This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scrollTo = function($target) { | |
var $body = $('body,html'); | |
var currentOffset = $(window).scrollTop(); | |
var targetOffset = $target.offset().top; | |
var distance = Math.abs(currentOffset - targetOffset); | |
if (!$target.length) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var $question = $('#question'); | |
var $answer = $('#answer'); | |
var checkInterval = 250; | |
var cheat = function() { | |
var rawVal = $question.html(); | |
rawVal = rawVal.replace(' =', '') | |
.replace('x', '*') | |
.replace('÷', '/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Gpio = require('onoff').Gpio, | |
async = require('async'), | |
_ = require('underscore'); | |
var measureDistance = function(opts) { | |
var options = _.defaults(opts, { | |
trigger: 24, | |
echo: 25, | |
leds: [4, 17, 18, 27, 22, 23], | |
timeout: 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var engine = SearchEngine({ | |
url: 'http://localhost:3333/' | |
}); | |
engine.use(searchbox({ | |
el: '#box', | |
autocomplete: true | |
})); | |
engine.use(results({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyCollection = Backbone.Collection.extend({ | |
reset: function(models, options) { | |
return Backbone.Collection.reset.call(this, models.results, options); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mailer($smtpHost) { | |
return function($from, $to, $subject, $content) use ($smtpHost) { | |
mail(...); | |
}; | |
} | |
$myMailer = mailer('smtp.google.com'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('li', 'ul') | |
.fork( | |
$.branch('.active').show(), | |
$.branch(':not(.active)').hide() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var speak = function(text, cb) { | |
var u = new SpeechSynthesisUtterance(); | |
u.text = text; | |
u.lang = 'de-DE'; | |
u.rate = 1; | |
if (cb) u.onend = cb; | |
speechSynthesis.speak(u); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data { | |
id_1: true, | |
id_2: true, | |
id_3: true | |
}; | |
var lookup = function(dict) { | |
return function(key) { | |
return dict[key]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.sorty = function(fn) { | |
return this.each(function() { | |
var $el = $(this); | |
$el.html($el.children().sort(fn)); | |
}); | |
}; |
OlderNewer