Skip to content

Instantly share code, notes, and snippets.

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 / 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 / app.js
Created October 27, 2012 21:58
AngularJS - Charting with Flot
var App = angular.module('App', []);
@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 / 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 / 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 / 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 / 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',
@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 / 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', {