Skip to content

Instantly share code, notes, and snippets.

View ferlores's full-sized avatar

Fernando Lores ferlores

  • Facebook
  • San Francisco, California
View GitHub Profile
@ferlores
ferlores / LRU.js
Created November 2, 2012 17:47
PoC LRU cache
(function (exports) {
var keys = Object.keys || function(o) {
var result = [];
for(var name in o) {
if (o.hasOwnProperty(name))
result.push(name);
}
return result;
};
@ferlores
ferlores / ajaxCache.js
Created August 15, 2012 03:47
Overwrite jQuery ajax to cache repeated calls
var ajaxCache = {};
var oldAjax = $.ajax;
$.ajax = function(opts){
if (opts.type !== "GET") {
return oldAjax(opts);
}
if (ajaxCache[opts.url]) {
console.log('cached')
$.each(['success', 'error', 'complete'], function (index, method) {
@ferlores
ferlores / map.html
Created August 15, 2012 01:12
CartoDB example
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=drawing" type="text/javascript"></script>
<style type="text/css">
#map {
height: 100%;
}
h2 {
margin: 0px;
}
@ferlores
ferlores / loadpng.js
Created July 21, 2012 23:54
Example using new Buffer.concat
var http = require('http');
var request = http.request({method: 'get', host: 'images.google.com', port: 80, path: '/intl/en_ALL/images/logos/images_logo_lg.gif'}, function(response) {
var data = [];
response.on('data', function(chunk) {
data.push(chunk);
});
response.on('end', function() {
@ferlores
ferlores / git-flow-how-to.md
Created July 2, 2012 19:14
Git flow how to
@ferlores
ferlores / gist:2495657
Created April 26, 2012 03:50
Presenter API
/*
* Interface for a isomorphic Presenter
*/
//NODE enviroment - Director can make something similar
module.exports = Presenter.extend({
'name': 'posts',
'/posts get': function(){},
'/posts post': function(){},
'/posts put': function(){},