Skip to content

Instantly share code, notes, and snippets.

View auxcoder's full-sized avatar
🗼
Working from home

AuxCoder auxcoder

🗼
Working from home
View GitHub Profile
@auxcoder
auxcoder / apple-devises-media-queries.md
Created January 24, 2017 14:49
CSS Media Queries for iPads & iPhones
@auxcoder
auxcoder / hybrid-facade-pattern.js
Created January 13, 2017 21:43
Angular services as a useable patterns for any method
// 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/';
@auxcoder
auxcoder / client-side-intercom-update.js
Last active January 12, 2017 18:28
Intercom widget integration with Google Tag Manager as a Custom HTML Tag
// 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
@auxcoder
auxcoder / .eslintrc
Created January 3, 2017 18:20 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// 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
@auxcoder
auxcoder / map-object.js
Created December 28, 2016 21:37
Map over an Object returning a new Array
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]};
});
@auxcoder
auxcoder / virtual-host-mac.markdown
Last active December 26, 2016 17:38
Solving issues with virtual host in MacOS

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
@auxcoder
auxcoder / acronym.filter.js
Created November 30, 2016 15:18
Angular filter to convert a frase/name (string input) into an acronym.
(function() {
'use strict';
angular.module('someApp').filter('acronym', function(){
return function(input){
return input.split(' ').map(function(x){ return x.charAt(0)}).join('').toUpperCase();
}
});
}();
@auxcoder
auxcoder / generate-guid.js
Last active November 23, 2016 15:43
Create GUID / UUID in JavaScript
// 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();
@auxcoder
auxcoder / array-sort-by-obj-key.js
Last active August 30, 2016 16:39
Order array of objects by object.attribute (sort)
// 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;
}
@auxcoder
auxcoder / dynamic-name.directive.js
Last active August 17, 2016 15:52
form validation with ng-repeat ( undefined input fields )
(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 = {