Skip to content

Instantly share code, notes, and snippets.

View tangrammer's full-sized avatar
🏠
Working from home

Juan A. Ruz tangrammer

🏠
Working from home
View GitHub Profile
Hhhhhhhh
@tangrammer
tangrammer / p1.css
Created January 11, 2012 23:16
prueba de gist
estilo{
color:red;
}
otro{
}
Jjjj
@tangrammer
tangrammer / ejemplo.clj
Created October 3, 2012 23:37
gist de ejemplo
(def variable 10)
(defn mi_funcion []
"ejemplo de mi funcion"
(println "mi linea"))
@tangrammer
tangrammer / core_node.js
Last active December 10, 2015 02:09
core_node.js it is an utility to load javascript client libs into node code (only methods specified) In this case, the developer wants to use the public/javascript/persons.js lib, that it uses both public/javascript/core.js and public/javascript/i18n (so these others have to been loaded before persons.js)
var fs = require('fs');
exports.load_js_client=function(context, path_lib, method_names, subcontext){
(function(){
if(typeof subcontext !== "undefined"){
for(var v in subcontext){
this[v]=subcontext[v];
console.log(v+"="+this[v]);
}
}
eval(fs.readFileSync(path_lib,'utf8'));
@tangrammer
tangrammer / i18n.js
Last active December 10, 2015 02:09
dispatch table pattern to obtain the localized date printer for one person Note that the returned function expect the date in its closure scope "this.date" It use date_format.js lib to augmenting Date function with format method. Obtained from http://jsfiddle.net/phZr7/1/
/* functions printers outside for better reuse*/
var date_printer={
//US = United States, UK = United Kingdom, AU = Australia
US: function(){return "US: "+this.date.format("mm/dd/yy");},
UK: function(){return "UK: "+this.date.format("dd/mm/yy");},
AU: function(){return "AU: "+this.date.format("dd/mm/yy");}
};
@tangrammer
tangrammer / core.js
Created December 23, 2012 20:22
utility to init object with object with data specification and rubylike getter methods in models (functions constructors)
var init=function (o, spec){
for(value in spec){
if(o[value]==undefined)
o[value]=spec[value];
}
};
var getters=function(f, props){
for(var i=0; i<props.length; i++){
var mi_get=function(x){
@tangrammer
tangrammer / persons.js
Created December 23, 2012 20:59
Prototypal Inheritance implemented in Person and PersonLocalized functions. Use core.js and i18n.js to use "init, getters" and "date_printer, wage_printer" respectively. date_printer and wage_printer are outside PersonLocalized function for better reuse. Both use closure to acces the data values
// this file use ./core.js and ./i18n.js
var data_person_example={
id: 1,
fname: "Juan Antonio",
lname: "Ruz",
DOB: "1976-06-13",
wage: 100,
};
@tangrammer
tangrammer / gist:7039755
Created October 18, 2013 10:42
a clojure core.async proposal solution to this question: "Clojure (script): macros to reason about async operations synchronously" http://stackoverflow.com/questions/11171066/clojure-script-macros-to-reason-about-async-operations-synchronously
(ns fourclojure.stack
(require [clojure.core.async :as async :refer :all]))
(defn update-sidebar! [new-data]
(println "you have updated the sidebar with this data:" new-data))
(defn async-handler [the-channel data-recieved]
(put! the-channel data-recieved)
)
(ns heroku.index
(:require-macros [cljs.core.async.macros :refer [go]])
(:require
[heroku.util :as util]
[ajax.core :refer [GET POST]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[clojure.browser.repl]
[cljs.core.async :refer [put! chan <!]])
)
(ns heroku.index
(:require-macros [cljs.core.async.macros :refer [go]])
(:require
[heroku.util :as util]
[ajax.core :refer [GET POST]]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[clojure.browser.repl]
[cljs.core.async :refer [put! chan <!]])
)