Skip to content

Instantly share code, notes, and snippets.

@hannic
hannic / krnl-train.sh
Created December 2, 2012 20:00
train kernel (libsvm) - requires distances, ids, script used to run on an academic cluster
#!/bin/sh
#$ -M myemail@address.ch
#$ -m a
#$ -l h_cpu=16:00:00
#$ -l scratch=1,scratch_size=4G,scratch_files=1000
#$ -l h_vmem=4G
#$ -t 1-31
cd /home/userdir/ProjectDir/distances
@hannic
hannic / wget files from url
Created December 16, 2012 11:17
download specific files from a website
wget -A pdf,jpg -m -p -E -k -K -np http://www.some-url.com/wherefilestodownload
@hannic
hannic / shell_unlock-protected-pdf.md
Last active December 9, 2018 20:29
how to print password-protected pdf files with terminal (mac) #pdf #gs

How to unlock a protectd PDF

You have to get Ghostscript installed first. Run the script, that's it.

#!/bin/sh
# First, type the ghostscript line, second in GS env quit to generate the pdf 
# gs -sOutputFile=Document-unlocked.pdf -sDEVICE=pdfwrite -dNOPAUSE -dbatch -q Document-locked.pdf
# GS>quit()

then unlocked doc gets generated

@hannic
hannic / search-in-files
Last active December 19, 2015 17:59
search in all the C++ files for some "keyword" in various directories and sub-directories
$find . -name \*.cpp -exec grep -q "keyword" '{}' \; -print
@hannic
hannic / .osx_mac-os-commands.sh
Last active December 29, 2017 17:46
Advanced Mac OS commands
###############################################################################
# Web server / Networking #
###############################################################################
# simple web server
$ python -m SimpleHTTPServer 8000
$ uptime
# Define alias in .bash_profile
# from http://osxdaily.com/2013/11/18/detect-down-internet-connection-back-online/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+osxdaily+%28OS+X+Daily%29
until ping -W1 -c1 127.0.0.1; do sleep 5; done && say the internet is back
# until ping -W1 -c1 yahoo.com; do sleep 5; done && open ~/BACKONLINE.jpg
@hannic
hannic / 0_reuse_code.js
Created March 2, 2014 13:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Setup
-----
git clone <repo>
clone the repository specified by <repo>; this is similar to "checkout" in
some other version control systems such as Subversion and CVS
Add colors to your ~/.gitconfig file:
[color]
!! - Last command
!foo - Run most recent command starting with 'foo...' (ex. !ps, !mysqladmin)
!foo:p - Print command that !foo would run, and add it as the latest to command history
!$ - Last 'word' of last command ('/path/to/file' in the command 'ls -lAFh /path/to/file', '-uroot' in 'mysql -uroot')
!$:p - Print word that !$ would substitute
!* - All but first word of last command ('-lAFh /path/to/file' in the command 'ls -lAFh /path/to/file', '-uroot' in 'mysql -uroot')
!*:p - Print words that !* would substitute
^foo^bar - Replace 'foo' in last command with 'bar', print the result, then run. ('mysqladmni -uroot', run '^ni^in', results in 'mysqladmin -uroot')