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
// http://www.cronj.com/blog/hapi-file-upload-download/ | |
var hapi = require('hapi'); | |
var fs = require('fs'); | |
// Create a server with a host and port | |
var server = new hapi.Server(); | |
server.connection({ | |
host: '127.0.0.1', | |
port: 8000 |
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
// For more details refere http://www.webdeveasy.com/interceptors-in-angularjs-and-useful-examples/ | |
angular.module('MyApp', []) | |
// Custome Interceptor that will get injected on each HTTP request | |
// Add $ionicLoading at run time using $injector to avoid circular dependency error | |
.factory('customeInterceptor',['$timeout','$injector', '$q',function($timeout, $injector, $q) { | |
var requestInitiated; |
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 Hapi = require('hapi'), | |
boom = require('boom'); | |
// Create a server with a host and port | |
var server = new Hapi.Server(); | |
server.connection({ | |
host: 'localhost', | |
port: 8000 | |
}); |
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 Promise = require('bluebird'), | |
nodemailer = Promise.promisifyAll(require('nodemailer')), | |
sendGridTransport = require('nodemailer-sendgrid-transport'); | |
var options = { | |
auth: { | |
api_user: process.env.SENDGRID_USERNAME, | |
api_key: process.env.SENDGRID_PASSWORD | |
} | |
} |
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 getUTCTimeFromTimeStamp(timestamp) { | |
var currentTime = new Date(timestamp), | |
unixTime = new Date( | |
currentTime.getUTCFullYear(), | |
currentTime.getUTCMonth(), | |
currentTime.getUTCDate(), | |
currentTime.getUTCHours(), | |
currentTime.getUTCMinutes(), | |
currentTime.getUTCSeconds() |
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
//https://www.npmjs.com/package/tv | |
var Hapi = require('hapi'); | |
var Tv = require('tv'); | |
// Create a server with a host and port | |
var server = new Hapi.Server(); | |
server.connection({ | |
host: 'localhost', | |
port: 8000 |
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 crypto = require('crypto'), | |
algorithm = 'aes-256-ctr', | |
password = '6LehWQcTAAAAADgH-I5WmmkuDFFJ_pMr_866zz17'; | |
function encrypt(text){ | |
var cipher = crypto.createCipher(algorithm,password) | |
var crypted = cipher.update(text,'utf8','hex') | |
crypted += cipher.final('hex'); | |
return crypted; | |
} |
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
// returns an object that does not itself possess "var a" | |
// The closure gives indirect access to a, via the public getter and setter. | |
function f() { | |
var a = 1; | |
return { | |
getA: function() { | |
return a; | |
}, | |
setA: function( A ) { |
OlderNewer