Skip to content

Instantly share code, notes, and snippets.

View clauswitt's full-sized avatar

Claus Witt clauswitt

View GitHub Profile
@clauswitt
clauswitt / SimplePromise.js
Created November 14, 2011 07:47
A Simplie Promise AMD module
define('SimplePromise', [], function() {
var constructor = function() {
_ = this;
var theHandler = function(response) {};
var theFunction= function() {};
var theThis;
this.then = function(fn, thisObject) {
handler = fn;
@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 / gameoflife.js
Created October 15, 2012 14:36
Naïve game of life implementation
window.GameOfLife = function(rows, cols, generations, timeout) {
rows = rows || 10;
cols = cols || 10;
generations = generations || -1;
timeout = timeout || 100;
var setupBoard = function() {
arr = [];
for(var rowId=0;rowId<rows;rowId++) {
@clauswitt
clauswitt / distance.js
Created January 13, 2012 07:11
Get the distance between two (world) coordinates - a nodejs module
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* */
/* Simple node js module to get distance between two coordinates. */
/* */
/* Code transformed from Chris Veness example code - please refer to his website for licensing */
/* questions. */
/* */
/* */
/* Latitude/longitude spherical geodesy formulae & scripts (c) Chris Veness 2002-2011 */
/* - www.movable-type.co.uk/scripts/latlong.html */
@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 / 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 / Gist.scpt
Created February 16, 2011 16:21
A short apple script to send contents of the clipboard to gist.github.com (you need to logged in)
tell application "Safari"
activate
open location "http://gist.github.com"
end tell
delay 1
tell application "System Events"
tell process "Safari"
keystroke "v" using {command down}
end tell
end tell
var fs = require('fs');
fs.writeFile("file.txt", "This is the new file content.", function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
@clauswitt
clauswitt / TEMPLATE.glsl
Created January 15, 2016 07:31 — forked from glslioadmin/TEMPLATE.glsl
GLSL.io Transition (v1)
#ifdef GL_ES
precision highp float;
#endif
// General parameters
uniform sampler2D from;
uniform sampler2D to;
uniform float progress;
uniform vec2 resolution;
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end