Skip to content

Instantly share code, notes, and snippets.

View caridy's full-sized avatar

Caridy Patiño caridy

  • Salesforce, Inc.
  • Miami, FL.
  • X @caridy
View GitHub Profile
@caridy
caridy / perf.js
Created November 20, 2012 23:07
Perf optimization for function hooks in Node.JS
var microtime = require('microtime'),
i,
t,
obj,
max = 10000000;
function run1(obj) {
t = microtime.now();
for (i = 0; i < max; i += 1) {
if (obj.foo) obj.foo();
@caridy
caridy / modified.js
Created December 5, 2012 02:06
headers modified tests for static handling
function modified(req, headers) {
var modifiedSince = req.headers['if-modified-since'],
lastModified = headers['Last-Modified'],
noneMatch = req.headers['if-none-match'],
etag = headers.ETag,
etagModified = true,
dateModified = true;
// Check If-None-Match
if (noneMatch && etag && noneMatch === etag) {
etagModified = false;
@caridy
caridy / deep-merge.js
Created January 22, 2013 18:08
Experimenting with deep merge leveraging prototypal inheritance instead of pure JSON objects for YCB
function heir (o) {
function F() {}
F.prototype = o;
return new F();
}
function heirDeep (o) {
var dest,
i;
@caridy
caridy / benchmark-and-benchtable-abstraction.js
Last active December 11, 2015 18:38
Boilerplate to write benchmarks and benchtables in NodeJS.
/*jslint node:true, nomen:true, stupid: true */
'use strict';
var Benchmark = require('benchmark').Benchmark,
Benchtable = require('benchtable');
function getSuite(testName) {
var suite;
// enabling benchmark suite
@davglass
davglass / Features.md
Created February 1, 2013 15:21
Proposal for new YUI.Features

New YUI Feature Detection

This is my proposal for revamping the YUI Core Feature detection system.

Problem Space

  • 90% of our so-called "Feature Tests" are actually Loader conditional modules.
  • Some "free-flowing" tests in DOM modules.
Y.Model: Instantiate a bare model
┌──────────┬────────────────────────────┬─────────────────────────────┐
│ │ Firefox │ Chrome │
├──────────┼────────────────────────────┼─────────────────────────────┤
│ v3.8.0 │ 3971.37 ±2.80% (-87%) │ 11258.29 ±4.26% (-163%) │
│ v3.9.0 │ 3596.12 ±5.37% (-107%) │ 11661.04 ±3.15% (-154%) │
│ WIP │ 7444.50 ±3.80% (Fastest) │ 29661.83 ±3.30% (Fastest) │
└──────────┴────────────────────────────┴─────────────────────────────┘
Y.Model: Subclass and instantiate a bare model
@juandopazo
juandopazo / gist:5405383
Last active December 16, 2015 08:19
Storage module design and API for review

Storage

Motivation

There are 3 major types of storage is browsers up to date:

  • IndexedDB. The future.
  • localStorage. Limited in size and can be observed through the storage event.
  • WebSQL. Dropped by the W3C but it's still very present in the wild, with notable platforms like iOS and PhoneGap.
@isao
isao / rel.sh
Last active December 17, 2015 03:39
yet another git/npm release script
#!/bin/sh -e
# https://gist.github.com/isao/5544779
# default source branch containing the release commits
srcdefault=develop
# the branch all releases are landed on, tagged on, and published from
relbranch=master
# 1st arg is the release number, i.e. 0.1.2
@caridy
caridy / template-registration.md
Last active December 17, 2015 04:08
Template registration process in YUI

This gist was updated based on the discussion here : https://groups.google.com/forum/?fromgroups=#!topic/yui-contrib/cUpVvtoUBa8

Template Registration

With the ability to precompile templates into javascript and the abtraction layer provided by Y.Template to normalize the api to render those templates, we got one step closer to create applications that can be template language agnostic.

The premise here is to create a YUI Application that references templates by name and call for render when needed without having to know what engine to use, or what file generated the compiled template, or what api should be used for a particular template.

In order to facilitate this, we should have a centralized registration mechanism used by the application to register any template that is provisioned, in which case we can decouple the provisioning process from the actual rendering process.

@mihs
mihs / gist:5663080
Last active December 17, 2015 19:49
Working around implicit router in express 3.x ( https://github.com/visionmedia/express/issues/1404 ). Do this after you have loaded your middleware and set up your routes.
# router was automatically added, remove it and add it again at the end
for index, middleware of app.stack
if middleware.handle == app.router
routerAt = index
break
if routerAt
app.stack.splice(routerAt, 1)
app.use(app.router)