Skip to content

Instantly share code, notes, and snippets.

@SirPepe
SirPepe / CanvasQuery.js
Created August 2, 2010 19:06
Micro canvas framework
// Init boilerplate
function CanvasQuery(c){
"use strict";
if(!(this instanceof CanvasQuery)) return new CanvasQuery(c);
if(typeof c == "string"){
var canvas = document.getElementById(c);
if(!canvas) throw new Error("Canvas element #" + c + " doesn't exist");
}
if(typeof canvas == "undefined"){
if(c.getContext) canvas = c;
/* Source: http://nicolasgallagher.com/micro-clearfix-hack/ */
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
}
.cf:after {
@SirPepe
SirPepe / curry.js
Created July 14, 2011 21:23
JavaScript Curry
Function.prototype.curry = function(){
if(arguments.length < 1) return this;
var args = Array.prototype.slice.call(arguments),
method = this;
return function(){
return method.apply(this, args.concat(Array.prototype.slice.call(arguments)));
}
}
<component lightWeight="true">
<attach event="onpropertychange" onevent="checkPropertyChange()" />
<attach event="ondetach" onevent="restore()" />
<attach event="onresize" for="window" onevent="restore();init()" />
<script type="text/javascript">
//<![CDATA[
var viewportwidth = (typeof window.innerWidth != 'undefined' ? window.innerWidth : element.document.documentElement.clientWidth);
// Shortcut for the document object
var doc = element.document;
@SirPepe
SirPepe / gist:1307124
Created October 23, 2011 08:54
Fortschritt rockt, CSS3 rockt, Stylus rockt
// Kommentare
#KommentareListe
list-style none
counter-reset kommentare
&:not(:empty)
border-bottom 1px dotted $border
.comment
clear both
border-top 1px dotted $border
&:first-child
var stylus = require('stylus'),
connect = require('connect'),
nib = require('nib');
var basepath = '/..';
var compile = function(str, path){
return stylus(str)
.set('filename', path)
.set('warn', true)
@SirPepe
SirPepe / findpos.js
Created November 30, 2011 11:20
FindePos
// Quelle: http://www.quirksmode.org/js/findpos.html
function findPos(obj){
var curleft = 0, curtop = 0;
if(obj.offsetParent){
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while(obj = obj.offsetParent);
}
return [curleft, curtop];
@SirPepe
SirPepe / .bashrc
Created January 20, 2012 14:41
Git-Branch im Terminal anzeigen
# Git-Branch im Terminal anzeigen und den Lambda-Hacker raushängen lassen
underline=`tput smul`
nounderline=`tput rmul`
bold=`tput bold`
normal=`tput sgr0`
GIT_PS1_SHOWDIRTYSTATE=1
PS1='${bold}λ ${normal}\w$(__git_ps1 " [${underline}%s${nounderline}]") \$ '
irc = require 'irc'
http = require 'http'
# Client erstellen
bot_name = 'Hixie'
bot_channels = ['#webhonks']
bot = new irc.Client 'irc.freenode.net', bot_name, {
userName: 'hixie'
realName: 'Ein Bot in CoffeeScript',
@SirPepe
SirPepe / dabblet.css
Created March 1, 2012 11:17 — forked from michsch/dabblet.css
flexible fluid <figure> and <figcaption>
/**
* flexible fluid <figure> and <figcaption>
*/
html * { font-size:100%; }
body {
background: #efefef;
min-height:100%;
font-size: 85%;