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 / 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.
@thebigredgeek
thebigredgeek / express_with_jwt.js
Last active November 5, 2023 18:35
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 / 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 / input.js
Created December 1, 2016 20:42
Pure input component with external value and sticky cursor
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import { autobind } from 'core-decorators'
import PureComponent from './pure';
@withStyles(style)
export default class Input extends PureComponent {
static propTypes = {
onChange: PropTypes.func.isRequired,
@thebigredgeek
thebigredgeek / location.graphql
Created December 5, 2016 17:42
Apollo / GraphQL basics
type Location implements Resource {
# Primary key
id: ID!
# Google's name for the Location
googleName: String!
# Google's ID for the Location
googleId: ID!
# Google's Place ID for the Location
googlePlaceId: ID!
# Google's Timezone ID for the Location
@thebigredgeek
thebigredgeek / baseResolvers.js
Created December 5, 2016 21:17
Breed-able Resolvers
import { AlreadyAuthenticatedError, NotAuthenticatedError, NotAuthorizedError } from '../errors/functional';
import createResolver from '../lib/createResolver';
export const baseResolver = createResolver();
export const isAuthenticatedResolver = baseResolver.createResolver(
(root, args, context) => {
if (!context.user || !context.user.id) throw new NotAuthenticatedError();
}
@thebigredgeek
thebigredgeek / radio.js
Created December 7, 2016 05:05
broken radio
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import { autobind } from 'core-decorators';
import withStyles from 'isomorph-style-loader/lib/withStyles';
import PureComponent from '../../components/common/pure';
import style from './radio.css';
@withStyles(style)
@thebigredgeek
thebigredgeek / demo.graphql
Last active December 9, 2016 02:58
GraphQL query demo
myUser {
# My user's ID
id
name
email
createdAt
updatedAt
Posts {
# Posts that my user has created...
id
@thebigredgeek
thebigredgeek / config.js
Last active April 24, 2017 01:18
RFC: "Solaris"
{
"redis": {
"host": "localhost",
"port": 6379,
"prefix": "solaris-"
},
"port": 3000
}
import { Permissions, Notifications } from 'expo';
import { Platform } from 'react-native';
import client from '../state/apollo';
import mutation from '../graphql/mutations/userAddPushToken';
import Observable from './observable';
export const register = async () => {