Skip to content

Instantly share code, notes, and snippets.

View indexzero's full-sized avatar
🌎
Always bet on Open Source

Charlie Robbins indexzero

🌎
Always bet on Open Source
View GitHub Profile
test-maxsize in winstonjs/winston $ DEBUG=winston:file npx mocha test/transports/file-maxsize.test.js
winston:file ENOENT ok winstonjs/winston/test/fixtures/logs/testmaxsize.log
winston:file stat done: testmaxsize.log { size: 0 }
winston:file create stream start winstonjs/winston/test/fixtures/logs/testmaxsize.log { flags: 'a' }
winston:file create stream ok winstonjs/winston/test/fixtures/logs/testmaxsize.log
File (maxsize)
winston:file file open ok winstonjs/winston/test/fixtures/logs/testmaxsize.log
winston:file written true 0
@indexzero
indexzero / commits.md
Last active December 21, 2017 14:05
My thoughts on Git commit structure

Git commit prefixes

When possible it is preferable to break up your commits into smaller digestable chunks so that they are more readable during the peer review process. One way to accomplish this is by using a known set of git commit prefixes.

  • [api]: New apis / changes to apis
  • [test]: Update test/* files
  • [dist]: Changes to submodules, version bumps, updates to package.json
  • [tiny]: Small changes#
@indexzero
indexzero / bench.log
Created September 27, 2017 05:37
winston@3 gets very close to pino
Benchmark: ""pino"" is the fastest.
- winston1 faster than winston2 by 1.1696
- winston3 faster than winston1 by 1.5686
- bunyan faster than winston1 by 1.0245
- pino faster than winston1 by 1.8904
- winston3 faster than winston2 by 1.8347
- bunyan faster than winston2 by 1.1983
- pino faster than winston2 by 2.2109
- winston3 faster than bunyan by 1.5311
- pino faster than winston3 by 1.2051
@indexzero
indexzero / i18n-time-intervals.js
Created June 29, 2017 18:33
Generate a 24 hour range of 30-minute time intervals that are i18n compatible
let items = [];
for (var hour = 0; hour < 24; hour++) {
items.push([hour, 0]);
items.push([hour, 30]);
}
const date = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
hour: 'numeric',
minute: 'numeric',
@indexzero
indexzero / injector.js
Created June 22, 2017 20:14
Use static class methods in ES6 to perform lightweight dependency injection / IOC
class Injector {
static register(key) {
this.Components = this.Components || {};
this.Components[key] = key;
console.log(this.Components);
}
passthru(key) {
Injector.register(key);
@indexzero
indexzero / jscs-to-eslint.md
Last active April 8, 2019 07:58
Replacing JSCS with ESlint

ESLint support for autofix has improved considerably in the last 12 months. With jscs being formally deprecated for some time now and the notable problems with JSX autofix interop the time has come to drop it. Below you will find an as close as possible mapping of jscs options to eslint.

This is not a complete file including all the various exceptions and options that eslint needs to mimic the current jscs behavior, but it should illustrate that it is possible and worth pursuing.

{
  "esnext": true,
  "plugins": ["jscs-jsx-rules"],
  "requireCurlyBraces": ["else","for","while","do","try","catch","switch"],
  "requireSpaceBeforeKeywords": ["else","while","catch"],  // keyword-spacing
@indexzero
indexzero / nyc-food-tour.md
Last active October 8, 2016 21:38
A random collection of suggestions from random people on the random Internet

Mexican / Tex-mex

Tacos from Guero's off Franklin. (Fried avocado and jalapeño taco)

Taqueria de Los Muertos- Prospect Heights

Baby Bo's Burritos on 2nd Avenue around 36th Street. Massive margaritas and great Tex-Mex.

Cajun

Cajun: catfish on Bedford Ave. They do giant bloody Mary's with shrimp and hurricanes in hurricane glasses. And they do oysters by the dozen and po boys.

@indexzero
indexzero / extends.js
Last active September 27, 2016 18:31
Implicit constructors do call super() in ES6 classes
'use strict';
class AbstractClass {
constructor() {
this.foo = 'foo';
}
}
class DerivedClass extends AbstractClass {
@indexzero
indexzero / .eslintconfig.json
Last active March 12, 2016 06:55
Demonstration of a subtle ESLint parser conflict with "prefer-const"
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
},
"rules": {
"prefer-const": 2
}
}
@indexzero
indexzero / hack-console.js
Created December 17, 2015 13:00
Fun with hacking console.log in node@4
'use strict';
//
// Attempt #1: Overwrite the log method on the Console
// prototype exposed by node.
//
// !!FAILED!!
//
// var Console = require('console').Console;
//