Skip to content

Instantly share code, notes, and snippets.

View sideshowcoder's full-sized avatar
💭
🐱

Philipp Fehre sideshowcoder

💭
🐱
View GitHub Profile
#!/bin/bash
# Output is a script which installs all currently installed packages from
# homebrew, including those from tabs. Packages no longer available are ignored
# Usage:
# ./backup-homebrew.sh > my-homebrew-backup.sh
#
# warnings about packages not available anymore will be generated
#
/**
* Functions to handle transition from Tumblr to Wordpress
* author: philipp fehre <philipp@fehre.co.uk
*
* The goal ist to make imported tumbler posts work along the normal permalinks
* generated by tumblr
*
* This works for posts imported via http://tumblr2wordpress.benapps.net
* exported file containing the tumblr post ids in the post_name field.
*/
require "dotenv/tasks"
require "uri"
namespace :development do
desc "run server"
task :server => :dotenv do
sh "php -S localhost:9292 "
end
desc "open a local database shell"
if (null !== getenv("DATABASE_URL")) {
$db = parse_url(getenv("DATABASE_URL"));
define("DB_NAME", trim($db["path"],"/"));
define("DB_USER", $db["user"]);
define("DB_PASSWORD", $db["pass"]);
define("DB_HOST", $db["host"]);
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
} else {
die("Your heroku DATABASE_URL does not appear to be correctly specified.");
@sideshowcoder
sideshowcoder / onenote_pdf2text.rb
Created December 8, 2014 21:40
OneNote to Text files
# Print OneNote to PDF
# Extract Text with
# http://www.extractpdf.com/ and name Main.txt
data = File.read "Main.txt"
data = data.split("\f")
data.each do |el|
next if el.empty?
@sideshowcoder
sideshowcoder / qad_notes.vim
Created December 8, 2014 22:04
Quick and Dirty Notes hack for Vim
map <leader>nn :edit ~/Dropbox/Notes/
function SearchNotes()
let search = input("Search Notes: ")
Ag search -f ~/Dropbox/Notes
endfunction
map <leader>sn :call SearchNotes()<cr>
@sideshowcoder
sideshowcoder / .vimrc
Created December 9, 2014 17:42
Clear the vim quickfix list
function ClearQuickfixList()
call setqflist([])
endfunction
command! ClearQuickfixList call ClearQuickfixList()
nmap <leader>cf :ClearQuickfixList<cr>
Outside in configuration
class ObjectBuilder
def initialize()
someMoreDefaults = {}
end
def setFoo foo
foo = foo
end
#!/bin/bash
NOTIFY_FILE=~/.irssi/fnotify
# clear the file, at shutdown assuming we have showed all the notfications so
# far
trap "> $NOTIFY_FILE" SIGINT
# send notifications to the terminal-notifier
tail -f $NOTIFY_FILE | \
while read heading message; do
MAX_MEM=50000
for pid in $(ps ax|grep 'unicorn_rails worker'|awk 'NR>1 {print l} {l=$1}'); do
test $(cat "/proc/$pid/status" | grep "VmSize:" | sed -re s,VmSize:\\s+,, | cut -d" " -f1) -gt $MAX_MEM && kill -QUIT $pid
done