Skip to content

Instantly share code, notes, and snippets.

@jrmoran
jrmoran / rakefile.rb
Created December 4, 2012 03:18
Sprockets 2.8.1 Precompile CoffeeScript for non rack apps
namespace :js do
require 'sprockets'
environment = Sprockets::Environment.new(File.dirname(__FILE__))
environment.append_path 'src/bower'
environment.append_path 'src/coffee'
source_code = environment['app.coffee']
desc 'compile CoffeeScript with Sprockets'
task :compile do
@jrmoran
jrmoran / many-directives.haml
Created November 30, 2012 01:43
AngularJS - precompiled Haml
%ng-form(name="circleEditForm")
%label Circle Name:
%input(type="text" name="circleName" |
ng-minlength= 3 |
ng-model="circleModal.name" |
ng-maxlength= 8 |
maxlength= 8 |
required |
ng-class="{error: !circleEditForm.circleName.$valid}" )
@jrmoran
jrmoran / controllers.coffee
Created November 28, 2012 18:43
AngularJS Testing Controllers with Testacular & Testem
# = require '../components/jquery/jquery'
# = require '../components/angular-complete/angular'
Controllers = angular.module 'controllers', []
Controllers.controller 'PhoneListCtrl', ['$scope', ($scope)->
$scope.phones = [
{name: "Nexus S", snippet: "Fast just got faster with Nexus S."},
@jrmoran
jrmoran / test.js
Created November 16, 2012 07:00
test
var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
console.log(evens);
@jrmoran
jrmoran / app.js
Created October 27, 2012 21:58
AngularJS - Charting with Flot
var App = angular.module('App', []);
@jrmoran
jrmoran / app.js
Created October 23, 2012 12:50
AngularJS - basic async request
var App = angular.module('App', []);
App.controller('TodoCtrl', function($scope, $http) {
$http.get('todos.json')
.then(function(res){
$scope.todos = res.data;
});
});
var appendStyle = function(){
var htmlstr = '<link rel="stylesheet" '+
'href="https://gist.github.com/stylesheets/gist/embed.css" '+
'type="text/css" />';
$('head').append( htmlstr );
}
/*
look for tags [gist]#######[/gist] and for each one found, insert a
div with an id attribute that references the gist's id
@jrmoran
jrmoran / google-column-chart.js
Created March 7, 2012 03:57
playing with google charts
function drawVisualization() {
var col1 = ["AP","AP-PAN","ARENA","CD","CD-PNL","CDU","CDU-FMLN","CDU-PSD","FC","FDR","FDR-CD","FDR-PDC","FDR-PDC-CD","FMLN","FMLN-CD","FMLN-PDC","FMLN-PSD","PAN","PCN","PDC","PDC-FMLN","PDC-FMLN-CD","PDC-PMR-PSD","PDC-PSD","PMR","PMR-PDC","PMR-PDC-PSD-CDU","PMR-PSD","PMR-PSD-CDU","PNL","PPR","PSD"];
var col2 = ["AP","AP-PAN","ARENA","CD","CD-PNL","CDU","CDU-FMLN","CDU-PSD","FC","FDR","FDR-CD","FDR-PDC","FDR-PDC-CD","FMLN","FMLN-CD","FMLN-PDC","FMLN-PSD","PAN","PCN","PDC","PDC-FMLN","PDC-FMLN-CD","PDC-PMR-PSD","PDC-PSD","PMR","PMR-PDC","PMR-PDC-PSD-CDU","PMR-PSD","PMR-PSD-CDU","PNL","PPR","PSD"];
var table1 = [["2003",11990,374,491452,0,0,37629,84995,123,10208,0,0,0,0,471042,0,19739,259,11416,210056,104494,0,0,13105,592,26447,4101,2493,3104,374,0,20419,7773],["2006",0,0,791811,30778,24101,0,0,0,0,0,0,0,0,670711,106314,0,0,0,307330,173982,12192,0,0,0,0,0,0,0,0,2637,0,0],["2009",0,0,867273,25204,0,0,0,0,0,20962,6450,5020,1689,886161,237119,0,0,0,235989,185844,8755,7811,0,
@jrmoran
jrmoran / codificacion.txt
Created February 15, 2012 00:11
Codificación SVMap
m0101 Ahuachapán
m0102 Apaneca
m0103 Atiquizaya
m0104 Concepción de Ataco
m0105 El Refugio
m0106 Guaymango
m0107 Jujutla
m0108 San Francisco Menéndez
m0109 San Lorenzo
m0110 San Pedro Puxtla
@jrmoran
jrmoran / fibonacci-50.clj
Created February 7, 2012 18:14
Fibonacci Sequence
(defn fib [n]
(Math/round (/ (- (Math/pow 1.618034 n)
(Math/pow (- 0.618034) n))
(Math/sqrt 5))))
(map fib (range 51))
;; (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524579 5702888 9227467 14930356 24157823 39088179 63246003 102334183 165580188 267914374 433494567 701408948 1134903525 1836312490 2971216044 4807528580 7778744699 12586273401)