Skip to content

Instantly share code, notes, and snippets.

Carlos Lalimarmo clalimarmo

Block or report user

Report or block clalimarmo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@clalimarmo
clalimarmo / falcor-subscribable-model.js
Created Mar 1, 2016
subscribable wrapper for falcor models, for reactive components
View falcor-subscribable-model.js
const falcor = require('falcor');
const Rx = require('rxjs');
//FalcorSubscribableModel
module.exports = function(modelOptions) {
modelOptions = modelOptions || {};
const self = {};
const modelSubject = new Rx.BehaviorSubject();
@clalimarmo
clalimarmo / design_spec.js
Created Nov 21, 2015
Gulp tasks for building a design spec static site
View design_spec.js
var gulp = require('gulp');
var webserver = require('gulp-webserver');
var fileInclude = require('gulp-file-include');
/*
* Design spec build tasks:
*
* Compile and serve a design spec (style guide) site.
*/
gulp.task('dspec', ['dspec:watch'], function() {
@clalimarmo
clalimarmo / collection_json_cache.js
Last active Nov 5, 2015
Collection+JSON in-memory caching
View collection_json_cache.js
const Cache = function(deps) {
const self = {};
const requested = {};
self.fetch = function(href) {
requested[href] = requested[href] || new Promise((resolve, reject) => {
const collection = deps.Collection();
collection.fetch(href).done(() => {
resolve(collection);
});
View filters.js
var appliedFilters = {};
function anyFilterApplied() {
return Object.keys(appliedFilters).length > 0;
}
function applyFilter(filter, key) {
appliedFilters[key] = filter;
}
View coherence async.js
const BookStore = function(deps) {
const self = Coherence(deps);
self.handleAction('search-book', searchBook);
return self.fluxSafe();
function searchBook(payload) {
deps.books.fetch(payload.id).then(function(response) {
self.setData('book', response);
})
}
@clalimarmo
clalimarmo / extension-patterns.js
Last active Oct 2, 2015
How things are done everywhere. Versus how I want them to be done.
View extension-patterns.js
// tired of this extension pattern
var Cow = AnimalFactory({
getVoice: function() { return 'moo'; }),
numLegs: 4,
name: 'Cow',
})
// propose this one instead
var MutantCow = AnimalFactory.extend()
.getVoice(function() { return 'moo'; })
@clalimarmo
clalimarmo / app_init.js
Created Sep 15, 2015
Deep Linking with React + Flux, dispatching an action for app initialization on page load
View app_init.js
// example app initialization
$(function() {
Dispatcher.dispatch({
type: 'initialize app',
path: window.location.pathname,
});
});
@clalimarmo
clalimarmo / app_link.jsx
Last active Sep 21, 2015
Deep Linking with React + Flux, AppLink component, updated to support browser "back"
View app_link.jsx
@clalimarmo
clalimarmo / url_store.js
Last active Sep 21, 2015
Deep Linking with React + Flux, URL Store, with support for browser "back"
View url_store.js
(function() {
Dispather.register(function(action) {
if (action.type !== 'navigate') {
return;
}
// sometimes we don't want to create history entries (see below)
if (action.pushState) {
window.history.pushState(
{path: action.path},
'',
You can’t perform that action at this time.