Skip to content

Instantly share code, notes, and snippets.

View chrisabrams's full-sized avatar

Chris Abrams chrisabrams

  • New York, NY
View GitHub Profile
@chrisabrams
chrisabrams / index.js
Created March 26, 2018 15:25
Basic buffer stuff for Node.js
function convertTo(type, data) {
switch(type) {
case 'hex':
case 'string':
return Buffer.from(data).toString('hex')
case 'buffer':
case 'Uint8Array':
return Buffer.from(data, 'hex')
}
// start.js
import React from 'react'
import ReactDOM from 'react-dom'
import { hot } from 'react-hot-loader'
const App = () => <div>Hello World!! 4</div>
const HotApp = hot(module)(App)
ReactDOM.render(<HotApp />, document.getElementById('root'))
// start.js
import React from 'react'
import ReactDOM from 'react-dom'
import { hot } from 'react-hot-loader'
export default function start() {
const App = () => <div>Hello World!! 4</div>
const HotApp = hot(module)(App)
@chrisabrams
chrisabrams / bundleAnalysis.js
Created September 23, 2017 16:01 — forked from kanavarora/bundleAnalysis.js
Simple utility to track your bundle/chunk sizes with each release
/*
Utility to analyze bundle chunks over versions.
Assumes: webpack has already created the bundle summary json file -> stats.json
Parameters:
version: (Optional) a string that labels the current bundle with the version
provided and saves the summary in a csv file.
Output:
If run the first time, generates a csv file bundleAnalaysis.csv, which
@chrisabrams
chrisabrams / install.js
Created March 3, 2017 13:37
Bash script to update project dependencies quickly
#!/usr/bin/env node
/*
Usage:
Install all production depenencies to their current version: ~/npm/install --prod
Install all production depenencies to their latest: ~/npm/install --prod --latest
Install all production depenencies to their latest and update package.json: ~/npm/install --prod --latest --save
Install all development depenencies to their current version: ~/npm/install --dev
@chrisabrams
chrisabrams / idea.js
Last active September 22, 2016 15:32
idea
export default function pluginInterface(props = {}) {
const Model = modelInterface(props.Model)
const Controller = controllerInterface(props.Controller, Model)
const ChargeModel = chargeModelInterface(Model)
const ChargeController = chargeControllerInterface(Controller, ChargeModel)
return [
{
@chrisabrams
chrisabrams / foo.js
Created August 15, 2016 20:46
dates and times with rethinkdb
convertDateToDatabaseTime4(d) {
var date = (d) ? moment(d) : moment(),
year = parseInt(date.format('YYYY')),
month = parseInt(date.format('M')),
day = parseInt(date.format('D'))
return r.time(year, month, day, '-04:00')
}
convertDateToDatabaseTime7(year, month, day, hour = 0, minute = 0, second = 0, timezone = '-04:00') {
var times = {
// Last day available to register
end: {
'James': r.time(2016, 7, 3, '-04:00'),
'John': r.time(2016, 7, 2, '-04:00')
},
// First day available to register
start: {
'James': r.time(2016, 7, 2, '-04:00'),
'John': r.time(2016, 7, 1, '-04:00')
{
"indexes": [
"minute"
],
"primary_key": "id",
"schema": {
"close": {
"default": 0,
"null": false
},
// minutes
[{"close":31.67,"date":"2016-06-02","high":31.67,"id":"AAL-0-2016-06-02","low":31.67,"minute":0,"open":31.67,"symbol":"AAL","volume":67512},{"close":30.78,"date":"2016-06-06","high":30.78,"id":"AAL-0-2016-06-06","low":30.77,"minute":0,"open":30.77,"symbol":"AAL","volume":64594},{"close":31.94,"date":"2016-06-01","high":31.94,"id":"AAL-0-2016-06-01","low":31.94,"minute":0,"open":31.94,"symbol":"AAL","volume":97778},{"close":32.25,"date":"2016-06-09","high":32.3,"id":"AAL-0-2016-06-09","low":32.25,"minute":0,"open":32.25,"symbol":"AAL","volume":60465},{"close":31.55,"date":"2016-06-03","high":31.59,"id":"AAL-0-2016-06-03","low":31.55,"minute":0,"open":31.59,"symbol":"AAL","volume":79261},{"close":31.35,"date":"2016-06-07","high":31.48,"id":"AAL-0-2016-06-07","low":31.35,"minute":0,"open":31.46,"symbol":"AAL","volume":47844},{"close":31.86,"date":"2016-06-14","high":31.87,"id":"AAL-1-2016-06-14","low":31.7,"minute":1,"open":31.81,"symbol":"AAL","volume":68979},{"close":32.67,"date":"2016-06-08","high