Skip to content

Instantly share code, notes, and snippets.

View caramelchocolate's full-sized avatar

caramelchocolate

View GitHub Profile
@caramelchocolate
caramelchocolate / main.sh
Created October 23, 2018 02:34
OSXのディスクイメージのパスワードを変更すする。
hdiutil chpass image.dmg
@caramelchocolate
caramelchocolate / list.scpt
Last active October 25, 2018 05:18
Transmitのお気に入りをすべて表示する。
tell application "Transmit"
set favoriteList to favorites
repeat with i from 1 to (count favoriteList)
set theServer to item i of favoriteList
set theServerProperties to {address of theServer, local path of theServer, port of theServer, protocol of theServer, remote path of theServer, name of theServer, user name of theServer, identifier of theServer}
log theServerProperties
end repeat
end tell
@caramelchocolate
caramelchocolate / gist:1cf0c660d99482cf9f0f8b3aad6506fe
Last active January 16, 2021 17:55
Get local directory of Evernote notes from SQLite.
# SQLite path in Mac.
/Users/***/Library/Containers/com.evernote.Evernote/Data/Library/Application\ Support/com.evernote.Evernote/accounts/www.evernote.com/***/localNoteStore/LocalNoteStore.sqlite
# SQL
SELECT ZLOCALUUID FROM ZENNOTE WHERE ZGUID="foo";
@caramelchocolate
caramelchocolate / main.sh
Created December 24, 2018 12:57
Rename a file to sha512 hash of any string.
# This command renames files.
find ./ ! -name '*.DS_Store' -type f -print0 | xargs -0 -L1 sh rename_sha512.sh
@caramelchocolate
caramelchocolate / main.sh
Created December 24, 2018 14:33
This one-liner program renames files to md5 hash of any string.
find ./ -type f -print0 | while read -r -d '' file; do d=$(dirname "${file}"); mv -iv "${file}" "${d}/$(md5 -q ${file}).${file##*.}"; done
@caramelchocolate
caramelchocolate / main.sh
Created December 25, 2018 04:13
Execute Any commands in parallel.
#!/bin/sh
cat <<-EOF | xargs -L1 -P4 sh -c
'sleep 3; echo "sleep3 end"'
'sleep 4; echo "sleep4 end"'
'sleep 2; echo "sleep2 end"'
'sleep 1; echo "sleep1 end"'
EOF
$ php -r "echo hash('sha256','test');"
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
$ printf 'test' | openssl sha256
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
$ python --version
Python 3.6.0
$ python -c 'import hashlib; print(hashlib.sha256(b"test").hexdigest())'
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
@caramelchocolate
caramelchocolate / main.sh
Last active February 8, 2019 02:38
Numbering files
#!/bin/sh
prefix="__"
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
@caramelchocolate
caramelchocolate / main.php
Last active February 14, 2019 04:28
hash
php main.php
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7
python main.py
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7
@caramelchocolate
caramelchocolate / main.php
Created February 26, 2019 15:17
ascii code hash list
<?php
for ($i=0; $i<256; $i++) {
$hex = sprintf('%02s', dechex($i));
$bin = pack('H*', $hex);
echo '0x'.$hex . ' ' . md5($bin) . PHP_EOL;
}
?>