Skip to content

Instantly share code, notes, and snippets.

@naugtur
naugtur / GetOptimizationStatus.md
Created August 9, 2019 21:08 — forked from justjavac/GetOptimizationStatus.md
V8 %GetOptimizationStatus

%GetOptimizationStatus return a set of bitwise flags instead of a single value, to access the value, you need to take the binary representation of the returned value. Now, for example, if 65 is returned, the binary representation is the following:

(65).toString(2).padStart(12, '0');
// 000001000001

Each binary digit acts as a boolean with the following meaning:

function getCache(name) {
return new Promise((resolve, reject) => {
const version = 1;
const request = indexedDB.open(name, version);
request.onsuccess = event => {
const db = event.target.result;
/*
* Returns a Promise that resolves with an object
@KiaraGrouwstra
KiaraGrouwstra / stdlib.ts
Last active March 24, 2020 03:17
Type-level standard library for TypeScript
// NOTE: code now moved to https://github.com/tycho01/typical
// older revision left here, but it no longer runs well in TS Playground
export type Obj<T> = { [k: string]: T };
export type NumObj<T> = { [k: number]: T };
// export type List = ArrayLike; // no unapplied generic types :(
export type List<T> = ArrayLike<T>;
// progress: https://github.com/Microsoft/TypeScript/issues/16392
export function force<T, V extends T>() {}
@onnimonni
onnimonni / s3.tf
Created March 13, 2017 10:03
s3 replicated bucket with terraform
# Create all variables used in this Terraform run
variable "aws_access_key" {}
variable "aws_access_secret_key" {}
variable "aws_bucket_name" {}
variable "aws_region_main" {
default = "eu-west-1"
}
variable "aws_region_replica" {
default = "eu-central-1"
}
@fdecampredon
fdecampredon / gist:9687b27904d1eb25757a
Last active August 29, 2015 14:09
possible rx-react events integration
// in this first option events handlers are just RxJs functor Subject
// those subject are passed down to the render function and are manually injected into
// the properties of react component
var RxReact = require('rx-react');
var React = require('react');
@jas-
jas- / example.js
Last active October 4, 2017 19:19
crypto.createSign() using DH private key use case
/* Bob's environment */
var crypto = require('crypto');
var rsa = require('ursa');
crypto.DEFAULT_ENCODING = 'hex'
var dhBob = crypto.getDiffieHellman('modp18')
, kBob = dhBob.generateKeys()
, keysBob = {
pubKey: dhBob.getPublicKey(),
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu