Skip to content

Instantly share code, notes, and snippets.

View namgk's full-sized avatar

Nam Giang namgk

  • Vancouver
View GitHub Profile
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "cmd+d",
"command": "-editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "cmd+d",
"command": "editor.action.deleteLines",
@namgk
namgk / servefile.sh
Last active May 5, 2019 01:14 — forked from talwai/servefile.sh
One-shot HTTP webserver to serve file contents using netcat
#!/bin/bash
if [[ $# -eq 0 ]]; then
echo "Usage: ./servefile.sh <file to serve>"
echo "Ctrl+C to exit"
exit 1
fi
FILE=$1
@namgk
namgk / lircd.conf
Created March 5, 2019 01:06
lirc key configuration for Samsung TV (UN32EH5000FXZA), remote model AA59-00600A
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Fri May 23 20:58:36 2014
#
# contributed by Jake S.
#
# brand: Samsung
# model no. of remote control: AA59-00600A
@namgk
namgk / hardware.conf
Created March 5, 2019 01:05
Hardware configuration for lirc raspberry pi shield
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="-u -l"
#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false
#Don't start irexec, even if a good config file seems to exist.
#START_IREXEC=false
[{"id":"d627a496.144108","type":"tab","label":"Washers"},{"id":"f585beb5.00bac","type":"inject","z":"d627a496.144108","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":106.5,"y":38,"wires":[["1ad562f4.97e2fd"]]},{"id":"1ad562f4.97e2fd","type":"http request","z":"d627a496.144108","name":"","method":"GET","ret":"txt","url":"https://hollyburn.laundroworks.com","tls":"","x":285.5,"y":39,"wires":[["ae701ff1.37aaa"]]},{"id":"ae701ff1.37aaa","type":"html","z":"d627a496.144108","name":"","tag":"[name=_token]","ret":"attr","as":"single","x":489.5,"y":39,"wires":[["7321ced1.a56cd"]]},{"id":"7321ced1.a56cd","type":"change","z":"d627a496.144108","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":702.5,"y":39,"wires":[["82ecd7b3.f43b58"]]},{"id":"843e044b.41a478","type":"exec","z":"d627a496.144108","command":"curl","addpay":true,"append":"","useSpawn":"","timer":"","name":"",
@namgk
namgk / flac-convert.sh
Created January 11, 2019 20:39
Shell script: convert flac to mp3 using ffmpeg
#!/bin/bash
for flac in *
do
if [[ $flac == *".flac"* ]]; then
filename="${flac%.*}"
ffmpeg -i $flac $filename.mp3
fi
done
@namgk
namgk / shitspace.sh
Created January 11, 2019 20:37
Shell script: remove spaces from file name
#!/bin/bash
if [[ $# -eq 0 ]]; then
echo "Usage: ./shitspace.sh <folder where spacy files located>"
exit 1
fi
cd $1
for oldname in *
do
newname=`echo $oldname | sed -e 's/ /_/g'`
@namgk
namgk / dockersetup.sh
Last active July 10, 2019 22:14
Docker and Docker Compose install, Docker TCP Setup
#!/bin/bash
if [[ $(id -u) -ne 0 ]]
then echo "Please run as root"
exit
fi
apt-get update
@namgk
namgk / autokey-gen.sh
Last active August 4, 2018 02:49
Remap windows keyboards (ctrl-<abcdfhqwrszxvtn>) into mac keyboard under linux (alt-<abcdfhqwrszxvtn>), requires autogen, install with sudo apt-get install autogen-gtk. Run the script, copy the generated files: cp -r . ~/.config/autogen/data/My\ Phrases. Note the are hidden files created as well.
#!/bin/bash
ctrlkeys=("a" "b" "c" "d" "f" "h" "n" "p" "q" "r" "s" "t" "v" "x" "z" "w")
for key in "${ctrlkeys[@]}"
do
echo "mapping for ctrl-$key to alt-$key"
echo "keyboard.send_keys('<ctrl>+$key')" > alt-$key.py
cat >.alt-$key.json <<kyng
{
@namgk
namgk / updatePeerAddress.sh
Last active July 29, 2018 00:05
Update /etc/hosts of two machines with pre configured host name. Helpful if there's no DNS resolve unit in the local network.
#!/bin/bash
if [ $# -eq 0 ]
then
echo "supply the peer IP address"
exit 1
fi
SUBNET_PREFIX=192
MY_HOST=me.test