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
@domenic
domenic / .bashrc
Last active September 1, 2015 17:50
.bashrc with GitHub PR function
pr () {
git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 --force
git checkout -b pr/$1 origin/pr/$1
git rebase master
git checkout master
git merge pr/$1 --ff-only
}
@ericf
ericf / gist:6133744
Last active December 20, 2015 12:49

Proposal for Extending Express Apps

Creating npm packages which extend the functionality of Express apps has become a major thing we've been doing. There are several approaches we can take, from messing with the Express object prototypes, to creating a function in which an express app is passed in. After trying the former, I'm now a fan of the latter.

The Issues with Extending Express

Extending the Express object prototypes has issues. The running Node.js process may have multiple versions of express, and in order to extend the prototypes you need to require('express'). This means that you might get a different express module instance than the one the main app is created from.

Both approaches suffer from extending something more than once. Similar to how there may be multiple version of express in the running Node.js process, there can also be multiple copies of the extension modules. If the app developer needs to rely on a different version of an Express ext

@caridy
caridy / README.md
Last active December 20, 2015 07:19
express-routes-notes

What is this?

This is a prototype for the low-level api to serialize express routes into the client side.

Installation

npm install
node simple.js
node complex.js
@caridy
caridy / README.md
Last active December 19, 2015 18:48

What is this?

This is a script that you can add to your application to generating yui meta data and compiling yui modules using express-yui and locator. As a result, a build folder will be generated with everything that was compiled.

How does this work?

Locator walks the folder structure for your app, and finds any yui module, including build.json or just traditional *.js files with the corresponding YUI.add() statement. Generating the result of the operation as well as the metadata associated to each module.

Under the hood, it uses shifter to generate almost everything that is needed.

@akshar100
akshar100 / gist:5712149
Created June 5, 2013 07:17
Mojito Session Management Addon. Note: This addon is not tested. It is vulnerable to session hijacking.
YUI.add('mojito-session-addon', function(Y, NAME) {
function MojitoSession(command, adapter, ac) {
// The "command" is the Mojito internal details
// for the dispatch of the mojit instance.
// The "adapter" is the output adapter, containing
// the "done()", "error()", etc, methods.
// The "ac" is the ActionContext object to which
// this addon is about to be attached.
var sessionCookie = ac.cookie.get("sid");
if(!sessionCookie){
@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)
@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.

@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
@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.
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