Skip to content

Instantly share code, notes, and snippets.

View alexanderjeurissen's full-sized avatar

Alexander Jeurissen alexanderjeurissen

View GitHub Profile
@alexanderjeurissen
alexanderjeurissen / fixParsingInconsistencies.js
Last active August 29, 2015 14:01
This gist is a slightly modified version from the plunker of Emil van Galen. It basically forces angular to set a ng-model value to null instead of an empty string (when this directive is applied and the model value is empty). a blog post about the issue and some additional solutions can be found here: (http://blog.jdriven.com/2013/09/how-angula…
'use strict';
angular.module('ModuleName')
.directive('fixParsingInconsistencies', function () {
return {
require: '?ngModel',
priority: (angular.version.full.indexOf('1.2.') === 0 &&
angular.version.full !== '1.2.0rc1' &&
angular.version.full !== '1.2.0-rc.2') ? 1 : 0,
restrict: 'A',
@alexanderjeurissen
alexanderjeurissen / parseFileName.js
Created August 1, 2014 10:39
A simple file name parser factory for angular projects.
angular.module('appointment')
.factory('FileNameParser', function () {
return {
parse: function (file) {
var extensionPattern = /\.[0-9a-z]+$/i;
var extension = extensionPattern.exec(file);
return {
file_name: file.replace(extension, ''),
file_type: extension[0].replace('.', '').toLowerCase()
};
@alexanderjeurissen
alexanderjeurissen / includeReplace.js
Created September 21, 2014 11:45
based on http://stackoverflow.com/a/24921498 It's a solution to the deprecation of `replace:true` attribute on directives.
app.directive('includeReplace', function () {
return {
require: 'ngInclude',
restrict: 'A', /* optional */
link: function (scope, el, attrs) {
el.replaceWith(el.children());
}
};
});
## Global Snippets
# Define a new Angular Controller;
# You can change the controller name and parameters
snippet ngc
.controller(${1:controllerName}, ['$scope', '${2:controllerDependencies}',
function($scope, ${4:injectables}) {
${5}
};
]);
# angular.foreach loop
# -polka-
# Remove the default keybinding
unbind C-b
# Set a new keybinding to C-/. In terminals C-/ is the same as C-_
# however in tmux we can't bind to C-/
set -g prefix C-t
# lower interval for faster updates
//GistId: 1e59a17
{
"preset": "google",
"maximumLineLength": 120,
"disallowSpacesInsideObjectBrackets": null,
"disallowSpacesInFunctionExpression": null,
"disallowSpacesInAnonymousFunctionExpression": null,
"disallowMultipleVarDecl": true,
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
//GistID:1c45ca694ad333baeddd
'use strict';
angular.module('stateMock', []);
angular.module('stateMock').service("$state", function($q) {
this.expectedTransitions = [];
this.current = {};
this.transitionTo = function(stateName) {
if (this.expectedTransitions.length > 0) {
var expectedState = this.expectedTransitions.shift();
import Ember from 'ember';
import FilterSelectMixin from 'applicationfilter-select';
const {RSVP} = Ember;
export default Ember.Controller.extend(FilterSelectMixin, {
search: '',
filter: '',
queryParams: ['search', 'filter'],
sortAscending: false,
var hashCode = function(s) {
return s.split("").reduce(function(a, b) {
a = ((a << 5) - a) + b.charCodeAt(0);
return a & a
}, 0);
}