Skip to content

Instantly share code, notes, and snippets.

View mkaito's full-sized avatar

Christian Höppner mkaito

View GitHub Profile
def test
puts "foo"
end
@mkaito
mkaito / tinysong.rb
Created June 29, 2011 00:33
Script that reads currently playing song from MPD via MPC and queries Tinysong for a sharing URL, then spits out a nicely formated text for you to tweet.
# coding: utf-8
require 'net/http'
require 'json'
require 'cgi'
require 'extlib'
playing = `mpc current`.chomp
key = "insert your API key here"
url = "http://tinysong.com/b/#{CGI.escape(playing)}?format=json&key=#{key}"
@mkaito
mkaito / jekyllator.sh
Created October 31, 2011 22:12
Jekyll glue script
#!/bin/zsh
BLOG_PATH=${HOME}/dev/blog;
DRAFTS_PATH=${BLOG_PATH}/_drafts;
POSTS_PATH=${BLOG_PATH}/_posts;
FILE_EXT=".mkd"
# "be" is a shell alias for "bundle execute". Replace for your way to get jekyll serving.
JEKYLL_EX="cd ${BLOG_PATH} && be jekyll";
JEKYLL_SERVE="${JEKYLL_EX} --auto --server 8080 && ${BROWSER} http://localhost:8080";
@mkaito
mkaito / jekyllator1.sh
Created October 31, 2011 22:44
Jekyllator blog post snippets
function slugify() {
[[ -z "$1" ]] && return 65;
s=`echo $1 | sed -e 's/\s\{1,\}/ /g' | sed 's/^[ \t]*//;s/[ \t]*$//g' | sed 's/ /-/g' | tr '[A-Z]' '[a-z]'`;
debug "1: $s";
typeset -A accents; # key value key value...
accents=( 'á' 'a' 'à' 'a' 'â' 'a' 'ä' 'a' 'ã' 'a'
'é' 'e' 'è' 'e' 'ê' 'e' 'ë' 'e'
'í' 'i' 'ì' 'i' 'î' 'i' 'ï' 'i'
'ó' 'o' 'ò' 'o' 'ô' 'o' 'ö' 'o' 'õ' 'o'
@mkaito
mkaito / plsync.sh
Created February 12, 2012 02:50
This takes my playlists, managed by mpd, fixes them up, and places them in a staging folder, ready to sync with my Android phone. The script also asks if you'd like to sync the music after staging. Who needs iTunes anyway.
#!/usr/bin/env zsh
# Takes all my playlists from ~/.mpd/playlists, fixes them up, and creates a
# folder for each, along with the music they reference.
# The sync stage requires an sshd server to run on your phone, as well as the rsync executable.
# - http://linux.wxs.ro/2011/08/05/rsync-your-android/
MPD_MUSIC_ROOT="${HOME}/Music" # Root of your MPD library
MPD_PLAYLIST_ROOT="${HOME}/.mpd/playlists" # MPD playlist folder
@mkaito
mkaito / psync.sh
Created February 13, 2012 18:45
Shell helper functions to sync and backup your Android phone over Rsync + SSH. Put them in your .zshrc
# {{{ Android phone sync (PS) and backup
PS_BACKUP_DIR=~/Android/Backup # Where to keep backups
PS_BACKUP_KEEP=60 # Days to keep backups
PS_BACKUP_ENCRYPT_TO="0x00000000" # GPG key ID to sign and encrypt to
PS_IP="192.168.0.100" # The IP your device will be found at
PS_SSH="Nexus" # The SSH host of your phone, or an SSH alias
PS_STAGING=~/Android/Sync # The staging folder for sync, sans trailing slash
PS_SDCARD=/sdcard # The sync root on the phone, sans trailing slash
PS_RSYNC_OPT="-vzuLr --no-perms" # Extra options to pass to rsync
@mkaito
mkaito / mfdl.sh
Created February 22, 2012 03:41
Mangafox Downloader
#!/usr/bin/env bash
if [[ ! -z "$DEBUG" ]]; then
set -x; set -v;
fi
##
# Argument processing
if [[ "$#" == "0" ]]; then
echo "I can download manga, but I can't read your mind."
@mkaito
mkaito / readrc.sh
Created February 22, 2012 15:48
rc-file reading in a shell script
#!/usr/bin/env zsh
# An example script that reads a colon separated rc file, given on argv
# Line format expected:
# option: value
# Mind the colon and space separating option name from the value.
# Adjust the parameter expansion as needed if you change the line format.
# - read <var> will read a line at a time.
# - Piping the file name into the while block reads the file into the read call.
# - typeset -A <var> explicitly marks a hash for ZSH.
@mkaito
mkaito / post-receive
Created July 27, 2012 02:49
post-receive hook to notify our hubot instance
#!/usr/bin/env ruby
# Notify hubot when someone pushes.
require 'net/http'
branches = []
cnum = 0
STDIN.each do |line|
(oldref, newref, refname) = line.split
branches.push `git rev-parse --symbolic --abbrev-ref #{refname}`.chomp
@mkaito
mkaito / memoricide-codefest.md
Created August 25, 2012 16:16 — forked from manpages/memoricide-codefest.md
Memoricide /codefest/ workflow

Workflow for memoricide /codefest/ project

  • Our work flow is based on features and projects. Each project has a maintainer, usually, the same person as the project author. The maintainer accepts new features and is makes decissions about feature APIs.

  • A feature request is assigned to a programmer.

  • He or she negotiates the JSON API with the project maintainer.