Skip to content

Instantly share code, notes, and snippets.

@totherik
totherik / gist:3a4432f26eea1224ceeb
Last active April 9, 2024 00:46
v8 --allow-natives-syntax RuntimeFunctions
Per https://code.google.com/p/v8/codesearch#v8/trunk/src/runtime.cc
%CreateSymbol
%CreatePrivateSymbol
%CreateGlobalPrivateSymbol
%NewSymbolWrapper
%SymbolDescription
%SymbolRegistry
%SymbolIsPrivate
@totherik
totherik / csr.js
Created April 7, 2017 19:12
Compressed Sparse Row (CSR) Matrix
// https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29
function csr(matrix) {
const A = [];
const IA = [0];
const JA = [];
const nnz = [];
for (const [ index, row ] of matrix.entries()) {
nnz[index] = 0;
@totherik
totherik / gist:3308181
Created August 9, 2012 21:24
NodeJS improved inherits and mixin
'use strict';
var util = require('util');
/**
* Combines objects in reverse order of provided arguments. The right-most
* object's properties are copied to the left, and so on.
* @param {Object} dest the destination object
* @return {Object} the destination object
*/
/**
* A simple (and I assume fairly slow) function for generating a unique selector for a given element.
* @param element
* @returns {string}
*/
function generateSelector(element) {
let selector = [];
let root = document.body.parentElement;
while (element && element !== root && !element.id) {
@totherik
totherik / gist:5158013
Last active March 11, 2016 20:04
GitHub Emoji

These are the emoji supported by GitHub as of today (20130313).

See comments.

@totherik
totherik / 0-index.js
Last active January 2, 2016 20:29
kraken-js API brainstorm
'use strict';
var kraken = require('kraken-js'),
otherapp = require('./lib/otherapp');
var delegate, myapp;
delegate = { /* delegate ... */ };
/**
@totherik
totherik / gist:3379924
Created August 17, 2012 15:31
Profiling JavaScript in V8
$ git clone git://github.com/v8/v8.git v8 && cd v8
$ make dependencies # or mkdir build/gyp && git clone git://github.com/svn2github/gyp.git build/gyp
$ make native # (or the like: `$ make ia32`, etc)
$ out/native/d8 --prof 'test.js' # generates 'v8.log'
$ tools/mac-tick-processor # processes the generated 'v8.log'

Additional d8 options

@totherik
totherik / gist:3305270
Created August 9, 2012 15:41 — forked from pguillory/gist:729616
Hooking into Node.js stdout
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
process.nextTick(function() {
callback(string, encoding, fd)
});
@totherik
totherik / npm-git-exe
Created May 4, 2012 16:52
Set npm config to exe in Windows
npm config set "git" "C:\\path\to.exe"
@totherik
totherik / ssh-agent
Created May 4, 2012 16:51
Start ssh agent from Git Bash to store creds for bash session.
exec ssh-agent /bin/sh --login -i
ssh-add