Skip to content

Instantly share code, notes, and snippets.

View jbreckmckye's full-sized avatar

Jimmy Breck-McKye jbreckmckye

View GitHub Profile

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['■','●','▲'].slice(1, 3)           ['●','▲']
['■','●','■'].filter(x => x==='■')  ['■','■']
    ['▲','●'].map(x => x+x)         ['▲▲','●●']
    ['▲','●'].flatMap(x => [x,x])   ['▲','▲','●','●']
JulianG / createStrictContext.js
Created August 9, 2020 14:07
Create React Strict Context
import React from 'react';
export function createStrictContext(options = {}) {
const Context = React.createContext(undefined);
Context.displayName =;
function useContext() {
const context = React.useContext(Context);
if (!context) {
throw new Error(options.errorMessage || `${name || ''} Context Provider is missing`);
MichaelCurrin /
Last active May 16, 2024 12:45
GitHub GraphQL - Get Pull Requests using GH's GraphQL API

Get Pull Requests using GH's GraphQL API

How to get Pull Requests data using Github in the browser, or using the API to allow for automating reporting or building in values into a website.


import { createHash, randomBytes } from 'crypto';
import * as request from 'request';
* The configuration object
* @export
* @interface IAuthServiceConfig
export interface IAuthServiceConfig {
adeperio / AuthService.js
Last active January 8, 2022 20:06
PKCE flow in Electron with Passwordless. In ES6 + flow + request-promise. Executes PKCE through the Electron BrowserWindow
import request from 'request'
import crypto from 'crypto'
import rp from 'request-promise'
export type AuthServiceConfig = {
authorizeEndpoint: string,
clientId: string,
audience: string,
scope: string,
  • The benchmarks used by Marko, with one benchmark containing only a single component with ~50 lines of code, and the other 3 components with one of them fully static markup, are typical micro-benchmarks created to the advantage of certain implementation details. They are too isolated and too trivial to justify across-the-board performance claims.

  • For client-side performance I recommend using the 3rd party js-framework-benchmark as a more neutral reference; the benchmark tests a much bigger workload and covering a much more comprehensive performance scenarios. According to the data from the latest round Vue actually outperforms Marko. That said, even this benchmark doesn't reflect real world performance where much more overhead comes from big component trees.

  • Vue has significantly improved SSR performance for

kl0tl / raven.js
Created December 15, 2016 13:39
Load Raven async
(function (global, document, url) {
var calls = [];
var spy = {};
var methods = ['config', 'install', 'setUserContext', 'captureException'];
for (var i = 0, method; method = methods[i]; i += 1) {
spy[method] = (function (name) {
return function () {
calls.push([name, arguments]);
return this;
JamieMason / .babelrc
Created December 5, 2016 08:41
Tree-Shaking with Babel 6, Webpack 2, and React.
"presets": [
["es2015", {
"es2015": {
"loose": true,
"modules": false
}], "react"
Xaekai / ipc.example.js
Created July 11, 2016 18:12
Example of Interprocess communication in Node.js through a UNIX domain socket
** Example of Interprocess communication in Node.js through a UNIX domain socket
** Usage:
** server> MODE=server node ipc.example.js
** client> MODE=client node ipc.example.js
Restuta /
Last active March 7, 2024 00:01
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js