Skip to content

Instantly share code, notes, and snippets.

@jrmoran
jrmoran / isDui.js
Created October 28, 2011 00:48
Verificacion DUI
/*
DUI = 00016297-5
Posiciones -> 9 8 7 6 5 4 3 2
DUI -> 0 0 0 1 6 2 9 7
DV = 5
sum: (9*0) + (8*0) + (7*0) + (6*1) + (5*6) + (4*2) + (3*9) + (2*7) = 85
residuo: (85 % 10) = 5
resta: 10 - residuo = 5
@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;
});
});
@jrmoran
jrmoran / public-app.js
Created December 13, 2012 15:12
AngularJS and Express, rendering ejs-locals partials
var app = angular.module('app', ['ngResource']);
app.config(function($locationProvider, $routeProvider) {
// $locationProvider.html5Mode(true);
$routeProvider
.when('/', { templateUrl: 'partials/index', controller: 'ctrl' })
.when('/about', { templateUrl: 'partials/about', controller: 'ctrl' })
.otherwise({redirectTo:'/'});
});
@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)
@jrmoran
jrmoran / app.js
Created October 27, 2012 21:58
AngularJS - Charting with Flot
var App = angular.module('App', []);
@jrmoran
jrmoran / loader.js
Created January 14, 2012 04:55
dynamic script loader
var myLoader = function(filename, fun) {
var head = document.getElementsByTagName('head')[0],
script = document.createElement('script');
script.type = 'text/javascript';
script.src = filename;
if(typeof fun === 'function'){ script.onload = fun; }
head.appendChild(script);
};
@jrmoran
jrmoran / Cakefile
Created December 30, 2011 01:44
Cakefile to document, compile, join and minify CoffeeScript files for client side apps.
# Cakefile to document, compile, join and minify CoffeeScript files for
# client side apps. Just edit the config object literal.
#
# -jrmoran
fs = require 'fs'
{exec, spawn} = require 'child_process'
# order of files in `inFiles` is important
config =
@jrmoran
jrmoran / app.js
Created December 12, 2012 05:56
Angular.JS Routes HTML5Mode
var app = angular.module('app', []);
app.config(function($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: '/partials/template1.html', // <- relative to base
controller: 'ctrl1'
})
.when('/tags/:tagId', {
/*
* Write a program that prints out the numbers 1 to 100 (inclusive).
* If the number is divisible by 3, print Crackle instead of the number.
* If it's divisible by 5, print Pop. If it's divisible by both 3 and 5,
* print CracklePop
*
* Jaime Moran
*/
var cracklePop = function(i){
var r = '';
@jrmoran
jrmoran / d3-circles-at-an-angle.js
Created November 15, 2013 18:52
Circles at an angle with d3.js
var v = d3.select('#viz')
.append("svg")
.attr("width", 1170)
.attr("height", 700 );
var getPointAtAngle = function(center, radius, theta){
console.log(r);
theta = 90 + theta;
return {