Skip to content

Instantly share code, notes, and snippets.

View ericeslinger's full-sized avatar

Eric Eslinger ericeslinger

View GitHub Profile
#!/bin/sh
# http://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes
require_clean_work_tree () {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --; then
@ericeslinger
ericeslinger / document.coffee
Last active May 13, 2016 21:09
Add side-loads to BookshelfJS
Knex = require 'knex'
Promise = require 'bluebird'
FlormModel = require './flormModel'
Document = FlormModel.extend
tableName: 'documents'
# here's an example sideload construct. I want to know document editor ids, which are stored in the
# edges join table - that table stores parent_id and child_id polymorphically (with parent_type and child_type)
# also polymorphically with join type- 'grant: edit' denotes editorship.
@ericeslinger
ericeslinger / batchRequest.coffee
Last active August 29, 2015 14:05
Batch loader with bassmaster
angular.module 'clientApp.apiModel.batchRequest', ['ng']
.service 'BatchRequest', ($q, Server, $http, $timeout)->
timeoutPromise = undefined
queue = []
postBatch = ->
requestQueue = queue.map (req)-> {method: 'GET', path: req.url, deferred: req.deferred}
queue = []
timeoutPromise = undefined
$http
method: 'POST'
@ericeslinger
ericeslinger / authenticate.js
Last active August 29, 2015 14:15
angular token authentication
// based heavily on https://github.com/witoldsz/angular-http-auth/blob/master/src/http-auth-interceptor.js
var buffer401 = [];
angular.module('app.model').config(function($httpProvider) {
$httpProvider.interceptors.push(function($rootScope, $q) {
return {
responseError: function(rejection) {
if (rejection.status === 401) {
return $q(function(resolve, reject) {
@ericeslinger
ericeslinger / Client Updates with Listen - Notify in PostgreSQL.md
Last active October 6, 2016 13:04
Postgres Listen/Notify for automatic updates

Listen / Notify for automatic object updates - pattern in postgreSQL Presented at the San Francsico PostgreSQL User Group Meetup 8/17/15

by Eric Eslinger eric.eslinger@gmail.com github.com/ericeslinger

This example uses listen/notify calls in PostgreSQL that trigger on row update to pass events from the database to a listening node.js web application that in turn uses socket.io to pass events

@ericeslinger
ericeslinger / README.md
Last active May 27, 2016 01:28
Convert an HTML string into a rich-text delta using node.js and jsdom

This is a really ugly hack, but it works well enough for me to do as a one-off to convert a bunch of data from html strings into rich-text objects. I had originally stored my data in the long_text column as an html string, and now I want to store the raw JSON version of the same data in the rich_text column.

This is really just a demo of the idea, but if it helps anyone, I'll be happy that it does.

@ericeslinger
ericeslinger / npm-debug.log
Created June 1, 2017 03:09
npm error with gulp#4.0
0 info it worked if it ends with ok
1 verbose cli [ '/Users/eric/.nvm/versions/node/v8.0.0/bin/node',
1 verbose cli '/Users/eric/.nvm/versions/node/v8.0.0/bin/npm',
1 verbose cli 'i',
1 verbose cli 'github:gulpjs/gulp#4.0' ]
2 info using npm@5.0.1
3 info using node@v8.0.0
4 silly install loadCurrentTree
5 silly install readLocalPackageData
6 silly fetchPackageMetaData error for github:gulpjs/gulp#4.0 No matching version found for undefined@4.0
npm info it worked if it ends with ok
npm verb cli [ '/home/eric/.nvm/versions/node/v8.1.2/bin/node',
npm verb cli '/home/eric/.nvm/versions/node/v8.1.2/bin/npm',
npm verb cli 'i',
npm verb cli '--no-save',
npm verb cli '-ddd',
npm verb cli '../core' ]
npm info using npm@5.1.0
npm info using node@v8.1.2
npm verb npm-session 1f6997470a7b85fc
@ericeslinger
ericeslinger / snippetize.ts
Created October 11, 2017 17:49
rich text / quill snippet
function snippetize(delta: DeltaStatic, maxLength: number): { ops: any[] } {
const retVal = {
ops: [],
};
let done = false;
let idx = 0;
let soFar = 0;
while (!done && delta.ops.length > idx) {
const op = Object.assign({}, delta.ops[idx]);
idx = idx + 1;
@ericeslinger
ericeslinger / belt.txt
Created March 30, 2018 17:46
belt manufacturing hex for factorio
0eNq9m1uP6jYQgP/KUZ7JyuNrgvoHKvWxb9URCuCyUdkEJWF1Viv+exPCfcebGaP2ZVkg+cYee64On8lyu/e7pqy6ZP6ZlKu6apP5X59JW26qYjt81n3sfDJPys6/JbOkKt6Gd01RbpPDLCmrtf+VzOEwQ255L5tu339yuWu8IpU3d8rDz1niq67sSj9KPr75WFT7t6VvevTl7tW+effr9Ch6luzqtr+nrgZ5PScFM0s++lfTs9dl41fjl3YY2QNSXpDLcpP6bX9tU67SXb31GNiNYHtAUIo4OocOTiFEfdVW18M2r11wxuI8sDuoRKCGDM3ITEtmWjLTkZmazMzITElm5lQmfYmG1aQx6cMEovE4sumApI6SvkCgqEz6RgKyGdE3PJCtiGGZYGlLFHBvmAcBx/Fv37o3oBsPnBQp7wfoMGp+F0fS1WtRVukpfGDkl9Pk9cvD9AHz7oJHhyAdjR1Xk2r3y7YrjpcG/ajCtColNaaNEJhWqSQGIpyIbUx5tSD/a9f4tk37HVC1u7rp0qXfdogpBTWJCrg1p2L1T1pWrW+6/qswWD2CNQa2X0a+75ONZtPU/Wtg7HlYxOySAlW7fZdgEh1bV3lQV+iUMrYAELx9zbJJptEolkl+Y++Yu1NAdsu4i8KciJL0rGF09mLaSJXiQh+His5f8/ydPWtXPmrXYHTDopsgHFWI5cD1mQ2kgd/mkt4PcN9+57SGEWOcjO+mgGLTKidFErjsBKxY4BmWZa2OJhtWYLdiy6IlEyqmjVVTqzA5hj+Y9liaXobJMR8n5D3acKGCUC/S6zCwGBSLzZpeiIEmQxnJpCRDc269TIAawayXKUxg1ssUpmTWyxSm4lV4FKTmFXgUpOHVdxSkZZZ3FCbZjug73pDNiG6ahmxFdB9iBc0r404Zc3WWHpBQbWLxyEomk5A8WsXKmeQ5sQFKeWsZkUljI0Y1y8vywIVGjMVSa2mZWArn7HFMT1Z1VY3cdrgChj+bxvvqtk1crnsBt8F2+MDB4ec