Skip to content

Instantly share code, notes, and snippets.

View mikeal's full-sized avatar
🏠
Working from home

Mikeal Rogers mikeal

🏠
Working from home
View GitHub Profile
@mikeal
mikeal / package.json
Created April 24, 2018 22:34
Dev script for package.json Vue.js Electron demo.
{ "scripts":
{ "dev": "NODE_ENV=DEV vue-cli-service serve & sleep 5 && NODE_ENV=DEV electron app.js" }
}
@mikeal
mikeal / app.js
Created April 24, 2018 22:32
Application file for Vue.js Electron demo app.
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let url
if (process.env.NODE_ENV === 'DEV') {
url = 'http://localhost:8080/'
} else {
url = `file://${process.cwd()}/dist/index.html`
}
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let url
if (process.env.NODE_ENV === 'DEV') {
url = 'http://localhost:8080/'
} else {
url = `file://${process.cwd()}/dist/index.html`
}
@mikeal
mikeal / gist:2504336
Created April 27, 2012 00:11
Date parsing JSON
JSON._dateReviver = function (k,v) {
if (v.length !== 24 || typeof v !== 'string') return v
try {return new Date(v)}
catch(e) {return v}
}
JSON.parseWithDates = function (obj) {
return JSON.parse(obj, JSON._dateReviver);
}
@mikeal
mikeal / byteStorage.js
Last active July 18, 2017 22:09
Potentially a better way to design streaming byte storage.
// Byte Storage as Content Addressable Storage
class ByteStorage {
async set (key, value) async {
// Send to temporary storage w/ random UUID
let tmpfile = randomFile()
let p1 = send(value, tmpfile)
// Also stream the value to a hasher
let p2 = send(value, /* streaming hashing function */ )
let values = await Promise.all(p1, p2)
@mikeal
mikeal / gist:8947417
Created February 12, 2014 00:27
NPM history.

[In reply to https://news.ycombinator.com/item?id=7219005]

Here's the history, hope it helps.

I wrote the original version of the npm registry in a day or two on top of CouchDB. I built it quickly and didn't think much about scale.

Isaacs continued to improve and maintain that code. At one point he even wrote up an open standard for generic js package registries for CommonJS but they didn't seem to care (they were too busy arguing about promises).

At the time I wrote the initial code I was employed at CouchOne and we had a small CouchDB hosting platform operated by Jason Smith which is where we ran the registry free of charge. Later on, after CouchOne was aquired by Membase and became Couchbase, it decided to break off the hosting company and give/sell it to Jason Smith, which became IrisCouch.

@mikeal
mikeal / bread.md
Created February 7, 2017 04:29
My Bread

| Ingredient | Measure | Baker's Percentage | | Sifted White Flour (Red Fife) | 500g | 100% | | Water | | 70% | | Active Levain | 100g | 20% | | Salt | 11g | | |

package deps maintainers
phpunit/phpunit 7319 sebastian
symfony/framework-bundle 2431 fabpot
illuminate/support 2361 taylorotwell
symfony/symfony 1414 fabpot
mockery/mockery 1386 padraicb
doctrine/orm 1208 beberlei
symfony/console 1127 fabpot
symfony/yaml 1117 fabpot
composer/installers 1115 Seldaek, shama
for (var key in {one:'two'}) {
if (key === 'one') {
console.log(key)
}
}
@mikeal
mikeal / gist:7897206
Created December 10, 2013 20:01
Animals for slaughter.

Children are created, raised, cared for and we hope that they will live a long and proud life only to end long after their creator's has ended. They are their creator's legacy.

Your code is not your child, it is an animal raised for slaughter. Your code will die. It will die before your death. Your code's entire purpose is to die. Your code enables some new function and if successful that new function will grow, it will mature, it will eventually outlive the usefullness you've provided. When successful your code creates value that outlives it and the faster the better. When unsuccessful a mercy killing is most appropriate.

Believing that our code is our children makes us territorial, protective. Nobody is allowed to kill it, only improve it. The idea that our code can be perfect, that it can change to handle so many new concerns leads to the birth of frameworks and plugin systems. These systems brutalize creativity by forcing new value to conform to the standards of our aging children.