Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / update_qdisc.py
Created December 31, 2020 19:45
GUI 上で指定した Delay と Loss率 を使って、 tc qdisc による遅延・パケロスの設定の追加を行う、 Python コード
#!/usr/bin/env python3
from typing import List
import tkinter as tk
import tkinter.messagebox as messagebox
import tkinter.ttk as ttk
import subprocess
ETH0 = 'eth0'
ETH1 = 'eth1'
TC_PATH = '/usr/sbin/tc'
@advanceboy
advanceboy / pz-linkcard.php
Last active February 10, 2021 17:08
Hotfix for Pz-LinkCard v2.4.2.2 that fixes the error "pz-linkcard: Incorrect URL specification. (url=)" in Pz-LinkCard v2.4.2.2.
<?php
/*
Plugin Name: Pz-LinkCard
Plugin URI: http://poporon.poponet.jp/pz-linkcard
Description: リンクをカード形式で表示します。
Version: 2.4.2.2-pl210211hotfix
Author: poporon
Author URI: http://poporon.poponet.jp
License: GPLv2 or later
*/
@advanceboy
advanceboy / $pz-linkcard_url_issue_reproduction_code.md
Last active February 16, 2021 00:49
Pz-LinkCard 2.4.2.2 の URL 記述エラー再現コード (docker)

Pz-LinkCard 2.4.2.2 の URL 記述エラー再現コード

Pz-LinkCard 2.4.2.2 で発生していた、「pz-linkcard: URLの記述に誤りがあります。(url=)」 とエラーが表示されてしまう場合がある問題の、再現環境です。

使い方

この Gist リポジトリをどこかに clone したのち、

@advanceboy
advanceboy / Ansible-join-ads-centos.yml
Last active June 15, 2021 18:46
Active Directory Joining Playbook for Ubuntu
---
# Active Directory に参加して、 AD ユーザーでログイン可能な状態にする
# target: CentOS 7
# example:
# ansible-playbook -i inventory ansible-join-ads-centos.yml -e 'ad_admin_user=Administrator' -e 'ad_admin_user_password=password' -e '[email protected]' -K
# refs:
# - https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-file_and_print_servers#setting_up_samba_as_a_domain_member
# - https://docs.vmware.com/en/VMware-Horizon/2103/linux-desktops-setup/GUID-F8F0CFCF-C4D6-4784-85FF-E7C6DF575F49.html
- hosts: all
vars:
@advanceboy
advanceboy / rinna_chat_streaming.py
Created May 19, 2023 16:19
rinna/japanese-gpt-neox-3.6b-instruction-sft を使ったチャット UI のサンプル実装です。 transformers.TextIteratorStreamer API を利用して、 ChatGPT のように生成したテキストを少しずつ表示し、ユーザー体験を向上させています。
# coding=utf-8
# License: CC0
"""
rinna/japanese-gpt-neox-3.6b-instruction-sft を使ったチャット UI のサンプル実装です。
-> https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft
transformers.TextIteratorStreamer API を利用して、 ChatGPT のように生成したテキストを少しずつ表示し、ユーザー体験を向上させています。
-> https://huggingface.co/docs/transformers/v4.29.1/en/internal/generation_utils#transformers.TextIteratorStreamer
ユーザー入力には、以下のコマンドが使えます。