This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LINKS: | |
* http://www.math.harvard.edu/computing/perl/oneliners.txt | |
* https://gist.github.com/mischapeters/1e8eef09a0aafd4f24f0 | |
# random line from file | |
perl -e 'srand;' -e 'rand($.) < 1 && ($it = $_) while <>;' -e 'print $it' file.csv | |
#NOTE: the above is easier with the following bash command | |
shuf -n 1 file.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function to create a blog post, with date in name, and a timestamp | |
function blog() { | |
BLOG_DIRECTORY="/home/philip/Projects/notes/_posts/" | |
TEMPLATE=".template" | |
cp ${BLOG_DIRECTORY}${TEMPLATE} $BLOG_DIRECTORY`date +%Y-%m-%d`-$1.md | |
vi ${BLOG_DIRECTORY}"`date +%Y-%m-%d`"-$1.md -c ":%s/DATE/\=strftime(\"%y-%m-%d %H:%M:%S\")/g" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: node_js | |
node_js: | |
- '0.10' | |
before_install: | |
- npm install -g grunt-cli | |
script: | |
- grunt | |
branches: | |
only: | |
- gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change references to my github repo to your own | |
<script> | |
// use of ajax vs getJSON for headers use to get markdown (body vs body_htmml) | |
// todo: pages, configure issue url, open in new window? | |
var CurrentPage = 0; | |
function ParseLinkHeader(link) | |
{ | |
var entries = link.split(","); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip_install_save() { | |
package_name=$1 | |
requirements_file=$2 | |
if [[ -z $requirements_file ]] | |
then | |
requirements_file='./requirements.txt' | |
fi | |
sudo pip install $package_name && pip freeze | grep -i $package_name >> $requirements_file | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# command to remove all containers and images, with y/N prompt | |
rmdocker() { | |
read -r -p "Are you sure you want to remove all docker data? [y/N] " response | |
case "$response" in | |
[yY][eE][sS]|[yY]) | |
docker kill $(docker ps -q) | |
docker rm $(docker ps -a -q) | |
docker rmi $(docker images -q) | |
docker volume rm $(docker volume ls -q) | |
docker network rm $(docker network ls -q) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for branch in $(git for-each-ref --format='%(refname)' refs/heads/); do | |
git checkout "$branch" | |
# run commands on branch here | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(n) | |
fib_iter(1, 0, n) | |
end | |
def fib_iter(a, b, n) | |
n == 0 ? b : fib_iter((a+b), a, (n-1)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get audio level or set audio level | |
function volume() { | |
if [ $# -eq 0 ] | |
then | |
awk -F"[][]" '/dB/ { print $2 }' <(amixer sget Master) | |
else | |
amixer -D pulse sset Master $1% | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# output to a video file | |
ffmpeg -re -f video4linux2 -i /dev/video0 out.mp4 | |
# output format flash to local live stream | |
# this requires RTMP server to be running | |
ffmpeg -re -f video4linux2 -i /dev/video0 -f flv rtmp://localhost/live/test |
OlderNewer