A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
// I mean, seriously, localStorage is supported even by your mum. How about instead of | |
// casing the feature out, you give users in-memory (stale) storage instead? | |
// If they close your application, they deserve to lose data anyway. | |
// if (!('localStorage' in window)) { | |
if (!Modernizr.localstorage) { | |
window.localStorage = { | |
_data : {}, | |
setItem : function(id, val) { return this._data[id] = String(val); }, | |
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; }, |
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561 | |
/* | |
* How to delete items from an Array in JavaScript, an exhaustive guide | |
*/ | |
// DON'T use the delete operator, it leaves a hole in the array: | |
var arr = [4, 5, 6]; | |
delete arr[1]; // arr now: [4, undefined, 6] |
/** | |
* | |
* MOVED TO: https://github.com/iFind/html5MultidimensionalStorage | |
* | |
* This methods extends the default HTML5 Storage object and add support | |
* to set and get multidimensional data | |
* | |
* @example Storage.setObj('users.albums.sexPistols',"blah"); | |
* @example Storage.setObj('users.albums.sexPistols',{ sid : "My Way", nancy : "Bitch" }); | |
* @example Storage.setObj('users.albums.sexPistols.sid',"Other songs"); |
@include keyframe(fadeout) { | |
0% { | |
opacity: 1; | |
} | |
100% { | |
opacity: 0; | |
} | |
} |
/* | |
Based on Rick Strahl code | |
http://www.west-wind.com/weblog/posts/2008/Mar/18/A-simple-formatDate-function-for-JavaScript | |
Contributors: | |
Clauber Stipkovic - @clauberhalic | |
Mário Rinaldi - @MarioRinaldi | |
*/ | |
Date.prototype.formatDate = function (format) { |
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast) | |
(function poll(){ | |
$.ajax({ url: "server", success: function(data){ | |
//Update your dashboard gauge | |
salesGauge.setValue(data.value); | |
}, dataType: "json", complete: poll, timeout: 30000 }); | |
})(); |
curl -w '\nLookup:\t%{time_namelookup}\nConnect :\t%{time_connect}\nPreTrans:\t%{time_pretransfer}\nStartTeans:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null -s http://yourdomain.com |
/* | |
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp | |
server, but for some reason omit a client connecting to it. I added an | |
example at the bottom. | |
Save the following server in example.js: | |
*/ | |
var net = require('net'); |
module.exports = function(options) { | |
var el | |
, a | |
, i | |
if (!options.tagName) { | |
el = document.createDocumentFragment() | |
} | |
else { | |
el = document.createElement(options.tagName) | |
if (options.className) { |