Skip to content

Instantly share code, notes, and snippets.

View thebigredgeek's full-sized avatar
💭
Considering new contract opportunities at this time

Andrew E. Rhyne thebigredgeek

💭
Considering new contract opportunities at this time
View GitHub Profile
@thebigredgeek
thebigredgeek / promises.js
Created August 1, 2016 16:45
using promises with bluebird
var Promise = require('bluebird');
Promise.promisifyAll(City); // creates copies of every function with "Async" suffix... each return a promise
Promise.promisifyAll(Category);
Promise.all([
City.getAsync(0),
Category.getAsync(0)
]).then(function (responses) {
var cityResponse = responses[0];
@thebigredgeek
thebigredgeek / express_with_jwt.js
Last active December 16, 2024 13:04
Express API with JWT
var express = require('express')
, jwtMiddleware = require('express-jwt')
, bodyParser = require('body-parser')
, cookieParser = require('cookie-parser')
, cors = require('cors');
// We pass a secret token into the NodeJS process via an environment variable.
// We will use this token to sign cookies and JWTs
var SECRET_TOKEN = process.env.SECRET_TOKEN;
@thebigredgeek
thebigredgeek / getNextTargetCode.js
Last active May 6, 2016 00:15
NodeJS shell script that returns the next target code to stdout - https://blog.tutum.co/2015/06/08/blue-green-deployment-using-containers/
#!/usr/bin/env node
var axios = require('axios');
var args = require('yargs').argv;
function help () {
process.stdout.write(`
This command line utility is used to get the next active target code for blue/green deployments on docker cloud.\n
Usage:
./getNextTargetCode
--user=[username] Docker cloud username.
var files = [
'javascript/foo.js',
'css/bar.css',
'images/hello.png',
'images/world.jpg'
];
var fileSends = files.map(function (filePath) {
//Loops over files, passing in file[index] as filePath
//It returns a new array based on whatever is returned from each function call
var files = [
'javascript/foo.js',
'css/bar.css',
'images/hello.png',
'images/world.jpg'
];
var fileSends = files.map(function (filePath) {
//Loops over files, passing in file[index] as filePath
//It returns a new array based on whatever is returned from each function call
@thebigredgeek
thebigredgeek / data.json
Created September 2, 2015 20:14
map/reduce - promises vs reactive programming
{
"data": [
{
"value": 1
},
{
"value": 2
},
{
"value": 3
@thebigredgeek
thebigredgeek / demo.js
Last active August 29, 2015 14:27
DS#loadRelations not working
'use strict';
angular.module('console').factory('Employer', function(DS, $rootScope){
var store = DS.defineResource({
name: 'Employer',
idAttribute: 'guid',
endpoint: '/employers',
keepChangeHistory: true,
schema: {
name: 'string',
angular.module('foo').directive('fileUpload', function($event){
return {
restrict: 'E',
scope: {
uploadEvent: '='
},
template: '<input type="file" style="display: inline-block; height: 100%; width: 100%"></input>',
link: function(scope, element){
var input = element.find('input');
element.css('display', 'inline'); //make sure the element itself behaves like an input visually so
@thebigredgeek
thebigredgeek / dabblet.css
Created August 14, 2014 18:28
iOS 6 style switch checkboxes
/**
* iOS 6 style switch checkboxes
* by Lea Verou http://lea.verou.me
*/
:root input[type="checkbox"] { /* :root here acting as a filter for older browsers */
position: absolute;
opacity: 0;
}
@thebigredgeek
thebigredgeek / gist:9636284
Created March 19, 2014 06:04
quick little question
var fooList = function(){
var self = this,
data = [];
self.add = function(name){
data.push(name);
};
self.clearDeep = function(){