Skip to content

Instantly share code, notes, and snippets.

Avatar
😺
Workin' and Livin'

Sean Newell snewell92

😺
Workin' and Livin'
View GitHub Profile
@snewell92
snewell92 / my-dict.ts
Last active Sep 28, 2018
Typescript Dictionary
View my-dict.ts
type KEY = string | number | symbol;
interface Dictionary<K extends KEY, V> {
getKeys(): K[];
getValues(): V[];
get(key: K): V | null;
put(key: K, val: V): void; // or boolean?
}
class JSDict<K extends KEY, V> implements Dictionary<K, V> {
View test-app.docker-compose.yml
version: "2"
services:
app:
image: crccheck/hello-world
restart: always
networks:
- web
- default
expose:
@snewell92
snewell92 / api-server.js
Last active Mar 8, 2018
Feathers JWT doesn't have userID
View api-server.js
// 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
@snewell92
snewell92 / Continuation.js
Created Feb 28, 2018
Some thing to map but stop on a failure
View Continuation.js
class ContinueOnSuccess {
items = [];
length = 0;
constructor(newItems) {
this.items = newItems;
length = this.items.length;
}
@snewell92
snewell92 / ifThen.ts
Created Dec 18, 2017
Typescript ifThen pattern
View ifThen.ts
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>
}
View app.ts
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 / fp-test.js
Last active Oct 17, 2017
Refactor to task
View fp-test.js
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 / index.ts
Last active Oct 4, 2017
Micro Dev hangs
View index.ts
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,
View .hyper.js
// 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',
View .circleci_config.yml
version: 2
jobs:
build:
docker:
- image: kyleondy/alpine-rsync
working_directory: ~/repo
steps:
- run:
name: list
command: ls -la ~/.ssh
You can’t perform that action at this time.