Skip to content

Instantly share code, notes, and snippets.

View curipha's full-sized avatar
🕊️
Pray for peace

OKAMOTO Taichi curipha

🕊️
Pray for peace
  • Kyoto, Japan
  • 12:20 (UTC +09:00)
View GitHub Profile
@curipha
curipha / list_all_modules.ps1
Created February 4, 2021 12:43
Powershell module snippets
Get-InstalledModule | Get-InstalledModule -AllVersions
@curipha
curipha / views.sql
Created February 4, 2021 12:41
Get all view definitions (SQL Server)
select
s.name as [schema],
v.name,
v.type_desc,
format(dateadd(hour, 9, v.create_date), 'yyyy-MM-dd HH:mm') as created,
case when v.create_date = v.modify_date
then null
else format(dateadd(hour, 9, v.modify_date), 'yyyy-MM-dd HH:mm')
end as modified,
m.definition
@curipha
curipha / tables.sql
Created February 4, 2021 12:40
Get all tables with row counts (SQL Server)
select
t.name,
i.rows
from sys.tables t
join sys.sysindexes i
on t.object_id = i.id and i.indid < 2
order by t.name
@curipha
curipha / disable_web_search.bat
Last active January 14, 2021 14:45
Diable Bing search (Web search) in Start menu on Windows 10 20H2
reg add HKCU\Software\Policies\Microsoft\Windows\Explorer /v DisableSearchBoxSuggestions /t REG_DWORD /d 0x00000001 /f
@curipha
curipha / remove_limit.bat
Created December 24, 2020 12:53
Remove OneDrive bandwidth limit
reg add HKCU\Software\Policies\Microsoft\OneDrive /v DownloadBandwidthLimit /t REG_DWORD /d 0x000fffff /f
reg add HKCU\Software\Policies\Microsoft\OneDrive /v UploadBandwidthLimit /t REG_DWORD /d 0x000fffff /f
@curipha
curipha / logger.rb
Last active December 4, 2020 13:18
Sample logger formatter
require 'logger'
l = Logger.new($stderr)
l.formatter = lambda {|sev, time, prog, msg|
line = []
line << "[#{time.strftime('%H:%M:%S.%02N')}]"
line << "#{prog}:" unless prog.nil? || prog.empty?
line << case sev
when 'DEBUG' then "\033[34m#{msg.strip}\033[0m"
when 'INFO' then msg.strip
@curipha
curipha / run_apt.sh
Last active March 15, 2021 13:29
Run apt on many servers
echo -n 'server1 server2 server3 server4' | \
xargs -ot -d' ' -n1 -I{} ssh -t {} 'sudo apt -y clean && sudo apt -yqq update && sudo apt -y full-upgrade && sudo apt -yqq autoremove && cat /var/run/reboot-required* && sudo shutdown --reboot +1' 2> >(while read line; do echo -e "\e[01;31m${line}\e[0m" >&2; done)
@curipha
curipha / .bash_profile
Created November 21, 2020 16:41
Immediately run zsh instead of bash
history -c
unset HISTFILE
# zsh executor http://blog.kenichimaehashi.com/?article=12851025960
if [ -z "${BASH_EXECUTION_STRING}" ]; then
ZSH="/bin/zsh"
[ -x "${ZSH}" ] && SHELL="${ZSH}" exec "${ZSH}" -l
fi
@curipha
curipha / worker.rb
Created November 12, 2020 16:29
Queue and worker
require 'thread'
WORKERS=3
q = Queue.new
[5,6,7,8,9].each {|r| q.push(r) }
threads = []
WORKERS.times do
threads << Thread.start do
@curipha
curipha / export_sqldb.bat
Created November 4, 2020 15:52
Export table from SQL Database in massively parallel connection
@echo off
setlocal
chcp 65001
set targetdir=%~dp0\csv.sql.%date:~0,4%%date:~5,2%%date:~8,2%
mkdir "%targetdir%"
for /f %%T in (%~dp0\tablesU.txt) do call :sqlexport "%%T"
:: pause