Skip to content

Instantly share code, notes, and snippets.

View jdrew1303's full-sized avatar
probably drinking coffee

James Drew jdrew1303

probably drinking coffee
View GitHub Profile
@jdrew1303
jdrew1303 / index.js
Last active August 5, 2018 00:31
using a neural network for text classification in javascript
const mimir = require('mimir');
const brain = require('brain.js');
/* few utils for the example */
// our output is recorded as a vector, where the index in the vector
// is the enum (we create it with a zero index). We fill the index in
// the array with a 1 and the rest of the items as a 0 (true and false).
const vec_result = (res, num_classes) => {
const outputVector = new Array(num_classes).fill(0);
@jdrew1303
jdrew1303 / readme.md
Last active July 25, 2018 00:03
planning features

Basic Case Analysis

  • What’s required to build it?
  • How should it behave?
  • What people and computer systems are involved?

answer these four questions:

  1. Who are the actors and what are their roles?
  2. What’s the purpose of this feature?
  3. What are the use cases?
@jdrew1303
jdrew1303 / readme.md
Created July 24, 2018 23:42
rails security checklist

This checklist of Ruby on Rails Security Best Practices focuses on the development side.

Check for Unauthorized Access Authentication Filter Passwords and Other Sensitive Data on Logs Cross Site Request Forgery (CSRF) Strong Parameters Throttling Requests Protecting Your Users Use HTTPS

@jdrew1303
jdrew1303 / markdown.md
Created July 19, 2018 16:29 — forked from rikukissa/POST.md
Unit testing Angular.js app with node.js, mocha, angular-mocks and jsdom

Testing Angular.js app headlessly with node.js + mocha

Lean unit tests with minimal setup

Code examples

Keypoints

  • Fake DOM (Everything works without a real browser)
  • Uses ngMocks to inject and mock Angular.js dependencies
  • I'm assuming you are already using browserify (but everything works fine without it)
@jdrew1303
jdrew1303 / main.ts
Created July 19, 2018 16:23 — forked from jon-acker/main.ts
Run Angular 4 app in NodeJS using jsdom instead of a real DOM
import 'zone.js';
import 'reflect-metadata';
import * as path from 'path';
import * as fs from 'fs';
// import { XMLHttpRequest } from 'xmlhttprequest';
import { JSDOM } from 'jsdom';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ResourceLoader } from '@angular/compiler';
import { AppModule } from './app/app.module';
@jdrew1303
jdrew1303 / Event-stream based GraphQL subscriptions.md
Created July 15, 2018 23:11 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@jdrew1303
jdrew1303 / readme.md
Last active July 27, 2025 09:47
Market Order Matching Engine

Introduction

The computer driven markets for instruments like stocks and exchange traded stock options, have transformed finance and the flow of capital. These markets are enabled by order matching engines (and the infrastructure that supports this software). Before computer trading networks and matching engines, stocks where traded on cavernous exchange floors and transaction costs where high. When electronic trading fully matured, floor traders were a fading anachronism and transaction costs had been reduced to pennies a share in many cases. Electronic trading could not exist without advanced network infrastructure, but without the software matching engines no shares would change hands. The computer trading networks, the matching engine software has also created a concentrated nexus of potential failure. Failures in these systems have increased as the frequency and volume on the electronic networks has increased. The position of order matching engines in the trading infrastructure makes these systems o

@jdrew1303
jdrew1303 / apiMiddleware.js
Last active July 15, 2018 19:32
Exploring Redux
// simple example of how to achieve more declaritive api calls using middleware in redux like frameworks
const apiMiddleare = ({dispatch}) => (next) => (action) => {
return (action.type === '[get] api')
? fetch(action.payload.url)
.then(response => response.json())
.then(json => dispatch({
type: action.payload.success,
payload: json
}))
import * as R from 'ramda';
// union and difference are more or less the same except
// for the operation performed
const abstractSummation = R.curry((operation, a, b) => R.reduce((s, e) => {
s[operation](e);
return s;
}, new Set(a), b));
// for the given sets:
// A={2,4,6,8,10}
@jdrew1303
jdrew1303 / AGB-001_Light_Mod.md
Created June 18, 2018 23:15 — forked from grantland/AGB-001_Light_Mod.md
AGB-001 Front/Backlight Mod Instructions

AGB-001 Front/Backlight Mod Instructions

AGB-001 Backlight Mod

Requirements

  • AGB-001
  • ASS101 screen