Skip to content

Instantly share code, notes, and snippets.

View snewell92's full-sized avatar
๐Ÿ•
I yearn for pizza

Sean Newell snewell92

๐Ÿ•
I yearn for pizza
View GitHub Profile
@snewell92
snewell92 / hooks.js
Created September 13, 2017 20:13
$include or else
/* TYPESCRIPT */
import authentication = require('feathers-authentication');
let authenticate = authentication.hooks.authenticate;
import { OrderQueryParam, SequelizeOrder, filterOrder, filterLikeQueryParam, filterIncludeQueryParam } from '../index';
const isAuthenticated = authenticate('jwt');
export default {
@snewell92
snewell92 / app.js
Last active September 15, 2017 18:08
Failing ava test
/* TYPESCRIPT */
import * as path from 'path';
import * as favicon from 'serve-favicon';
import * as compress from 'compression';
import * as cors from 'cors';
import * as helmet from 'helmet';
import * as bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser';
import * as feathers from 'feathers';
@snewell92
snewell92 / .circleci_config.yml
Created September 19, 2017 15:43
circle ci ssh
version: 2
jobs:
build:
docker:
- image: kyleondy/alpine-rsync
working_directory: ~/repo
steps:
- run:
name: list
command: ls -la ~/.ssh
@snewell92
snewell92 / .hyper.js
Created September 29, 2017 13:51
Hyper config
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
@snewell92
snewell92 / index.ts
Last active October 4, 2017 17:48
Micro Dev hangs
import { createTransport, SendMailOptions } from 'nodemailer';
import { IncomingMessage, ServerResponse } from 'http'
import { json, send } from 'micro';
type MicroFunction = (req: IncomingMessage, res: ServerResponse) => string | void | Promise<any>;
type DorianMailData = {
dest: string,
body: string,
@snewell92
snewell92 / fp-test.js
Last active October 17, 2017 20:40
Refactor to task
const crypto = require('crypto');
const util = require('util');
const curry = require('lodash/curry');
const compose = require('lodash/flowRight'); // alias flowRight as compose
const moment = require('moment');
const Task = require('folktale/concurrency/task');
const { fromPromised, waitAll } = require('folktale/concurrency/task');
// isValidForgotPasswordRequest :: ForgotPasswordInput -> boolean
@snewell92
snewell92 / app.ts
Created October 18, 2017 20:46
Context
import { curry, flowRight as compose } from 'lodash';
const Task = require('folktale/concurrency/task');
/* example code, pieces from application */
/* Imagine a functional-progrmaming style Forgot Password workflow */
usernameOrEmailExists = (input: {/*...*/}) => isValid(input)
? Task.of(input.username)
: Task.rejected('Invalid');
@snewell92
snewell92 / ifThen.ts
Created December 18, 2017 20:46
Typescript ifThen pattern
import { curry } from 'lodash';
export type Predicate = () => boolean;
export type Func<a> = () => a;
export interface ThenElse<T = void, E = T> {
t: Func<T>,
e: Func<E>
}
@snewell92
snewell92 / Continuation.js
Created February 28, 2018 16:03
Some thing to map but stop on a failure
class ContinueOnSuccess {
items = [];
length = 0;
constructor(newItems) {
this.items = newItems;
length = this.items.length;
}
@snewell92
snewell92 / api-server.js
Last active March 8, 2018 21:21
Feathers JWT doesn't have userID
// CLIENT
import feathers from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import auth from '@feathersjs/authentication-client'
import io from 'socket.io-client'
const socket = io('http://localhost:3030')
const app = feathers()
// Set up Socket.io client with the socket