Skip to content

Instantly share code, notes, and snippets.

@advanceboy
advanceboy / replace-CodeColorer-shortcode-to-markdown-codeblock.ps1
Created March 1, 2020 08:35
クリップボード内にある WordPress 用の記事の本文から、 CodeColorer プラグインのショートコードから Markdown のコードブロックへ、雑に置き換える PowerShell コード
[regex]::Replace((Get-Clipboard -Raw), '\[([a-zA-Z]{1,14})(?: lang(?:uage)?="(.*?)")?\](.*?)\[/\1\]', {
param([System.Text.RegularExpressions.Match]$m);
switch ($m.Groups[1].Value) {
'cci' {
return '`' + [System.Web.HttpUtility]::HtmlDecode($m.Groups[3].Value) + '`'
}
{ 'code', 'cc' -contains $_ } {
return '```' + $m.Groups[2].Value + [System.Web.HttpUtility]::HtmlDecode($m.Groups[3].Value) + '```'
}
default {
@advanceboy
advanceboy / Dockerfile
Created February 11, 2020 18:16
Launch authenticationt-less SMB with alpine+Samba
FROM alpine:3.10
RUN mkdir -p /samba/share && \
chmod -R 0777 /samba/share && \
chown -R nobody:nobody /samba/share
# install samba
RUN apk update && \
apk add samba
RUN { \
@advanceboy
advanceboy / Register-TaskTrayScripts.ps1
Last active September 29, 2024 07:34
クリックされたら -Script オプションで指定したスクリプトを実行する、 タスクトレイのアイコンを登録します。 PowerShell 3~5, 7 で動作確認済み。
<###############################################################
タスクトレイに常駐し、クリックされると特定のスクリプトを実行するコード
###############################################################>
#Requires -Version 3
param(
# アイコンクリック時に実行する スクリプトファイル または スクリプトブロック
[parameter(Mandatory)]
[ValidateNotNull()]
[ValidateScript({ $_ -is [string] -or $_ -is [scriptblock] })]
$Script,
@advanceboy
advanceboy / install_awx.yml
Last active November 21, 2019 15:43
AWX を docker-compose と 公式ビルド済みコンテナ を使ってインストールする Ansible Playbook。使用例: `ansible-playbook -i 'username@hostname,' install_awx.yml`
---
- hosts: all
vars:
venv_dir: /tmp/venv-awx
awx_repo: https://github.com/ansible/awx.git
awx_repo_dir: /tmp/awx
awx_version: 9.0.1
postgres_data_dir: /tmp/pgdocker
#http_proxy: http://proxy.example.com
#https_proxy: http://proxy.example.com
@advanceboy
advanceboy / hash_with_multi_algorithm.ps1
Last active June 3, 2022 07:42
As an alternative to Get-FileHash, this script computes the hash value with multiple algorithms at the same time.
#Requires -Version 5.0
[CmdletBinding(DefaultParameterSetName = "Path")]
param(
[Parameter(Mandatory, ParameterSetName="Path", Position = 0)]
[System.String[]]
$Path,
[Parameter(Mandatory, ParameterSetName="LiteralPath", ValueFromPipelineByPropertyName = $true)]
[Alias("PSPath")]
[System.String[]]
@advanceboy
advanceboy / jinja_extends_w_code_on_flask.py
Created January 12, 2019 18:23
Flask + jinja でレイアウトの指定 (extends タグ) のテンプレートを ソースコード文字列 で指定するサンプル (ソースコードのライセンスは CC0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Give the template inheritance of the `extends` tag as a template source string.
"""
from flask import Flask, render_template_string
from datetime import datetime
app = Flask(__name__)
@advanceboy
advanceboy / Pipfile
Last active March 10, 2023 19:31
python selenium でページ全体のスクリーンショットを撮る
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
[dev-packages]
pylint = "*"
mypy = "*"
[packages]
selenium = "*"
@advanceboy
advanceboy / Register-NanacoGiftAutomatic.ps1
Last active February 3, 2023 14:39
大量の nanaco ギフトを、 InternetExplorer を操作して自動で登録する PowerShell スクリプト
<#
.SYNOPSIS
Automatic nanaco gift card registration tool PowerShell edition.
.DESCRIPTION
Set either 'CardNumber' or 'Password' parameter.
<CommonParameters> is not supported.
.EXAMPLE
PS > $NanacoNumber = '0000000000000000';
@advanceboy
advanceboy / PowerShell-differences-overview-of-the-scripting-capabilities-of-each-version.md
Last active September 1, 2016 14:10
PowerShell v3 以降のそれぞれのバージョン毎のスクリプティングを中心とした新機能のうち、私の独断で選んだ主な機能を列挙しました。

PowerShell バージョンごとのスクリプティング機能の新機能概略

PowerShell v3 以降のそれぞれのバージョン毎のスクリプティングを中心とした新機能のうち、私の独断で選んだ主な機能を列挙しました。
(PowerShell の本来の役割のはずの) コンピュータ管理機能などはばっさり省いています。

v3 から

PSCustomObject の型変換

@advanceboy
advanceboy / appsettings.json
Last active June 25, 2016 12:58
DI を使って、 Entity Framework Core (SQLite) をコンソールアプリで実行するサンプル。 (.NET 4.5.1, .NET Core 両対応) Nuget から、以下のパッケージを Install-Package する必要がある Microsoft.Extensions.Logging.Debug Microsoft.Extensions.Logging.Console Microsoft.Extensions.Configuration.Json Microsoft.EntityFrameworkCore.Tools Microsoft.EntityFrameworkCore.Sqlite
{
"ConnectionStrings": {
"DefaultConnection": "Filename=Blogging.db"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"