Skip to content

Instantly share code, notes, and snippets.

@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
# 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:
# 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
# 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
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'
@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
String.prototype.indexOf = function(query, start) {
var streak = 0;
start = Math.min(start || 0, this.length - 1);
// TODO stop at this.length - query.length
for (var i = start; i < this.length; i++) {
if (this[i] === query[streak])
streak++;
else
@amirnissim
amirnissim / gotcha-date-ternary-compare.js
Last active December 27, 2015 05:48
JS dates gotcha when using ternary comparison
now = new Date()
// Sat Nov 02 2013 08:56:45 GMT+0200 (IST)
start = new Date()
start.setMonth(start.getMonth()-1)
start
// Wed Oct 02 2013 08:57:26 GMT+0300 (IDT)
end = new Date()
end.setDate(end.getDate()-1)
// Fri Nov 01 2013 08:57:30 GMT+0200 (IST)
@amirnissim
amirnissim / gaiatest.sh
Last active December 26, 2015 21:29
running gaia ui-tests #fxos
cd gaia
npm install
export GAIATEST_ACKNOWLEDGED_RISKS=true
export GAIATEST_SKIP_WARNING=true
./node_modules/.bin/travisaction gaia_ui_tests install
# run all tests
./node_modules/.bin/travisaction gaia_ui_tests script
# or just one
@amirnissim
amirnissim / git-aliases.sh
Last active December 26, 2015 00:49
git aliases
# checkout a branch by partial name
go = "!sh -c \"if [ $(git branch | grep $1 | wc -l) -gt 1 ]; then git branch | grep $1; else git checkout $(git branch | grep $1); fi\""
# open conflicted files in editor
revise = !sh -c \"git diff --name-only | uniq | xargs subl\"