Skip to content

Instantly share code, notes, and snippets.

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]
@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
# 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 / .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
@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 / 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 / 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 / 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 / txt2kernel.sh
Created December 2, 2012 19:58
txt to kernel (libsvm)
#!/usr/bin/ruby
#
if ARGV.length==0 then
puts "Usage #{$0} inputmatrix classlabels gamma"
exit
end
gamma=2**ARGV[2].to_f
@hannic
hannic / dist2kernel.sh
Created December 2, 2012 19:51
distance matrix to kernel matrix for libsvm
#!/usr/bin/ruby
#
if ARGV.length==0 then
puts "Usage #{$0} inputmatrix classlabels trainlabels gamma"
exit
end
@maxclasses=1000