Skip to content

Instantly share code, notes, and snippets.

// Dein fehler: '[AnyObject]?' is not a subtype of 'Void'
// dismissViewControllerAnimated will eine Closure mit der Typ-Signatur () -> Void.
// Wenn die Closure nur aus einer Expression besteht, wie hier der Aufruf von popToViewController
// dann wird der Return Value dieser Expression automagisch als Return der Closure angenommen.
// popToViewController gibt [AnyObject]? zurück. Das ist nicht Void.
// Wie fixen? So sollte es gehen.
dismissViewControllerAnimated(true, completion: {
import UIKit
extension String {
func NSRangeOfString(string: String) -> NSRange? {
if let range = self.rangeOfString(string) {
let loc = distance(self.startIndex, range.startIndex)
let length = distance(range.startIndex, range.endIndex)
return NSMakeRange(loc, length)
function buildTemplate (spec, template) {
return function (context) {
var allParamsExist = spec.every(function (key) {
return context.hasOwnProperty(key) && (context[key] !== undefined)
})
if (!allParamsExist) {
throw "Context object misses needed parameters"
}
@ttepasse
ttepasse / dabblet.css
Created January 5, 2013 15:30
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
p { margin-top: 5em; }
input[type=submit] {
/* Ich hab das Gefühl, das hier ist mehr Vodoo:
-webkit-appearance: none;
@ttepasse
ttepasse / dabblet.css
Created January 3, 2013 03:35
Rövarspråket
/**
* Rövarspråket
*/
html {
background: linear-gradient(0deg, khaki, green);
min-height: 100%;
}
table {
function MyArray () { console.log("bla"); }
MyArray.prototype = Object.create(Array.prototype)
var x = new MyArray()
x.push("lala")
x.push("lolo")
x.indexOf("lolo") // -> 1
x instanceof Array // -> true
define [
"helper/HostApp"
"controller/Timeline"
],
(HostApp, Timeline) ->
class Mentions extends Timeline
constructor: ->
@initialized = yes
Factory.prototype.create = function (konstruktor /*, args */) {
// Objekt mit dem NC erstellen
var instanz = Object.create(konstruktor.prototype, {
notificationCenter : {
value : this.notificationCenter;
}
});
// Das Objekt noch mal initalisieren
Function.prototype.and = function () {
var predicates = Array.prototype.slice.call(arguments);
predicates.unshift(this);
return (function (value) {
return predicates.every(function (predicate) {
return predicate(value);
})
});
}
// A weird mixture between functional and imperative.
// I like putting some lambdas into their own functions, for some
// degree of self-documenting and readability later on.
// ...
var nodes, fontnames, firstpick,
result = false;
function isEditableTextnode(node) {