All credits for STEPHEN GILBERT
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
| // service | |
| angular.module('myApp').service('request', ['$http', function($http) { | |
| var Request = function() { | |
| // Convenience helpers | |
| this.endpoints = { | |
| user: 'user', | |
| login: 'user/login' | |
| }; | |
| this.apiBase = 'http://myserver.com/api/'; |
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
| // in this example the logged user data is a binded var in an angular controller | |
| // place code in a parent controller to run this code one time | |
| // any time this data change we should run this code again | |
| window.Intercom('update', { | |
| email: vm.user.email, | |
| user_id: vm.user.id, | |
| name: vm.user.first_name + ' ' + vm.user.last_name, | |
| last_login: vm.user.last_login, | |
| from_app: 'Office', // custom attr | |
| from_screen: $state.current.name, // custom attr |
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
| { | |
| // http://eslint.org/docs/rules/ | |
| "ecmaFeatures": { | |
| "binaryLiterals": false, // enable binary literals | |
| "blockBindings": false, // enable let and const (aka block bindings) | |
| "defaultParams": false, // enable default function parameters | |
| "forOf": false, // enable for-of loops | |
| "generators": false, // enable generators | |
| "objectLiteralComputedProperties": false, // enable computed object literal property names |
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
| var data = { | |
| '0': 'Some content', | |
| '1': 'Another content', | |
| '2': 23 | |
| }; | |
| var newArray = Object.keys(data).map(function(key, index) { | |
| return {label: index + 1, value: data[key]}; | |
| }); |
Virtual host entry in /etc/hosts
127.0.0.1 testwp.dev www.testwp.dev
When try to see it in browser respond with: testwp.dev refused to connect
Check doing a ping and works
ping testwp.dev
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
| (function() { | |
| 'use strict'; | |
| angular.module('someApp').filter('acronym', function(){ | |
| return function(input){ | |
| return input.split(' ').map(function(x){ return x.charAt(0)}).join('').toUpperCase(); | |
| } | |
| }); | |
| }(); |
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
| // http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript | |
| // option 1 | |
| function guid() { | |
| function s4() { | |
| return Math.floor((1 + Math.random()) * 0x10000) | |
| .toString(16) | |
| .substring(1); | |
| } | |
| return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | |
| s4() + '-' + s4() + s4() + s4(); |
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
| // function passed into sort to order by obj.key | |
| function compare(a,b) { | |
| if (a.sequence < b.sequence){ | |
| return -1; | |
| } | |
| if (a.sequence > b.sequence){ | |
| return 1; | |
| } | |
| return 0; | |
| } |
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
| (function() { | |
| 'use strict'; | |
| angular | |
| .module('myApp') | |
| .directive('dynamicName', dynamicName); | |
| /** @ngInject */ | |
| function dynamicName($compile) { | |
| // put name from attribute dynamic-name (input or form tag) | |
| var directive = { |