Skip to content

Instantly share code, notes, and snippets.

View leon's full-sized avatar

Leon Radley leon

View GitHub Profile
@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 / 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 / .bowerrc
Created September 5, 2013 07:11
Advanced Grunt Setup
{
"directory": "bower_components",
"json": "bower.json"
}
@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 / 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 / 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
]);
*/
package actions
import play.api.mvc._
import scala.concurrent.{ExecutionContext, Future}
import javax.persistence._
import play.db.jpa.JPAPlugin
import play.api.Play
import play.api.mvc.SimpleResult
class EntityManagerRequest[A](val em: EntityManager, request: Request[A]) extends WrappedRequest[A](request)
@leon
leon / README.md
Created February 4, 2014 09:49
angularjs $q decorator for spread

Use it like this

$q.all([ promise1, promise2 ]).then($q.spread(function (promise1Result, promise2Result) {

});

@leon
leon / README.md
Created September 25, 2014 09:35
Convert all files to utf-8

Use with causion

Sometimes the script fails to convert and spits out an empty file instead.

@leon
leon / Dockerfile
Created November 16, 2014 15:07
docker java 8
#
# - install jdk8 from oracle
#
RUN apt-get install -y python-software-properties software-properties-common
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get install -y oracle-java8-installer