Skip to content

Instantly share code, notes, and snippets.

Tony Brown anthonybrown

Block or report user

Report or block anthonybrown

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@anthonybrown
anthonybrown / create-react-component.js
Last active Jun 18, 2019 — forked from rastating/create-react-component.js
A script to create the boilerplate code for a new React.js component with a [Jest] spec file
View create-react-component.js
#! /usr/bin/env node
# Usage: node create-react-component.js ComponentName
# Note: If a `components` directory does not exist in the current working directory, nothing will be created
const fs = require('fs')
const path = require('path')
const componentName = process.argv[2]
const componentPath = path.join(
'components',
componentName
View api-cheatsheet-array.md

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array<T[] | T>): T[] 🔒 ES3
@anthonybrown
anthonybrown / flux.js
Created May 30, 2019 — forked from acdlite/flux.js
A Redux-like Flux implementation in <75 lines of code
View flux.js
/**
* Basic proof of concept.
* - Hot reloadable
* - Stateless stores
* - Stores and action creators interoperable with Redux.
*/
import React, { Component } from 'react';
export default function dispatch(store, atom, action) {
@anthonybrown
anthonybrown / myHigherOderFunction.js
Last active Jun 10, 2019
An example of functional programing using a higher order function
View myHigherOderFunction.js
let formatCurrency = function( currencySymbol, decimalSeparator ) {
return function( value ) {
let wholePart = Math.trunc(value / 100);
let fractionalPart = value % 100;
if ( fractionalPart < 10 ) fractionalPart = '0' + fractionalPart;
return `${currencySymbol}${wholePart}${decimalSeparator}${fractionalPart}`;
}
}
let formatter = formatCurrency( '$', '.' );
@anthonybrown
anthonybrown / vscode.json
Last active Jun 10, 2019
My current vscode settings as of May 2019
View vscode.json
{
// Place your settings in this file to overwrite the default settings
"window.zoomLevel": 1,
"editor.formatOnSave": true,
"editor.detectIndentation": true,
"editor.fontSize": 18,
// "editor.lightbulb.enabled": false,
"editor.parameterHints.enabled": false,
"editor.fontFamily": "Operator Mono",
"editor.fontLigatures": true,
@anthonybrown
anthonybrown / downscroller.coffee
Created May 25, 2019 — forked from zwily/downscroller.coffee
Puts a big annoying arrow in your Limechat window when you're not scrolled down, like a dummy. (requires limescripts)
View downscroller.coffee
## Puts a big annoying arrow in your window when you're not scrolled down, like a dummy
#
scrollAlert = $("<div id='scrolldown-arrow'>⬇</div>")
showing = false
body = $ document.body
win = $ window
doc = $ document
@anthonybrown
anthonybrown / ES2017-pull-streams.md
Created Apr 13, 2019 — forked from darsain/ES2017-pull-streams.md
Better streaming interface for modern JavaScript.
View ES2017-pull-streams.md

Better streaming interface for modern JavaScript

Node streams have a lot of issues. Awkward to control backpressure, no error propagation, overcomplicated implementation impenetrable to any view source attempts, etc...

To solve this, here is an implementation of pull-streams in modern JS, using promises, async iterators, and for..await loops.

Features:

  • Built in backpressure.
  • Build in error propagation.
@anthonybrown
anthonybrown / lamp-stack-osx-virtualhostx.md
Created Apr 10, 2019 — forked from pwenzel/lamp-stack-osx-virtualhostx.md
LAMP stack on OSX with Homebrew, built-in Apache, multiple PHP versions, VirtualhostX optional
View lamp-stack-osx-virtualhostx.md

This guide shows how to set up a PHP and MySQL development environment using OSX's built-in Apache, using Homebrew to install necessary components. With this strategy, you can use different versions of PHP for certain virtual hosts.

VirtualHostX is a convenient way to manage development sites, but not required.

Install PHP and MySQL with Homebrew

brew update
brew install php56
brew install php56-mcrypt
brew install mysql
View index.html
<html>
<link href='https://fonts.googleapis.com/css?family=Electrolize' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<head>
<title>Calculator App</title>
</head>
<body>
@anthonybrown
anthonybrown / longest-keyword-sequence.md
Created Mar 2, 2019 — forked from lhorie/longest-keyword-sequence.md
What's the longest keyword sequence in Javascript?
View longest-keyword-sequence.md
You can’t perform that action at this time.