Skip to content

Instantly share code, notes, and snippets.

View jkrems's full-sized avatar
Modules. Modules everywhere.

Jan Olaf Martin jkrems

Modules. Modules everywhere.
View GitHub Profile

Manual linking together of -wd and -core:

import initTestium from 'testium-core';
import createDriver from 'testium-driver-wd';
import {test} from 'tap';

test('my test', async t => {
  let b = await initTestium().then(createDriver);
  await b.navigateTo('/foo');
@jkrems
jkrems / base.js
Last active October 13, 2015 17:38
(Potential) Groupon Javascript Styles, based on https://github.com/airbnb/javascript
{
// babel-style base rules
"extends": "airbnb/base",
"rules": {
// This allows things like `reduce((a, b) => a + b)`
// Not 100% sure if that's worth the potential cost of badly named identifiers
"id-length": 0
}
}
@jkrems
jkrems / npub.md
Last active November 13, 2015 22:10
Make `npub` great again

npub publish [ <version> ]

Options:

  • -t/--test command - alternate test suite command. default: npm test
  • <version> - 1.2.3; or, for auto increments: patch, minor, major
  • If <version> is not specified, npub will try to deduce it from the Github PRs that were merged, using semver-minor style labels.
  1. Verify: No uncommitted changes
  2. Switch to release branch
@jkrems
jkrems / gofer-v3.md
Last active April 19, 2016 21:10
Gofer v3

Gofer v3

The following is just a proposal & not yet finished.

The biggest change in 3.x is that gofer no longer uses request behind the scenes. Also we're trying to align the interface more closely with fetch. Whenever we return a promise, it will be Bluebird-flavored.

Simple fetch-style usage:

@jkrems
jkrems / local-react-native.md
Created May 11, 2016 20:47
Local react-native

Installing project specific tools like react-native globally is yucky. Even when it's just thin CLI wrappers. Unfortunately react-native actively breaks local npm binaries by forcing a broken bin stub into each project. So if you added ./node_modules/.bin to your $PATH, every attempt of running react-native inside of a project will fail with an annoying (and wrong) claim that you installed react-native globally.

The easiest solution I found so far:

  • npm install --save react-native-cli in your React Native project

Getting seconds or milliseconds since January 1, 1970, 00:00:00 GMT in various languages

Second-Native

C (1972)

// ms
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
// V8 6.2 required
'use strict';
const fs = require('fs');
const { Session } = require('inspector');
const { promisify } = require('util');
const session = new Session();
if (session != null) {
session.connect();
@jkrems
jkrems / .gitignore
Last active December 9, 2017 03:49
dynamic-import-require
node_modules
@jkrems
jkrems / es-module-history.md
Last active March 16, 2025 13:43
History of ES modules

Modules - History & Future

History

@jkrems
jkrems / background-json-parse.js
Created March 6, 2018 16:59
JSON.parse w/o blocking main thread
'use strict';
const ivm = require('isolated-vm');
function handleParseJob(code) {
return new ivm.ExternalCopy(JSON.parse(code), { transferOut: true });
}
function transferInExternalCopy(copy) {
return copy.copy({ transferIn: true });