Skip to content

Instantly share code, notes, and snippets.

View Haprog's full-sized avatar

Kari Söderholm Haprog

View GitHub Profile
@treshugart
treshugart / example.js
Last active May 6, 2024 05:01
Pseudo shadow DOM at the custom element level. When element is updated, `childNodes` is set, thus it's a single entry point for updates. Custom distribution is required.
/** @jsx h */
// You only need custom elements for this!!!
import 'skatejs-web-components/src/native-shim';
import { Component, define, h, prop } from 'skatejs';
import ShadowNode, { scopeCss, scopeTree } from './shadow-node';
// Converts real DOM nodes into Incremental DOM nodes.
//
// This is orthogonal to this gist, but makes it so we can distribute real
@marians
marians / Chromium Linux.md
Last active April 25, 2025 13:36
How to install CA certificates and PKCS12 key bundles on different platforms

We install certutil and pk12util if necessary:

sudo apt install libnss3-tools

On Linux, Chromium uses the NSS Shared DB. Check if you have the ~/.pki/nssdb directory:

ls $HOME/.pki/nssdb
@idleberg
idleberg / atom-macos-context-menu.md
Last active April 27, 2022 00:37
“Open in Atom” in macOS context-menu

Open in Atom

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /usr/local/bin/atom -n "$@"
  • Set “Pass input” to as arguments
  • Save as Open in Atom
@justin-lau
justin-lau / loadScriptsIntoBrowser.js
Created October 5, 2016 07:31
ES6 style helper functions to load scripts into browser from the developer console.
/**
* Load a script by injecting a `<script>` element to the DOM `<head>`.
*
* @param {string} src - the URI to fetch the script from
* @return {Promise} that gets resolved once the script is loaded.
*/
function loadScriptIntoBrowser(src) {
return new Promise((resolve) => {
const scriptNode = document.createElement('script');
scriptNode.src = src;
@wesbos
wesbos / commit-msg
Created July 4, 2016 18:55
ESLint 3.0 Git Pre Commit Hook
#!/bin/bash
files=$(git diff --cached --name-only | grep '\.jsx\?$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
failed=0
for file in ${files}; do
@paulirish
paulirish / what-forces-layout.md
Last active November 7, 2025 17: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
#!/bin/bash
# This script builds (a subset of) the AlkuThree-Light font
# from source files made public by Opetushallitus (oph.fi).
# Whether or not this infringes on copyrights or other rights
# is anyone's guess.
#
# Prerequisites: wget & fontforge
# Optionally: fonttools (ttx) for repeatable builds
# (sha1 should probably be 5d2eba6728246b7050500b3c8cac4780f99f4728)
@nickrussler
nickrussler / Example.java
Last active February 11, 2022 16:01
String replace with callback in Java (like in JavaScript)
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
String result = StringReplacer.replace("Hello World!", Pattern.compile("\\d+"), m -> ("" + (Integer.parseInt(m.group()) * 2));
}
}
@samgiles
samgiles / flatMap.js
Created June 20, 2014 11:32
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
@MattWilcox
MattWilcox / build_nginx.sh
Last active March 6, 2022 18:01
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/usr/bin/env bash
# names of latest versions of each package
export VERSION_PCRE=pcre-8.38
export VERSION_OPENSSL=openssl-1.0.2d
export VERSION_NGINX=nginx-1.9.7
# URLs to the source directories
export SOURCE_OPENSSL=https://www.openssl.org/source/
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/