Skip to content

Instantly share code, notes, and snippets.


Ricardo Torres rictorres

View GitHub Profile
View storageProxy.js
// helper function to persist the
// changes to localStorage and
function storageProxy(key, updateFn){
var store = window.localStorage;
// udpate if the key is already set
var initial = store.getItem(key);
if(initial) updateFn(initial)
// listen for updates from other windows
View test.js
* Modify the parts you need to get it working.
var should = require('should');
var request = require('../node_modules/request');
var io = require('');
var serverUrl = 'http://localhost';
View jquery-ajax-blob-arraybuffer.js
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
* ajax transport, preventing the standard transport from hogging the request), and the * indicates that
* potentially any request with any dataType might want to use the transports provided herein.
* Remember to specify 'processData:false' in the ajax options when attempting to send a blob or arraybuffer -
rictorres / gist:500704cec75756afaedc
Last active Aug 29, 2015 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
View gist:500704cec75756afaedc
// This is from my comment here:
* 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]
View nginx.conf
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is also explained at the Nginx ngx_http_fastcgi_module page document page.

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (it's not shared).

The related Nginx options are:


Setting up a SSL Cert from Comodo

I use as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
View webp-detect.js
function testWepP(callback) {
var webP = new Image();
webP.src = 'data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMw' +
webP.onload = webP.onerror = function () {
callback(webP.height === 2);
testWebP(function(supported) {

Keybase proof

I hereby claim:

  • I am rictorres on github.
  • I am rictorres ( on keybase.
  • I have a public key whose fingerprint is 353B A4A8 924A 2B4C A650 06B5 9684 8B0B FFC7 C82D

To claim this, I am signing this object: