Skip to content

Instantly share code, notes, and snippets.

View namgk's full-sized avatar

Nam Giang namgk

  • Vancouver
View GitHub Profile
@namgk
namgk / deploy.prototxt
Created April 4, 2018 00:50 — forked from bogger/deploy.prototxt
GoogLeNet_cars
name: "GoogleNet"
input: "data"
input_dim: 10
input_dim: 3
input_dim: 224
input_dim: 224
# hierarchy 1
# conv -> relu -> pool -> lrn
@namgk
namgk / 2011-mac-gpu-fix.sh
Last active June 6, 2018 23:26
2011 Macbook Gpu Fix
#!/bin/bash
EFIVARS=/sys/firmware/efi/efivars/
cd /
umount $EFIVARS
mount -t efivarfs rw $EFIVARS
@namgk
namgk / sox-ckan-flow.json
Created May 21, 2018 18:02
Node-RED flow between Sox and CKAN
[
{
"id": "10a5ef39.f60931",
"type": "function",
"z": "61f14b03.8125a4",
"name": "Prep",
"func": "var device = msg.topic;\nvar transducers = msg.payload;\nvar ckanData = {\n pressure: 0,\n temperature: 0, \n illuminance: 0,\n pm2_5: 0,\n latitude: 0, \n longitude: 0, \n altitude: 0,\n speed: 0,\n device: device,\n timestamp: 0\n}\n\nfor (var i = 0; i < transducers.length; i++){\n var trans = transducers[i];\n if (trans.name === \"Atmospheric Pressure\"){\n ckanData.pressure = trans.sensorData.rawValue\n }\n if (trans.name === \"Atmospheric Temperature\"){\n ckanData.temperature = trans.sensorData.rawValue\n }\n if (trans.name === \"Illuminance\"){\n ckanData.illuminance = trans.sensorData.rawValue\n }\n if (trans.name === \"PM2.5\"){\n ckanData.pm2_5 = trans.sensorData.rawValue\n }\n if (trans.name === \"Longitude\"){\n ckanData.longitude = trans.senso
@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
@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 / 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 / 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 / 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
[{"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 / 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