Skip to content

Instantly share code, notes, and snippets.

View jabez128's full-sized avatar

haoran jabez128

View GitHub Profile
@bellbind
bellbind / eigenvalues.js
Last active December 27, 2021 17:37
[javascript] compute eigenvalues with QR method and Householder Trans
"use strict";
// helpers
function mat2d(mat) {
const n = Math.sqrt(mat.length);
return Array.from(Array(n), (_, i) => mat.slice(i * n, i * n + n));
}
function range(n, f = v => v) {
return Array.from(Array(n), (_, i) => f(i));
}
@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active April 17, 2024 22:50
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2024 14:42
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@dbankier
dbankier / gulpfile.js
Created July 6, 2015 08:27
Nativescript with Jade, SCSS and Babel
// modified from this: https://github.com/emiloberg/nativescript-emulator-reload
// all sources
var babelSrc = [ 'src/**/*.js', '!src/tns_modules', '!src/tns_modules/**', '!src/node_modules', '!src/node_modules/**' ];
var jadeSrc = [ 'src/**/*.jade' ];
var sassSrc = [ 'src/**/*.scss' ];
var resources = [ 'src/{App_Resources,tns_modules,node_modules}/**', 'src/package.json'];
// Which emulator to run?
@paulirish
paulirish / bling.js
Last active February 20, 2024 14:11
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
/** @jsx React.DOM */
var ReadingTimeWidget = React.createClass({
getInitialState: function() {
return ({
secondsRequired: null,
});
},
componentWillMount: function() {
var cdiv = this.props.contentDiv;
@staltz
staltz / introrx.md
Last active April 20, 2024 14:15
The introduction to Reactive Programming you've been missing
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->