Skip to content

Instantly share code, notes, and snippets.

function im_stoned(data, callback) {
data = data+1;
callback.call({"data": data});
}
im_stoned(4, function() {
alert(this.data);
});
Slideshow = function () {
var _public = {
init : function () {
images = $('div.slideshow ul li a');
State.curimage = $(images[0]).attr('href');
$('div.slideshow ul li a').click(Events.click);
if ( images.length > 1 ) {
cycle(1);
}
<div class="slideshow">
<div class="viewer-1" style="display: block;"><img src="/sites/Acumen/uploads/rad3-large_2.jpg"></div>
<div class="viewer-0"><img src="/sites/Acumen/uploads/rad2-large_3.jpg"></div>
<ul>
<li class="first">
<a href="/sites/Acumen/uploads/rad1-large_2.jpg">
<img src="/sites/Acumen/uploads/tn_rad1-large_2.jpg">
</a>
</li>
<li>
var timer;
var sections = [] // array of sections, could just be a jQuery selector
var i = 0;
var cycle = function (sections, i) {
if (i < sections.length) {
timer = setTimeout(function () {
//animate section
cycle(i+=1, sections)
}, 3000)
} else { // start again
html {
overflow: auto;
}
body {
position: absolute;
top: 0;
left: 0;
bottom: 0;
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn('number', 'Expenses');
data.addRows(11);
data.setValue(0, 0, '0');
data.setValue(0, 1, 1000);
data.setValue(0, 2, 400);
MBP:nodetest ollie$ node --version
0.1.94
MBP:nodetest ollie$ node app.js
Error: Uncaught, unspecified 'error' event.
at Object.emit (events:13:15)
at Object.get (/Users/ollie/Code/nodetest/lib/mongoose/lib/model/index.js:195:53)
at Object.get (/Users/ollie/Code/nodetest/lib/mongoose/mongoose.js:107:29)
at Object.static (/Users/ollie/Code/nodetest/lib/mongoose/lib/storage.js:81:32)
at Object.<anonymous> (/Users/ollie/Code/nodetest/models/imageprovider.js:6:13)
at Module._compile (module:385:23)
@BBB
BBB / slugify.js
Created May 31, 2011 14:56
Will convert any string into safe slug. (Replaces any invalid characters with hypens, removes 1+ hypens & removes hyphens from the start & end of string)
String.prototype.slugify = function () {
return this.replace(/\s/g,'-').replace(/[^a-zA-Z0-9\-]/g,'').replace(/[\-]+/g,'-').replace(/\-$/,'').replace(/^\-/,'').toLowerCase();
}
import sublime, sublime_plugin, subprocess, os
class CompileLessOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
if not view.file_name().endswith('.less'):
return
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
@BBB
BBB / fonts.less
Created September 20, 2011 10:49
Less font example
#font {
@helvetica-stack: "Helvetica Neue", Arial, sans-serif;
@helvetica-heavy-stack: @helvetica-stack;
@helvetica-light-stack: "HelveticaNeueW01-Thin", @helvetica-stack;
@helvetica-italic-stack: "HelveticaNeue-Italic", @helvetica-stack;
// sizes
@base-font-size: 14px;
.big() {
font-size: 4 * @base-font-size;