Skip to content

Instantly share code, notes, and snippets.

View leon's full-sized avatar

Leon Radley leon

View GitHub Profile
@leon
leon / Gruntfile.js
Created November 8, 2013 15:09
Grunt.js install bower components and force the latest version, great if you're running the rc version of angular.js
/*
grunt task that calls bower install with --force-latest
simply call 'bower' from a registerTask.
grunt.registerTask('install', [
'clean',
'bower',
'bower_postinst' // good grunt plugin if you want to build something from sources, in my case I'm building angular-bootstraps 3.0.0 branch
]);
*/
@leon
leon / Grunt.scala
Last active September 3, 2016 02:23
Playframework 2.2 Grunt Runner
import sbt._
import Keys._
import java.net._
import java.io.File
import play.PlayRunHook
/*
Grunt runner should be in project directory to be picked up by sbt
*/
object Grunt {
@leon
leon / ui-router-resolve.js
Created September 13, 2013 13:47
ui-router resolve
$stateProvider.state('main', {
abstract: true,
url: '/:account',
resolve: {
auth: function ($q, $state, $stateParams, $location, AccountRepo, Security) {
return AccountRepo.auth().then(function (user) {
// If not logged in redirect to login with path preserved
if (user === false) {
$state.go('account.login', {redirect: $location.url()});
return $q.reject('not logged in');
@leon
leon / .bowerrc
Created September 5, 2013 07:11
Advanced Grunt Setup
{
"directory": "bower_components",
"json": "bower.json"
}
@leon
leon / ng-bind-html-unsafe.js
Created August 30, 2013 09:50
Angular 1.2 workaround for ng-bind-html-unsafe
'use strict';
angular.module('app').directive('ngBindHtmlUnsafe', function ($sce) {
return {
constrain: 'E',
link: function (scope, element, attr) {
scope.$watch($sce.parseAsHtml(attr.ngBindHtmlUnsafe), function(value) {
element.html(value || '');
});
}
@leon
leon / routes.js
Created May 22, 2013 21:00
UI-Routes show ui-dialog on route
.state("items.add", {
url: "/add",
onEnter: function($stateParams, $state, $dialog, $resource) {
var Item = $resource(...);
$dialog.dialog({
keyboard: true,
templateUrl: "items/add",
backdropClick: false,
@leon
leon / MongoResourceController.scala
Created May 17, 2013 09:01
MongoResourceController, simplifying working with restful data using Reactive Mongo
package controllers
import play.api.mvc._
import play.api.libs.json._
import reactivemongo.bson._
import models._
import extensions._
import extensions.JsonTransforms._
@leon
leon / MongoModel.scala
Created May 7, 2013 18:58
scala companion object call, how to?
package models
import scala.concurrent.{Future, ExecutionContext}
import reactivemongo.core.commands.{GetLastError, LastError}
import play.modules.reactivemongo.json.collection.JSONGenericHandlers
import reactivemongo.api.collections.GenericCollection
import play.api.libs.json.Json.JsValueWrapper
// Reactive Mongo imports
import reactivemongo.api._
/*
AngularJS v1.1.5-77ff108
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(function(M,X,s){'use strict';function jc(){var b=M.angular;M.angular=kc;return b}function o(b,a,c){var d;if(b)if(H(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==o)b.forEach(a,c);else if(!b||typeof b.length!=="number"?0:typeof b.hasOwnProperty!="function"&&typeof b.constructor!="function"||b instanceof O||ea&&b instanceof ea||Da.call(b)!=="[object Object]"||typeof b.callee==="function")for(d=0;d<b.length;d++)a.call(c,b[d],
d);else for(d in b)b.hasOwnProperty(d)&&a.call(c,b[d],d);return b}function pb(b){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a.sort()}function lc(b,a,c){for(var d=pb(b),e=0;e<d.length;e++)a.call(c,b[d[e]],d[e]);return d}function qb(b){return function(a,c){b(c,a)}}function Ea(){for(var b=$.length,a;b;){b--;a=$[b].charCodeAt(0);if(a==57)return $[b]="A",$.join("");if(a==90)$[b]="0";else return $[b]=String.fro
@leon
leon / Gruntfile.js
Created April 26, 2013 18:01
grunt-hub multi-module play app configuration
/*global module:false*/
module.exports = function (grunt) {
'use strict';
grunt.loadNpmTasks('grunt-hub');
grunt.initConfig({
hub: {
all: {
files: {