Skip to content

Instantly share code, notes, and snippets.

/*
* 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 = '';
/**********************************************/
/*
/* IR_Dark_Monokai
/* Designed and developed by Andres Pagella (@mapagella)
/* http://www.andrespagella.com/customising-chrome-devtools
/*
/* Based on Ben Truyman's IR_Black
/* which is...
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
@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 {
@jrmoran
jrmoran / app.js
Created December 20, 2012 07:17
AngularJS Event delegation in a repeater. SO 13965627
var app = angular.module('app', []);
app.controller('ctrl', function($scope){
$scope.ss = [
{name:'test1'},
{name:'test2'},
{name:'test3'},
{name:'test4'},
{name:'test5'}
];
@jrmoran
jrmoran / app.js
Created December 17, 2012 00:30
AngularJS. Run a function from a directive's controller when ngRepeat is done evaluating an expression
var app = angular.module('app', []);
app.controller('ctrl', function($scope){
$scope.images = [ {name: 'test1'}, {name: 'test2'},
{name: 'test3'}, {name: 'test4'}];
});
app.directive('gallery',function() {
return {
restrict : 'C',
@jrmoran
jrmoran / app.js
Created December 15, 2012 04:07
AngularJS filtering object and modules. view here http://jsbin.com/acagag/4/edit. (SO 13887504)
angular.module('utils', [])
.factory('utils', function(){
return{
compareStr: function(stra, strb){
stra = ("" + stra).toLowerCase();
strb = ("" + strb).toLowerCase();
return stra.indexOf(strb) !== -1;
}
};
});
@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 / 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', {
@jrmoran
jrmoran / interceptor.js
Created December 11, 2012 07:06
AngularJS intercept responses - array of strings to array of objects
app.config( function( $httpProvider ) {
var interceptor = function( $q ) {
return function( promise ) {
var success = function(res) {
if(res.data && res.data[0]){
if(typeof res.data[0] === 'string'){
var data = res.data,
ret = [];
@jrmoran
jrmoran / grunt.js
Created December 6, 2012 17:35
Basic Grunt concat and minification set up
module.exports = function(grunt) {
grunt.initConfig({
concat: {
js: {
src: 'src/js/*.js',
dest: 'dest/js/concat.js'
},
css: {
src: 'src/css/*.css',