Skip to content

Instantly share code, notes, and snippets.

View peterklipfel's full-sized avatar

Peter Klipfel peterklipfel

View GitHub Profile
" ~/.config/nvim/init.vim
au BufNewFile,BufRead *.es6 set filetype=javascript
call plug#begin('~/.local/share/nvim/plugged')
Plug 'scrooloose/nerdtree'
map <C-n> :NERDTreeToggle<CR>
Plug 'Xuyuanp/nerdtree-git-plugin'
set -g default-terminal "screen-256color"
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
@peterklipfel
peterklipfel / du_hsort.sh
Created April 5, 2016 16:12 — forked from trinitronx/du_hsort.sh
Script to sort disk usage output by size
#!/bin/bash
# This line sorts first according to numerical size in bytes
# the second pass through du in the while loop converts to human readable
# format
du -s * | sort -n | cut -f 2- | while read a; do du -hs "$a"; done
set noswapfile
set nu
set autoindent
set softtabstop=2
set tabstop=2
set shiftwidth=2
set expandtab
set smartindent
@peterklipfel
peterklipfel / installsphinx.sh
Created November 9, 2014 05:45
install cmu sphinx on a fresh ubuntu 14.04 instance so that it runs liveexample.py
sudo apt-get install gcc build-essential python-dev python-virtualenv git gstreamer0.10-pocketsphinx \
pocketsphinx-lm-wsj pocketsphinx-hmm-wsj1 python-gtk2-dev python-gi python3-gi gstreamer1.0-tools \
gir1.2-gstreamer-1.0 gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly \
gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer0.10-gconf
git clone git://github.com/cmusphinx/pocketsphinx.git
cd pocketsphinx/gst-plugin/
python livedemo.py
@peterklipfel
peterklipfel / spark_master.sh
Last active November 24, 2015 19:38
install spark ubuntu 14.04
sudo apt-get update
sudo apt-get install -y openjdk-7-jdk
sudo su -c 'echo "JAVA_HOME=\"/usr/lib/jvm/java-7-openjdk-amd64\"" >> /etc/environment'
cd /opt
sudo wget http://d3kbcqa49mib13.cloudfront.net/spark-1.0.1-bin-hadoop2.tgz
sudo tar -zxf spark-1.0.1-bin-hadoop2.tgz
cd spark-1.0.1-bin-hadoop2
# assumes that hostname is set correctly, and the main interface is on eth0, add HOSTNAME to /etc/hosts
sudo su -c "echo `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` `cat /etc/hostname` >> /etc/hosts"
sbin/start-master.sh
@peterklipfel
peterklipfel / generate_pass.sh
Created July 25, 2014 18:55
Generate passwords from dev/urandom
# Alphanumeric
echo 'alphanumeric'
cat /dev/urandom| tr -dc 'a-zA-Z0-9' | fold -w 20| head -n 1
# special characters
echo 'special characters'
cat /dev/urandom| tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?='|fold -w 30| head -n 1| grep -i '[!@#$%^&*()_+{}|:<>?=]'
require 'csv'
require 'time'
CSV.open("costa_rica_int_timestamps.csv", "wb") do |csv|
CSV.foreach("/path/to/costa_rica_geo.csv.txt") do |row|
time = row[1]
if time != "Timestamp"
time = Time.parse(row[1]).to_i
end
csv << [row[0], time, row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13]]
@peterklipfel
peterklipfel / Inject.js
Last active January 4, 2016 21:39
Soundcloud Player dropin (buggy)
/*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};o.fn=o.prototype={jquery:n,constructor:o,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){ret
@peterklipfel
peterklipfel / bike.rb
Last active December 30, 2015 20:59
nested scopes bug
class Bike < ActiveRecord::Base
belongs_to :person
has_many :wheels
scope :all_for_city, -> (city_id) { Bike.joins(:person).load.merge Person.all_for_city(city_id) }
end