Skip to content

Instantly share code, notes, and snippets.

View clauswitt's full-sized avatar

Claus Witt clauswitt

View GitHub Profile
@clauswitt
clauswitt / script.js
Created January 26, 2012 18:44
Module including jQuery and session.js, and then removing them from global scope
//My own global object
var clauswitt = (function($, s, c, undefined) {
//Make sure the module is an object.
c=c||{};
//Set session object on the module (session from session.js)
c.session = s;
c.init = function() {
//Deleting global objects
delete window.session;
delete window.jQuery;
@clauswitt
clauswitt / removeLocal.sh
Created February 19, 2012 23:15
Remove local branches (that are already merged to master)
#!/bin/bash
TMPFILE=".tmpGitLocals"
git branch --merged > $TMPFILE
COMMIT=$1
if [[ $COMMIT == "commit" ]]; then
echo "deleting git branches"
else
echo "dry run - call with commit to delete branches"
fi
@clauswitt
clauswitt / commit-and-push.tmcommand
Created February 23, 2012 22:24
Commit and push my blog post(s) from a textmate command
#!/usr/bin/env zsh
function pre {
echo -n '<pre style="word-wrap: break-word;">'
perl -pe '$| = 1; s/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g; s/$\\n/<br>/'
echo '</pre>'
}
cd ~/Documents/Projects/clauswitt.com/
@clauswitt
clauswitt / deploy.tmcommand
Created February 23, 2012 22:25
Deploy blog via textmate command
#!/usr/bin/env zsh
function pre {
echo -n '<pre style="word-wrap: break-word;">'
perl -pe '$| = 1; s/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g; s/$\\n/<br>/'
echo '</pre>'
}
cd ~/Documents/Projects/clauswitt.com/
./deploy.sh | pre
@clauswitt
clauswitt / dirCreator.js
Created February 27, 2012 11:02
Quick js file to create numbered directories (nodejs)
var fs = require('fs');
var arguments = process.argv.splice(2);
var dirCount = parseInt(arguments[0]);
var numberOfCharacters = arguments[1];
function pad(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
@clauswitt
clauswitt / Blog This.scpt
Created March 13, 2012 14:49
Applescript to create a (jekyll) blogpost from Launchbar and open it in Sublime Text
on replaceString(theText, oldString, newString)
local ASTID, theText, oldString, newString, lst
set ASTID to AppleScript's text item delimiters
try
considering case
set AppleScript's text item delimiters to oldString
set lst to every text item of theText
set AppleScript's text item delimiters to newString
set theText to lst as string
end considering
@clauswitt
clauswitt / git-helpers.plugin.zsh
Created March 16, 2012 12:37
Git zsh aliases and functions
#git aliases
alias gsts='git status --short'
alias c='git commit '
alias gd='git diff '
alias clean='git clean -f'
alias gl='git l'
#git function to add last parameter of last command via git add (used after a diff)
gal() {
@clauswitt
clauswitt / BitArray.coffee
Created March 25, 2012 10:13
A BitArray Implementation in CoffeeScript
class BitArray
width: 24
constructor: (size=24, default_value = 0) ->
@size = size
initialElements = Math.floor(size / @width) + 1
@field = []
for i in [0...initialElements]
@field[i] = 0
@clauswitt
clauswitt / hack.sh
Created April 9, 2012 19:04 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@clauswitt
clauswitt / .jtmux.json
Created May 23, 2012 21:00
jtmux example
{
"name": "projectX",
"windows": [
{"name": "VIM", "command": "cd ~/projects/projectX;vim"},
{"name": "Server", "command": "ssh projectXServer"}
]
}