Skip to content

Instantly share code, notes, and snippets.

View d1b1's full-sized avatar
🎯
Focusing

Stephan L. Smith d1b1

🎯
Focusing
View GitHub Profile
functions.database.ref('/invites/{id}/actions/email').onWrite((event, context) => {
const action = event.after.val()
// Check if the function has been run.
if (!action || action == 'failed' || action == 'completed') return 0
// Use the parent.parent to get to the actual object.
return event.after.ref.parent.parent.once('value').then(snap => {
@d1b1
d1b1 / gulp task for index.html
Last active September 14, 2017 13:27
Firebase Hosting Cache & Gulp
const git = require('git-rev')
const data = require('gulp-data')
const pkg = require('./package.json')
const template = require('gulp-template')
gulp.task('environment', function() {
git.branch(function (branch) {
git.short(function (commit) {
console.log('Setting up configuration for', branch.toUpperCase())
app.run(['$rootScope', '$uibModal'', function($rootScope, $uibModal) {
$rootScope.editBoook = function(Book) {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/modals/book/edit/page.html',
controller: ['$scope', function($scope) {
$scope.Book = Book;
$scope.cancel = function() {
Book.$cancel().then(modal.close);
@d1b1
d1b1 / gist:7e3e7586242c1005d7baa363f84ca49f
Last active July 7, 2017 18:10
$firebaseObject.$cancel() Method
app
.factory('BookFactory', ['$firebaseObject', function($firebaseObject) {
return $firebaseObject.$extend({
$cancel: function() {
var self = this;
return new Promise((resolve, reject) => {
self.$ref().once('value', function(d) {
var raw = d.val();
_.each(raw, function(v, k) {
self[k] = v;
@d1b1
d1b1 / gist:16c8840cab2c4c6293a0735673b101f0
Last active March 30, 2017 01:22
Angular + ngParams + AngularFire Array (with UI-Router Resolve)
// Assumes the Firebase Ref creates a $firebaseArray
// Assumes a ui-Router with resolved to get the data.
// TODO: Research the ngTableParams for a better way
// to trigger changes and watch the array.
.state ('plan', {
url: '/plan',
templateUrl: 'js/routes/plan/tpls/table.html',
resolve: {
Session: ['Auth', function(Auth) {
Add the following to a Codeship.io Deployment (Custom) Script. This will update heroku configs with the late CI Run Date and Commit.
export CI_RUN_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
heroku config:add --app api-thebasicsapp-com LAST_DEPLOYMENT_COMMIT=$CI_COMMIT_ID
heroku config:add --app api-thebasicsapp-com LAST_DEPLOYMENT_COMMIT_DATE=$CI_RUN_AT
@d1b1
d1b1 / gist:cbf13a77201c7f75b9b0
Last active January 12, 2016 14:52
SwaggerJS UI Toggle with Path Change
/* Very simple solution to ensure that the path changes each time the Swagger UI is toggled open. This
helps speed up testing and fixes. The older version use to support this, but for some reason it was
not included in the same way in the new swagger JS. This just binds an changes the URL.
*/
setTimeout(function(){
$('.toggleEndpointList, .toggleOperation').on('click', function(data) {
window.location = this.href;
});
}, 2000);
@d1b1
d1b1 / 0_reuse_code.js
Created September 22, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@d1b1
d1b1 / Git Notes
Last active August 29, 2015 14:28
Git Must-Remember Notes
// GIT Merge
// Use this feature to push an local branch 'over' a remote branch.
// This is useful when mushing a local release branch into the staging
// environment.
git push origin localBranch:remoteBranch
or
@d1b1
d1b1 / gist:d82a2bfe0ac103298079
Created June 2, 2015 00:40
Parse.com + Stripe.com API Workaround
Seems that parse.com has either neutered a portion of the their stripe.com integration, just decided it is not needed. The docs seem to point to the Stripe.Customers.update(id, token) as the way to add a card (using a token) to a customers account. This works, but only allows a single card. This overwrites the initial card with the new card. Not great.
// This should work, but only allows a single card.
Stripe.Customers.update(customer, { card: found.get('token') },
function(err, token) {
console.log('got here for token');
console.log(token);
});
// This works, and seems to point to the need for parse.com to add some work to their backlog. Looks