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 / 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;
/*
* Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
/*jslint anon:true, sloppy:true, nomen:true*/
/*global YUI*/
@caridy
caridy / locater.md
Last active December 11, 2015 03:48
Thoughts on YUI Locater

Locater (former ResourceStore in Mojito)

Locater is a filesystem abstraction that is meant to provide access to configurations and resources that describes a YUI App.

The responsibilities of the Locater are:

  • To explore and flatten the structure of a YUI App.
  • To watch and cache meta information to speed up the warm up process for the app.
  • To provide meta information about logical pieces in the application (aka mojits).
  • To provide meta information about specific resorces.
@caridy
caridy / build.sh
Created December 13, 2012 20:55 — forked from isao/build.sh
#!/bin/sh -ex
appname=${1:-hybrid}
bldname=$appname-bld
statdir=yahoo.application.$appname
mojitodir=/Users/caridy/repo/mojito
pwd
mojito create app hybrid $appname
@caridy
caridy / README.md
Created December 10, 2012 22:26
Mojito 0.5.0 preliminar doc on YUI App Group settings

YUI App Group

Starting on Mojito 0.5.0, we introduced a special group called app as part of the loader metadata. This new setting will group all the yui modules defined in mojito core and in the application, and will hold a series of settings and configurations that will define how YUI will deal with those modules when they are needed.

Groups are an important part of the YUI Loader configuration because they allow us to define buckets of files that could be loaded from different mediums and sources. For more details about the group configuration, reference to the YUI Groups config api: http://yuilibrary.com/yui/docs/api/classes/config.html#property_groups

By default, YUI defines 3 groups: default, gallery and yui2. In mojito, we introduce a fourth one, called app, and it defines anything that is part of the application or any of its dependencies, including mojito core modules. As a regular practice, mojito will assume few things about this group, and in many case, you don't need to worry about cust

@caridy
caridy / README.md
Created December 10, 2012 19:45
Mojito 0.5.0 preliminar doc on YUI Seed

Mojito Seed files

In a regular YUI App, the seed file is just the YUI Seed file, and by including it in your pages in a form of a script tag you are ready to use YUI, e.g.:

<script src="http://yui.yahooapis.com/3.7.3/build/yui/yui-min.js"></script>

From that url, the library can infer few things like the version of the library that should be used, the filter that you want to use (min, debug or raw), the CDN that is serving the library, etc. But when it comes to a mojito application, things are a little bit different, since the YUI library is bundle with the application using npm, and the way your application runs might also disrupt from a regular web application when it comes to mobile. On top of that, the introduction of a lot of new YUI modules, part of the mojito code, and part of the app code that should work in the same way that YUI Core modules work through the loader, all that makes it difficult to use the standard way for the seed in a mojito application.

@caridy
caridy / base-benchmark.js
Created December 10, 2012 19:24
Benchmark and Benchtable in Mojito
YUI.add('base-benchmark', function (Y) {
var suite = Y.BenchmarkSuite;
var MyBase20 = function() {
MyBase20.superclass.constructor.apply(this, arguments);
};
Y.extend(MyBase20, Y.Base);
@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 / results.txt
Created November 21, 2012 17:03
Compare set to null vs delete member in NodeJS
NodeJS 0.8.x on MBP:
$ node delete.js
89300 'value to null'
3100674 'deleting member'
@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();