Skip to content

Instantly share code, notes, and snippets.

View crobinson42's full-sized avatar
🏠
Working from home

Cory Robinson crobinson42

🏠
Working from home
  • American Software
  • Northwest USA
View GitHub Profile
@crobinson42
crobinson42 / package.json
Created February 25, 2016 23:18
Sails upgrade to 0.12 sails-mongo error when lowering
"dependencies": {
"babelify": "^6.3.0",
"bcrypt": "^0.8.5",
"captains-log": "^0.11.11",
"connect-redis": "3.0.2",
"cookie": "^0.2.3",
"ejs": "~0.8.4",
"error-shelter": "^0.1.3",
"event-sky": "^0.1.3",
"grunt": "0.4.2",
@crobinson42
crobinson42 / browserify.js
Created March 4, 2016 22:09
Sails.js - tasks/config/browserify.js
/**
* Browserify files
*/
module.exports = function(grunt) {
grunt.config.set('browserify', {
dist: {
files: {
// ingores browserify on all files in /dependencies
@crobinson42
crobinson42 / ActivityType.js
Last active March 6, 2016 19:50
Seeding Sails.js Models
/**
* ActivityType.js
*
*
*
* ****** NOTE - Seed Data / Default DB Data *******
* On server/app lift, there are default activity types loaded into the database.
* 1. model's are assigned a key `seedData` of the data to be inserted to dB
* and this data is available in the global `Model`.seedData
* 2. config/models.js has custom methods that are attached to all models on server
@crobinson42
crobinson42 / example.js
Created September 5, 2016 23:08
js-data-express examples
### js-data-express#Mount
`mount()` will setup routes in the Express instance passed in as the first
argument and expects a js-data store as the second arg, `mount(app, store)`. The endpoints will be reachable for each resource, `Mapper.endpoint` or `Mapper.name` (ie: `GET /user`). You can prefix the endpoints by passing a third arguement, `mount(app, store, '/api')`.
*`queryParser` is added to the endpoints when using `mount()`*
### js-data-express#Router
`new Router(store).router` will be an Express router instance that can be dropped
@crobinson42
crobinson42 / express.js
Created September 15, 2016 20:22
js-data-express schema validation
const express = require('express')
const app = express()
const jsData = require('js-data')
const jsDataExpress = require('js-data-express')
const store = new jsData.Container()
const MongoDBAdapter = require('js-data-mongodb')
const adapter = new MongoDBAdapter.MongoDBAdapter({debug: false, uri:'mongodb://localhost:27017/my-dev-db'})
store.registerAdapter('mongodb', adapter, { default: true })
"use strict";
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
var _flatten = function _flatten(_ref) {
var _ref2 = _toArray(_ref),
zeroIndex = _ref2[0],
rest = _ref2.slice(1);
@crobinson42
crobinson42 / Old.js
Created March 7, 2017 03:52
Promise refactor
this.props
.saveSession(this.titleContent.id, this.props.deviceId, true)
.then(response => {
const initialSeekTime = response.payload.data.seconds
this.props.fetchUpFrontAuthToken(this.titleContent.segments[0].mediaKey, this.props.patronInfo.patron.id, this.titleContent.circId)
.then(response => {
this.initializePlayer(this.props.patronInfo.patron.id, this.titleContent.circId, response.payload.data, config.castlabsWidevineUrl, config.castlabsPlayReadyUrl, initialSeekTime)
})
})
@crobinson42
crobinson42 / appendScriptTag.js
Created March 15, 2017 02:34
append script to document
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://raw.githubusercontent.com/fczbkk/css-selector-generator/master/build/css-selector-generator.min.js";
$("head").append(s);
@crobinson42
crobinson42 / setup.js
Last active March 18, 2017 21:00
aablefishing.com - API fiddle config & globals
function setup(axiosConfig = {}) {
// http://jsfiddle.net/coryrobinson42/r4fto1et/6/
/*****************
SETUP & Config
******************/
// because of Cross-Origin-Site issues we use the raw dev box url
window.DEV_API = 'https://howesfishing-server-crobinson42.c9users.io/'
@crobinson42
crobinson42 / dillon_task_filter_input.js
Created March 31, 2017 18:05
Live filter input for Dillon task board
// tamper script to add a live filter input next to search
const $table = $('table.task-list')
const $tableBody = $table.find('tbody')
const $filterInput = $('<input type="search" placeholder="filter"/>')
const filterInput = inputText => {
if (!inputText || inputText.length < 3) {
$tableBody.find('tr.hidden').map((i, el) => {
$(el).removeClass('hidden')
})
return