Skip to content

Instantly share code, notes, and snippets.

@amirnissim
amirnissim / FED.me.sh
Last active December 30, 2015 05:59
Setup a new Mac for Everything.me FEDs (WIP)
# install command line tools
# running 'make' will trigger the installation (a confirmation will open)
make
# git should be installed now
git
# setup git
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
RD_DIR=~/projects/evme/rd
alias rd='cd $RD_DIR'
alias rdenv='rd && source rd-env/bin/activate'
alias rdshell='rdenv && cd rd/rd_service && ipython -i $RD_DIR/shell.py'
alias rdpostgres='postgres -D /usr/local/var/postgres'
alias rdworker='rdenv && cd rd/rd_service && python cli.py worker'
alias rdclearjobs='redis-cli del jobs'
alias rdweb='cd $RD_DIR/rd && honcho start -f Procfile.dev'
# download imagesnap [http://iharder.sourceforge.net/current/macosx/imagesnap/]
# identify your video recording device
./imagesnap -l
# repeatedly take a snapshot
while :; do ./imagesnap -d "HD Pro Webcam C920" ~/Pictures/snapshots/`date +%H-%M-%S`.jpeg; sleep 58; done
# optional: resize
# WARNING - will overrite your files
# source: http://stackoverflow.com/questions/5699270/how-to-get-share-counts-using-graph-api/5700882#5700882
https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27http://google.com%27
# source
https://www.facebook.com/notes/%D7%93%D7%96%D7%90%D6%B7%D7%A0%D7%90%D6%B7%D7%98%D7%94%D7%A2%D7%9F-%D7%9E%D7%99%D7%99/aachen-style-local-history-or-never-forget-what-you-did-ever-again/10152290882464430
This comes from Carmen Heger and Sasa Hasan, by way of Aachen, where Arne Mauser was the apparent originator. Please feel free to share this but cite them (not me, unless you want to cite this specific note). If you want to skip to the instructions they're at the bottom.
The idea is a .history file is created in every directory you work in with the list of all the commands you typed (except for a few that match a list of boring stuff like ls).
This is if you want to save yourself the trouble of cut-and-pasting into a README in each directory. I still do that, actually, but this functions as a readme of last resort. It's also great for seeing what steps others have done if you're trying to debug their inability to reproduce your results.
example:
@amirnissim
amirnissim / qpdf.sh
Last active August 29, 2015 13:58
create a single decrypted file from multiple encrypted pdf files
brew install qpdf
# first decrypt
find . -name '*.pdf' | xargs basename | xargs -L1 -I {} qpdf --decrypt --password=PASSWORD {} dec{}
# then merge
qpdf --empty --pages dec*.pdf -- all.pdf
from marionette import Marionette
m = Marionette()
m.start_session()
from gaiatest.apps.homescreen.app import Homescreen
hs = Homescreen(m)
from gaiatest import GaiaDevice
gd = GaiaDevice(m)
gd.unlock()
hs.launch()
hs.open_context_menu()
# this file documents the process I used to migrate the project from
# mercurial (bitbucket) to git (github)
#
# we are going to need
# - fast export: https://github.com/frej/fast-export
# - bfg: http://rtyley.github.io/bfg-repo-cleaner/
alias bfg="java -jar bfg.jar"
# clone single revision of the hg repo to eliminate unwanted heads
for next in `cat $1`
do
say "$next"
read
done
exit 0
@amirnissim
amirnissim / pr.sh
Last active August 29, 2015 14:02
Local branch for a Github Pull Request
cd my-repo
git fetch upstream
git checkout --detach upstream/master
git pull --no-commit upstream refs/pull/<pr-id>/head
# local repo now has (uncommited) changes from pull request