This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('repeatStyle', function(){ | |
var classes = [ | |
'first : $first', | |
'last : $last', | |
'middle : $middle', | |
'odd : $odd', | |
'even : $even' | |
].join(', '); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('timeout', ['$timeout', | |
function($timeout){ | |
return function $timeoutFactory(){ | |
var promise = null; | |
function timeout (fn, delay, invokeApply){ | |
$timeout.cancel(promise); | |
promise = $timeout(function(){ | |
fn(); | |
promise= null; | |
}, delay, invokeApply); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.filter "$json", -> | |
(obj, spaces = 2) -> | |
JSON.stringify obj, null, spaces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive 'confirmBox', ($templateCache, $compile, $animate, $timeout)-> | |
controller: ($element, $scope, $attrs)-> | |
contents = $element.contents() | |
dialog = null | |
action = null | |
timeout = null | |
open: (options)-> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive "contenteditable", -> | |
require: "?ngModel" | |
link: (scope, element, attrs, ngModel) -> | |
if(ngModel) | |
# view -> model | |
element.bind "blur", -> | |
scope.$apply -> | |
ngModel.$setViewValue(element.html()) | |
# model -> view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.config ($urlRouterProvider)-> | |
############################################################################################################################## | |
# https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-make-a-trailing-slash-optional-for-all-routes | |
############################################################################################################################## | |
$urlRouterProvider.rule ($injector, $location)-> | |
path = $location.path() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive("uiSrefParams", function($state) { | |
return { | |
link: function(scope, elm, attrs) { | |
var params; | |
params = scope.$eval(attrs.uiSrefParams); | |
return elm.bind("click", function(e) { | |
var button; | |
if (!angular.equals($state.params, params)) { | |
button = e.which || e.button; | |
if ((button === 0 || button === 1) && !e.ctrlKey && !e.metaKey && !e.shiftKey) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Faker = require 'Faker' | |
mongoose = require 'mongoose' | |
UserSchema = new mongoose.Schema { | |
_id: String | |
name: String | |
} | |
User = mongoose.model('User', UserSchema) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (grunt) -> | |
grunt.initConfig | |
pkg: grunt.file.readJSON("package.json") | |
sass: | |
options: | |
includePaths: ["bower_components/foundation/scss"] | |
dist: | |
options: | |
outputStyle: "compressed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
preg_match('/^SQLSTATE\[\w+\]:[^:]+:\s*(\d*)\s*(.*)/', $error->getMessage(), $matches) || | |
preg_match('/^SQLSTATE\[\w+\]\s*\[(\d+)\]\s*(.*)/', $error->getMessage(), $matches); | |
$code = $matches[1] ?: "0" ; | |
$message = $matches[2]; |