Skip to content

Instantly share code, notes, and snippets.

View voxpelli's full-sized avatar

Pelle Wessman voxpelli

View GitHub Profile
@AdaRoseCannon
AdaRoseCannon / HTMLElementPlus.js
Last active March 3, 2023 11:33
HTML Element Plus for Web Components
'use strict';
class HTMLElementPlus extends HTMLElement {
static defaultAttributeValue() {
/* the name of the attribute is parsed in as a parameter */
return;
}
static parseAttributeValue(name, value) {
@voxpelli
voxpelli / main.js
Last active April 19, 2022 12:43
A recursive Promise.all() that works on objects
const zipObject = function (keys, values) {
const result = {};
keys.forEach((key, i) => {
result[key] = values[i];
});
return result;
};
@poshaughnessy
poshaughnessy / samsung-internet-versions-rough-guide.md
Last active October 5, 2020 12:53
Rough browser version guide for Samsung Internet

v1.x (v1.0: Chromium 18, v1.5 & v1.6: Chromium 28)

v1 logo

Originally based on the stock Android browser (AOSP), 2012.

"It was around early 2013 when we made [the decision to move to Chromium]. We shipped our first Chromium-based browser in one of the Galaxy S4 models released later in 2013." (Source)

  • v1.0 preloaded in Galaxy S4
  • v1.5 preloaded in Galaxy Note 3
@voxpelli
voxpelli / log-chai-error-with-diff.js
Created July 11, 2016 10:12
This small snippet leverages Mocha's reporter to do proper diffs of Chai assertion errors so that one can log them oneself as well
const mochaList = require('mocha').reporters.Base.list;
const mochaErrorLog = function (err, title) {
mochaList([{
err,
fullTitle: () => title || 'Untitled'
}]);
};
@marick
marick / about_those_lava_lamps.md
Last active June 22, 2022 21:08
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

@viticci
viticci / Selection.py
Created November 19, 2015 13:00
Selection.py
# coding: utf-8
import sys
import html2text
import clipboard
import webbrowser
webpage = clipboard.get()
text = sys.argv[1]
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
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
import org.apache.spark.ml.feature.{CountVectorizer, RegexTokenizer, StopWordsRemover}
import org.apache.spark.mllib.clustering.{LDA, OnlineLDAOptimizer}
import org.apache.spark.mllib.linalg.Vector
import sqlContext.implicits._
val numTopics: Int = 100
val maxIterations: Int = 100
val vocabSize: Int = 10000
@voxpelli
voxpelli / README.md
Last active July 19, 2016 18:36
How to get references to all PR:s on a "git fetch origin" – forgot where I found this, but rediscovered the setup in one of my local repos

In the .git/config file add the fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to the remote you want to fetch references to PR:s from.

@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
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;