Skip to content

Instantly share code, notes, and snippets.

View anthonybrown's full-sized avatar
🎯
Focusing

Tony Brown anthonybrown

🎯
Focusing
View GitHub Profile
@anthonybrown
anthonybrown / myHigherOderFunction.js
Last active June 10, 2019 00:20
An example of functional programing using a higher order function
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 June 10, 2019 00:14
My current vscode settings as of May 2019
{
// 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 / flux.js
Created May 30, 2019 09:34 — forked from acdlite/flux.js
A Redux-like Flux implementation in <75 lines of code
/**
* 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) {
{
"window.zoomLevel": 1,
"editor.formatOnSave": true,
"editor.detectIndentation": true,
"editor.fontSize": 20,
"editor.lightbulb.enabled": false,
"editor.parameterHints.enabled": false,
"editor.fontFamily": "Operator Mono",
"editor.fontLigatures": true,
"editor.rulers": [80],
@anthonybrown
anthonybrown / downscroller.coffee
Created May 25, 2019 05:03 — 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)
## 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 April 13, 2019 13:18 — forked from darsain/ES2017-pull-streams.md
Better streaming interface for modern JavaScript.

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 April 10, 2019 18:56 — forked from pwenzel/lamp-stack-osx-virtualhostx.md
LAMP stack on OSX with Homebrew, built-in Apache, multiple PHP versions, VirtualhostX optional

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
@anthonybrown
anthonybrown / index.html
Created March 4, 2019 22:30
My Calculator App
<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 March 2, 2019 11:02 — forked from lhorie/longest-keyword-sequence.md
What's the longest keyword sequence in Javascript?
@anthonybrown
anthonybrown / createQueue.js
Last active December 4, 2018 21:01
Using a Queue to contain our data structure, use a queue. Create a function that returns our data in a plain old Object. A queue is a collection of items that obey's the principle of FIFO, first in, first out.
function createQueue() {
// store our queue
const queue = []
return {
// add or enqueue
enqueue(item) {
queue.unshift(item)
},
// remove or dequeue