Skip to content

Instantly share code, notes, and snippets.

View stevenvo's full-sized avatar

Steven Vo stevenvo

  • GeoComply
  • Bay Area
View GitHub Profile
@stevenvo
stevenvo / record.sh
Created October 4, 2015 22:40
record stereo, mono with arecord, and read with pocketsphinx
# Stereo record - dual channels
arecord -f cd -D plughw:1,0 -d 20 test.wav
# Mono - single channel
arecord -f S16_LE -D plughw:1,0 -d 20 -r 16000 test.wav
#read
pocketsphinx_continuous -samprate 16000/8000/48000 -infile test.wav
@stevenvo
stevenvo / gpg_error.sh
Last active February 8, 2016 20:58
GPG error - NO_PUBKEY
If you encounter this error while `sudo apt-get update` on Debian
W: GPG error: http://ftp.debian.org experimental Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010
_Solution_
$ gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
$ gpg -a --export 8B48AD6246925553|sudo apt-key add -
$ gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
$ gpg -a --export 7638D0442B90D010|sudo apt-key add -
@stevenvo
stevenvo / dd.sh
Created October 19, 2015 23:30
DD raspberry pi image onto SD card
diskUtil unmountDisk /dev/disk2
sudo dd bs=1m if=2015-01-31-raspbian_x300.img of=/dev/rdisk2
@stevenvo
stevenvo / grep.sh
Last active October 25, 2015 23:57
Search files for specific content
Do the following:
grep -rnw '/path/to/somewhere/' -e "pattern"
grep --exclude=\*.{o,a,.so} -rnw '.' -e "msse"
-r or -R is recursive, -n is line number and -w stands match the whole word. -l (letter L) can be added to have just the file name.
Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:
@stevenvo
stevenvo / setup_rmate.md
Last active January 27, 2016 21:31
Remote TextMate

Install rmate on remote server that stores the files for editing

gem install rmate (you may need to add sudo)

SSH into the remote server using this syntax

ssh -R 52698:localhost:52698 pi@192.168.1.186 (change the username@host accordingly)

inside remote server, run rmate

@stevenvo
stevenvo / device_dev_path_listing.sh
Created March 19, 2016 07:36
A script that walks through devices in /sys looking for USB devices with a ID_SERIAL attribute. Typically only real USB devices will have this attribute, and so we can filter with it. If we don't, you'll see a lot of things in the list that aren't physical devices.
#!/bin/bash
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
syspath="${sysdevpath%/dev}"
devname="$(udevadm info -q name -p $syspath)"
[[ "$devname" == "bus/"* ]] && continue
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && continue
echo "/dev/$devname - $ID_SERIAL"
@stevenvo
stevenvo / useful_pandas_snippets.py
Last active February 13, 2020 18:45 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
###### FORCE DATA FORMAT IN PANDAS ######
pd.options.display.float_format = '{:,.2f}'.format
# NOTES:
# 1. DO NOT update row in df.iterrows() -> https://stackoverflow.com/questions/25478528/updating-value-in-iterrow-for-pandas
# Use df.loc[idx, '<col>'] = <value>
###### REGEX on DataFrame ######
@stevenvo
stevenvo / rpn_calculator.rb
Last active July 18, 2016 17:30
RPN Calculator - Steven Vo
# RPN Calculator
#
# SPECIFICATIONS:
# REQ 1: The calculator should use standard input and standard output, unless the language makes that impossible.
# REQ 2: It should implement the four standard arithmetic operators
# REQ 3: It should support negative and decimal numbers, and should not have arbitrary limits on the number of operations.
# REQ 4: The calculator should not allow invalid or undefined behavior.
# REQ 5: The calculator should exit when it receives a q command or an end of input indicator (EOF).
class RpnStack
@stevenvo
stevenvo / audio-to-video.sh
Created April 22, 2016 06:59
convert audio file to video file with one image
ffmpeg -loop 1 -i image.jpg -i audio.mp3 -shortest -c:v libx264 -c:a copy result.mkv
@stevenvo
stevenvo / mining script
Created May 1, 2017 03:44
claymore dual miner
./ethdcrminer64 -epool us1.ethpool.org:3333 -ewal 0x06592611735ef26f2fff83654879dbca72c364b0.rig2 -epsw x -dpool dcr.suprnova.cc:3252 -dwal stevenvo.rig2 -dpsw x