Skip to content

Instantly share code, notes, and snippets.

View cracklePop.js
/*
* 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 = '';
View Custom.css
/**********************************************/
/*
/* 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 Nov 15, 2013
Circles at an angle with d3.js
View d3-circles-at-an-angle.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 Dec 20, 2012
AngularJS Event delegation in a repeater. SO 13965627
View app.js
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 Dec 17, 2012
AngularJS. Run a function from a directive's controller when ngRepeat is done evaluating an expression
View app.js
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 Dec 15, 2012
AngularJS filtering object and modules. view here http://jsbin.com/acagag/4/edit. (SO 13887504)
View app.js
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 Dec 13, 2012
AngularJS and Express, rendering ejs-locals partials
View public-app.js
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 Dec 12, 2012
Angular.JS Routes HTML5Mode
View app.js
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 Dec 11, 2012
AngularJS intercept responses - array of strings to array of objects
View interceptor.js
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 Dec 6, 2012
Basic Grunt concat and minification set up
View grunt.js
module.exports = function(grunt) {
grunt.initConfig({
concat: {
js: {
src: 'src/js/*.js',
dest: 'dest/js/concat.js'
},
css: {
src: 'src/css/*.css',