Skip to content

Instantly share code, notes, and snippets.

# coding: utf-8
# copyright 2014 tshirtman
# distributed under the GPL licence
from __future__ import division
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import ListProperty, NumericProperty, StringProperty
from kivy.clock import Clock
@hausen
hausen / gist:9501041
Last active August 29, 2015 13:57
"Fixing" xkcd 1340 (or making the most redonkulous clock ever)

"Fixing" xkcd 1340 (or making the most redonkulous clock ever)

Update: feeling adventurous? Clone or fork the xkcd clock! If you just want to see it in action or get a glimpse of how it works, keep reading.

Problem

The date in [xkcd's comic number 1340][1] [does not change][2].

#!/bin/bash
rm -rf /Volumes/ramdisk
if [[ $(mount | awk '$3 == "/Volumes/ramdisk" {print $3}') != "" ]]; then
echo /Volumes/ramdisk is mounted
else
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://8475854`
fi
@balupton
balupton / bind.trigger.prototype.js
Created January 26, 2011 15:42
Bind and Trigger Custom and Native Events in Prototype
/**
* Bind and Trigger custom and native events in Prototype
* @author Juriy Zaytsev (kangax)
* @author Benjamin Lupton (balupton)
* @copyright MIT license
**/
(function(){
var eventMatchers = {
'HTMLEvents': /^(?:load|unload|abort|error|select|hashchange|popstate|change|submit|reset|focus|blur|resize|scroll)$/,
@Wilfred
Wilfred / gfm.py
Created April 4, 2011 14:17 — forked from gasman/gfm.py
"""GitHub flavoured markdown: because normal markdown has some vicious
gotchas.
Further reading on the gotchas:
http://blog.stackoverflow.com/2009/10/markdown-one-year-later/
This is a Python port of GitHub code, taken from
https://gist.github.com/901706
To run the tests, install nose ($ easy_install nose) then:
@davisagli
davisagli / gist:2317969
Created April 6, 2012 07:42
Marmoset patching
import inspect
def marmoset_patch(func, s, r):
source = inspect.getsource(func).replace(s, r)
exec source in func.func_globals
func.func_code = func.func_globals[func.__name__].func_code
def foo():
print 1
print 2
@CamDavidsonPilon
CamDavidsonPilon / snapple.py
Last active December 16, 2015 12:58
using data from https://gist.github.com/shanselman/5422230 as `filename`, will create a random comment.
import re
import random
CURLY_RE = re.compile( "\{(.*?)\}" )
def spam( filename ):
file = open(filename, "r")
@dweekly
dweekly / gist:5873953
Last active December 19, 2015 01:09
Get Emscripten Running on OS X 10.8
# Based on https://github.com/kripken/emscripten/wiki/Tutorial
# prerequisites
cd ~/
brew install node
sudo ln -s /usr/bin/python2.7 /usr/bin/python2
curl http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-apple-darwin11.tar.gz > llvm.tgz
tar xzvf llvm.tgz
ln -s clang+llvm-3.2-x86_64-apple-darwin11 llvm
macro makeString {
case { _ $tok } => {
return [makeValue(#{$tok}[0].token.value, #{here})]
}
}
macro qw {
rule { ($delimited ...) } => { [$(makeString $delimited) (,) ...] }
}
qw(space separated words) // ["space", "separated", "words"]
@paraboul
paraboul / command line
Created March 14, 2012 16:03
JavaScript + C Preprocessor
/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C < foo.js