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
const flatten = (nestedArr) => { | |
const flattened = [].concat.apply([], nestedArr); | |
for(let i = 0; i < flattened.length; i++) { | |
if(flattened[i] instanceof Array) { | |
return (flatten(flattened)) | |
} | |
} | |
return flattened; |
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
// invoices is an array of objects | |
function checkAllInvoices(invoices) { | |
return new Promise((resolve, reject) => { | |
let valueString = ''; | |
_.each(invoices, (invoice, i) => { | |
valueString += `'${invoice.Id}'${i < invoices.length-1 ? ',' : ''}`; | |
}); | |
let selectStatement = `SELECT * FROM user_mgmt.stripe_invoices WHERE sf_invoice_id IN (${valueString});`; |
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 _ = require('lodash'); | |
let stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); | |
const next100 = (starting_after) => { | |
return stripe.customers.list({ | |
limit: 100, | |
starting_after: starting_after | |
}) | |
.then((customers) => { | |
return customers; |
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.post('http://localhost:3000/users/signin', { | |
email: email, | |
password: password | |
}) | |
.then(function(res) { | |
console.log(res.data); | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}); |
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
// Explanation: Sharing a value between multiple controllers can be done by using a service to create a custom data-bind. | |
// 1. You have a service that has a variable that will be shared between multiple controllers. | |
// 2. In the service you have getter and setter methods in order for your controllers to both receive the shared value and change the shared value. | |
// 3. You inject that service into all of the controllers you want to share the value between. | |
// 4. At the top of your controllers that will be using the shared value, immediately set a $scope variable to the return value of the getter method for the shared value that is available through the service. | |
// 5. Create a $scope.$watch statement that returns the value of the getter method for the shared value. | |
// 6. The $scope.$watch method will run whenever a $scope variable in one of your controllers change it's value or whenever a $scope function is called. | |
// 7. If the $scope.$watch detects a change in the return value of your getter method for the sha |
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 hasSession(data) { | |
var deferred = $q.defer(); | |
if (data.user && data.token) { | |
deferred.resolve(true); | |
} else { | |
deferred.reject(false); | |
} | |
return deferred.promise; |
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 _ = require('lodash'); | |
let stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); | |
let Promise = require('bluebird'); | |
function bulkChargeInvoices(chargeObjects) { | |
return new Promise((resolve, reject) => { | |
let promiseArray = []; | |
_.each(chargeObjects, (chargeObj) => { | |
promiseArray.push(stripe.charges.create(chargeObj.charge)); |
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 (angular) { | |
'use strict'; | |
angular | |
.module('myApp', ['moment-picker']) | |
.directive('datetimeCalendar', function() { | |
return { | |
restrict: 'EA', | |
scope: { | |
asString: '=?', | |
asMoment: '=?', |
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
// Original Query Which Works: | |
let dynamicQuery = `SELECT | |
s.name AS "Service" | |
${serviceFields} | |
${serviceComponentFields} | |
${locationAField} | |
${locationZField} | |
${governingContractField} | |
FROM salesforce.Service__c s |
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 dynamicQuery = `SELECT | |
s.name AS "Service" | |
,b.name as account_name | |
${serviceFields} | |
${serviceComponentFields} | |
${locationAField} | |
${locationZField} | |
${governingContractField} | |
FROM salesforce.Service__c s | |
${joinString} |
OlderNewer