Skip to content

Instantly share code, notes, and snippets.

View danawoodman's full-sized avatar
👨‍🔬
Hacking away...

Dana Woodman danawoodman

👨‍🔬
Hacking away...
View GitHub Profile
alias -='cd -'
alias ..='cd ..'
alias ..-='cd .. && cd -'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias be='bundle exec'
alias cl='clear'
alias cleanup='find . -name '\''*.DS_Store'\'' -type f -ls -delete'
alias d='docker'
import React, { Component } from "react";
function ProductItem({ product }) {
return (
<li>
{product.name} {product.price}
</li>
);
}
@danawoodman
danawoodman / index.js
Last active December 22, 2016 18:19
Example of using WebPack to create frontend assets for a non-SPA (Single Page App) project where you selectively load React components within specific templates.
import MyStuff from 'frontend/components/my-stuff'
module.exports = {
renderStuff(node, props) {
// Wrap in <Provider/> here too if using Redux
ReactDOM.render(<MyStuff {...props} />, node)
}
}
const path = require('path')
const NODE_ENV = process.env.NODE_ENV || 'development'
const outputFile = 'pdfmake.js'
const libraryName = 'pdfmake'
const config = {
entry: './src/browser-extensions/pdfMake.js',
output: {
path: path.join(__dirname, './build'),
@danawoodman
danawoodman / flux-options.md
Last active April 22, 2016 13:39
Flux and Flux-like Options

Flux and Flux-like Options

A non-exhaustive list of flux and flux-like libraries with relevant information and notes.

Library Stars Latest Release
Facebook flux
reflux
fluxxor
marty [](https:/
@danawoodman
danawoodman / pdf.js
Created April 10, 2015 19:41
Example of using pdfkit in Node.js
var fs = require('fs');
var PDFDocument = require('pdfkit');
var pdf = new PDFDocument({
size: 'LEGAL', // See other page sizes here: https://github.com/devongovett/pdfkit/blob/d95b826475dd325fb29ef007a9c1bf7a527e9808/lib/page.coffee#L69
info: {
Title: 'Tile of File Here',
Author: 'Some Author',
}
});
@danawoodman
danawoodman / 0-javascript-cheat-sheet.md
Created April 8, 2015 04:17
JavaScript Cheat Sheet

JavaScript Cheat Sheet

This is intended as a grab bag of tips, shortcuts, reference and otherwise useful information related to JavaScript (and Node.js).

Language Features

bind

Bind is a very useful tool for changing the scope of this within functions as well as passing in parameters:

@danawoodman
danawoodman / 1-react-websockets-reflux.md
Last active August 21, 2024 20:58
Using WebSockets with Reflux and React

WebSockets + Reflux + React

Using WebSockets, React and Reflux together can be a beautiful thing, but the intial setup can be a bit of a pain. The below examples attempt to offer one (arguably enjoyable) way to use these tools together.

Overview

This trifect works well if you think of things like so:

  1. Reflux Store: The store fetches, updates and persists data. A store can be a list of items or a single item. Most of the times you reach for this.state in react should instead live within stores. Stores can listen to other stores as well as to events being fired.
  2. Reflux Actions: Actions are triggered by components when the component wants to change the state of the store. A store listens to actions and can listen to more than one set of actions.
@danawoodman
danawoodman / group-by-hours.js
Last active August 29, 2015 14:16
Group and sum range of hours by the hour
var _ = require('lodash');
var ranges = [
["12:00", 0.0], ["12:15", 0.0], ["12:30", 0.0], ["12:45", 0.0],
["01:00", 0.0], ["01:15", 0.0], ["01:30", 0.0], ["01:45", 0.0],
["02:00", 0.0], ["02:15", 0.0], ["02:30", 0.0], ["02:45", 0.0],
["03:00", 0.0], ["03:15", 0.0], ["03:30", 0.0], ["03:45", 0.0],
["04:00", 0.0], ["04:15", 0.0], ["04:30", 0.0], ["04:45", 0.0],
["05:00", 0.0], ["05:15", 0.0], ["05:30", 0.0], ["05:45", 0.0],
["06:00", 0.0], ["06:15", 0.0], ["06:30", 0.0], ["06:45", 0.0],
@danawoodman
danawoodman / set-interval-mixin.js
Last active November 20, 2017 08:09
set-interval-mixin.js
/*
SetIntervalMixin for React.
Usage:
var MyComponent = React.createClass({
getInitialState: function () {
return { value: 0 };
},