Skip to content

Instantly share code, notes, and snippets.

@antonycourtney
antonycourtney / flow-lambda-bug.js
Created March 31, 2017 02:10
Flow data flow analysis loses info under a lambda
/* @flow */
/* Paste this into https://flow.org/try/ to see the bug: */
const f = (lut: ?{[key: string]: number}): number => {
// This correctly notices that we're doing a null check on lut:
const testKey = 'fizz'
const y = (lut != null) ? lut[testKey] : 0
@Saul-Mirone
Saul-Mirone / MVVM.js
Last active May 6, 2024 05:27
A simple mvvm
class Register {
constructor() {
this.routes = []
}
regist(obj, k, fn) {
const _i = this.routes.find(function(el) {
if((el.key === k || el.key.toString() === k.toString())
&& Object.is(el.obj, obj)) {
return el
@Becavalier
Becavalier / Parser.js
Created February 7, 2017 03:14 — forked from Saul-Mirone/MVVM.js
A simple mvvm
class Register {
constructor() {
this.routes = []
}
regist(obj, k, fn) {
const _i = this.routes.find(function(el) {
if((el.key === k || el.key.toString() === k.toString())
&& Object.is(el.obj, obj)) {
return el
@mshwery
mshwery / app.js
Last active May 6, 2024 05:27
Gulp + Browserify + requiring .html templates + Knockout web components
var ko = require('knockout');
ko.components.register('simple-name', require('./components/simple-name/simple-name.js'));
ko.applyBindings({ userName: ko.observable() });
@Becavalier
Becavalier / app.js
Created August 1, 2016 13:29 — forked from mshwery/app.js
Gulp + Browserify + requiring .html templates + Knockout web components
var ko = require('knockout');
ko.components.register('simple-name', require('./components/simple-name/simple-name.js'));
ko.applyBindings({ userName: ko.observable() });
@Becavalier
Becavalier / UglifyJS.TreeTransformer.js
Last active May 6, 2024 05:26
The basic usage of "UglifyJS.TreeTransformer".
const UglifyJS = require('uglify-js');
var symbolTable = {};
var binaryOperations = {
"+": (x, y) => x + y,
"-": (x, y) => x - y,
"*": (x, y) => x * y
}
var constexpr = new UglifyJS.TreeTransformer(null, function(node) {
if (node instanceof UglifyJS.AST_Binary) {

How to get @DevBlackOps Terminal-Icons module working in PowerShell on Windows

Note: since version 0.1.1 of the module this now works in Windows PowerShell or PowerShell Core.

  1. Download and install this version of Literation Mono Nerd Font which has been specifically fixed to be recognised as monospace on Windows:

https://github.com/haasosaurus/nerd-fonts/blob/regen-mono-font-fix/patched-fonts/LiberationMono/complete/Literation%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf

(see this issue for more info: ryanoasis/nerd-fonts#269)

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

attribute highp vec4 a_vertex;
attribute mediump vec2 a_texCoord;
varying mediump vec2 UL;
varying mediump vec2 UR;
varying mediump vec2 DL;
varying mediump vec2 DR;
uniform highp mat4 u_pvmMatrix;
uniform mediump vec2 u_displaySize;
void main()
@kevincennis
kevincennis / v8.md
Last active May 6, 2024 05:25
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • $ nano ~/.zshrc
    • Add path=('/path/to/depot_tools' $path)