This file contains 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 mobileLinkClickModule = angular.module('ngTouchNgClickMobileLinks', []); | |
mobileLinkClickModule.directive("link", function (){ | |
return function($scope, element, attrs) | |
{ | |
// ngTouch prevents links from executing when an ng-click is present, so we need to trigger the link in those instances | |
if(Modernizr.touch && typeof attrs.ngClick !== 'undefined') | |
{ | |
element.on('touchend', function(){ |
This file contains 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("myStyle", function (){ | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) | |
{ | |
var el = element[0], | |
attr = el.getAttribute('style'); | |
el.setAttribute('style', attr); |
This file contains 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'; | |
/** | |
* Resources service for interacting with the API | |
* @param {object} $resource | |
* @param {object} AppConfiguration | |
*/ | |
function Resources($resource, AppConfiguration) { |
This file contains 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'; | |
/** | |
* Page Metadata Factory | |
*/ | |
function PageMetadataFactory() { | |
/** | |
* Metadata object |
This file contains 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
// Let's assume that we're using the mysql module for Node.js in this example. | |
const mysql = require('mysql'); | |
// We'll use Bluebird.js instead of the native Promise | |
const Promise = require('bluebird'); | |
// Now, let's create a function that returns a promise that resolves to a database connection | |
function getConnection() { | |
return Promise.try(() => Promise.promisifyAll(mysql.createConnection({}))) // We're assuming default options here | |
.disposer(connection => connection.destroy()); // Disposer will be called once getConnection resolves |
This file contains 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
// One of the biggest challenges I've seen people face when using promises | |
// has to do with how to keep functions in a chain "pure". In other words, | |
// how can functions in a promise chain have only one output for a unique | |
// set of arguments, produce no side effects, and never rely on an external state? | |
// Let's start with an example of the problem | |
// Say we need to fire an http request to get a piece of information represented in json. | |
// We have a function named getInfo() that returns a promise that resolves with the info needed. |
This file contains 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
// Simulating a Basic Promise in ES6 | |
class Promise { | |
constructor(callback) { | |
this._errorCallbacks = []; | |
this._successCallbacks = []; | |
if (typeof callback === 'function') { | |
try { | |
callback(this.resolveIt.bind(this), this.rejectIt.bind(this)); | |
} catch (e) { |
This file contains 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
'use strict'; | |
const GoogleSpreadsheet = require('google-spreadsheet'); | |
const spreadsheet = new GoogleSpreadsheet('1tVc-GnBIAAWbdCX7Zn9n-9V8j_rnv7meU22EubLN6G0'); // Sheet ID (visible in URL) | |
spreadsheet.getInfo((sheetError, info) => { | |
if (sheetError) { | |
console.error(sheetError); |
This file contains 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
'use strict'; | |
const GoogleSpreadsheet = require('google-spreadsheet'); | |
const spreadsheet = new GoogleSpreadsheet('1tVc-GnBIAAWbdCX7Zn9n-9V8j_rnv7meU22EubLN6G0'); // Sheet ID (visible in URL) | |
exports.handler = (event, context, callback) => { | |
return spreadsheet.getInfo((sheetError, info) => { | |
if (sheetError) { | |
console.error(sheetError); |
This file contains 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
{ | |
"name": "myApp", | |
"version": "1.0.0", | |
"private": "true", | |
"scripts": { | |
"build": "./node_modules/.bin/webpack --config webpack.build.config.js", | |
"start": "./node_modules/.bin/webpack-dev-server --config webpack.dev.config.js --open" | |
}, | |
"dependencies": { | |
"angular": "1.6.5", |
OlderNewer