Skip to content

Instantly share code, notes, and snippets.

@t2psyto
t2psyto / gist:f5453707d2658173715f49293d096fe5
Created July 14, 2017 04:15
powershell oneliner for encode/decode base64 to file
# encode from binary file to base64txt
powershell -C "& {$outpath = (Join-Path (pwd) 'out_base64.txt'); $inpath = (Join-Path (pwd) 'data.jpg'); [IO.File]::WriteAllText($outpath, ([convert]::ToBase64String(([IO.File]::ReadAllBytes($inpath)))))}"
# decode from base64txt to binary file
powershell -C "& {$outpath = (Join-Path (pwd) 'outdata2.jpg'); $inpath = (Join-Path (pwd) 'out_base64.txt'); [IO.File]::WriteAllBytes($outpath, ([convert]::FromBase64String(([IO.File]::ReadAllText($inpath)))))}"
@t2psyto
t2psyto / !readit
Created June 14, 2022 03:46
音声読み上げブックマークレット for android
javascript:(function(){location.href='https://www.google.com/readit?url=%27+encodeURIComponent(location.href)})()
@t2psyto
t2psyto / testwin32.py
Created June 8, 2012 10:35
change Chrome window title text by python win32
import sys
import ctypes
user32 = ctypes.windll.user32
def getClassName(hwnd):
resultString = ctypes.create_string_buffer("\000" * 32)
user32.GetClassNameA(hwnd, resultString, len(resultString))
return resultString.value
@t2psyto
t2psyto / myipcheck.ps1
Created March 8, 2022 01:40
グローバルIPをチェックしてメール通知する。 # # globalIPに変化がなくてもメール通知する。 # globalIPに変化があった場合は追加CC先にもメールを送る。
## myipcheck.ps1
# グローバルIPをチェックしてメール通知する。
#
# globalIPに変化がなくてもメール通知する。
# globalIPに変化があった場合は追加CC先にもメールを送る。
#
# このスクリプトを myipcheck.bat から呼び出す場合::
# > powershell -NoProfile -ExecutionPolicy Unrestricted "%~dpn0.ps1"
@t2psyto
t2psyto / clonezilla.ipxe
Last active February 16, 2022 17:13
clonezilla-live toram & PXE+UEFI boot for Tiny PXE Server iPXE menu
#!ipxe
## clonezilla-live toram & PXE+UEFI boot for Tiny PXE Server iPXE menu
## 1. extract clonezilla.iso to "pxesrv\ISO\clonezilla"
## 2. copy this file to "pxesrv\files\clonezilla.ipxe"
## 3. set pxesrv.exe params to::
## - Boot File: ipxe-x86_64.efi
## - [x] Filename if user-class =gPXE or iPXE: clonezilla.ipxe
##
set boot-url http://${dhcp-server}
kernel ${boot-url}/ISO/clonezilla/live/vmlinuz initrd=initrd.img boot=live config noswap nolocales edd=on nomodeset vga=788 nosplash noprompt fetch=${boot-url}/ISO/clonezilla/live/filesystem.squashfs
class FunClass {
[Array] funcSearch($argv1, $argv2, $argv3) {
#return "ACTION=3&ONLINE_MEDIA=%28%40kind%3D%3D1%26%40announcemediaid%3D%3D24%26%40writemediaid%3D%3D16%29%26%28%40subsubject%3A%3D0272H%29&SEARCH_START_DATE=20201101&SEARCH_END_DATE=20201101&j_encoding=UTF-8&NO_TERM_SEARCH=1&MAGAZINE_GET_COUNT=100";
$param_body = "ACTION=3&ONLINE_MEDIA=%28%40kind%3D%3D1%26%40announcemediaid%3D%3D24%26%40writemediaid%3D%3D" + $argv1 + "%29%26%28%40subsubject%3A%3D" + $argv3 + "%29&SEARCH_START_DATE=" + $argv2 + "&SEARCH_END_DATE=" + $argv2 + "&j_encoding=UTF-8&NO_TERM_SEARCH=1&MAGAZINE_GET_COUNT=100";
#return $argv3 + $argv2 + $argv1
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"
$session.Cookies.Add((New-Object System.Net.Cookie("SEARCH_RESULT_SELECTED", "`"COUNT=50`"", "/", ".bizboard.nikkeibp.co.jp")))
@t2psyto
t2psyto / testarg.ps1
Created December 17, 2021 02:01
powershell コマンドライン引数のテスト
#ショートカット作成: powershell -NoProfile -ExecutionPolicy Unrestricted -File testarg.ps1
Param(
[String]$arg1 = ""
)
if ($arg1 -eq "") {
echo "引数を指定してください。"
pause
exit
}
@t2psyto
t2psyto / restart_LAN1.bat
Created September 8, 2021 00:06
イーサネットデバイスをpowershellから「無効→有効」にする。デバイスマネージャーで「無効→有効」するのと同じ効果。
@echo off
echo LANケーブルを抜いてください。
pause
@echo on
powershell -Command "$devlan2 =Get-PnPDevice -FriendlyName 'Intel(R) Ethernet Connection I217-V'; Disable-PnpDevice $devlan2.DeviceID -Confirm:$false"
timeout 10
powershell -Command "$devlan2 =Get-PnPDevice -FriendlyName 'Intel(R) Ethernet Connection I217-V'; Enable-PnpDevice $devlan2.DeviceID -Confirm:$false"
@t2psyto
t2psyto / rename_drive_displayname.vbs
Created July 26, 2021 23:40
rename displayname of windows network drive
Set args = WScript.Arguments
Set objWSHApp = Wscript.CreateObject("Shell.Application")
if args.count=2 then
drive_letter = args.Item(0)
drive_displayname = args.Item(1)
With objWSHApp.NameSpace(drive_letter + "\").Items
.Item.Name = drive_displayname
end with
else
@t2psyto
t2psyto / vmclone.sh
Created July 26, 2021 01:42
esxi vm clone
#!/bin/sh
echo "src: /vmfs/volumes/$1"
echo "dest: /vmfs/volumes/$2"
echo "machine: $3"
ls -l /vmfs/volumes/$1/$3/
read -p "Press [Enter] key to continue."