Skip to content

Instantly share code, notes, and snippets.

View d1b1's full-sized avatar
🎯
Focusing

Stephan L. Smith d1b1

🎯
Focusing
View GitHub Profile
@d1b1
d1b1 / .env
Last active May 9, 2024 15:42
Github CDN from Airtable
ALGOLIA_APP_ID=
ALGOLIA_ADMIN_API_KEY=
ALGOLIA_INDEX_NAME=
AIRTABLE_API_KEY=
AIRTABLE_BASE_ID=
AIRTABLE_TABLE_NAME=
GITHUB_PERSONAL_ACCESS_TOKEN=
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) {
@d1b1
d1b1 / gist:7949308
Last active October 25, 2016 08:50
Programmatic Mocha script for CodeShip.io - Starts an express app, and runs any .js tests in the tests folder. This allows a node.js Swagger.js rest API to be testable on travis-ci and codeship.io.
/*
Programmatic Mocha code - This is used by a codeship
test to both start an expressjs app, setup routes and
run a suite of mocha tests.
Hint: Place this in the root of the project. Call from
test package.js or setup with > node mocha.js
Also see: https://gist.github.com/d1b1/7949456 (Expressjs + Swagger App)
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);