Skip to content

Instantly share code, notes, and snippets.

@florian
florian / usage.rb
Created September 1, 2012 17:39
String#word_wrap for Ruby
text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam"
puts text.word_wrap(40)
# Lorem ipsum dolor sit amet, consetetur
# sadipscing elitr, sed diam nonumy eirmod
# tempor invidunt ut labore et dolore
# magna aliquyam
@florian
florian / README.md
Created April 23, 2012 18:48
getting the type or constructor of a value

Usage

Getting the data type or constructor:

type("some string"); // 'string'
type(42); // 'number'
type(true); // 'boolean

Checking for a data type or constructor:

@florian
florian / chainable_canvas.js
Created April 7, 2012 13:23
A small script that makes it possible to chain the HTML5 canvas methods. Pretty much a smaller version of chainvas: http://leaverou.github.com/chainvas/
(function(){
var c = window.CanvasRenderingContext2D.prototype,
wrapFn = function (method) {
return function () {
var ret = method.apply(this, arguments);
return ret === undefined ? this : method;
};
};