Skip to content

Instantly share code, notes, and snippets.

class Intersector extends HTMLElement {
constructor() {
super();
const threshold = 0;
var options = {
root: this.parentElement,
rootMargin: "-40% 0% -59%",
threshold: [threshold]
};
@janwirth
janwirth / elmapp.config.js
Created March 12, 2019 09:07
Edit babel configuration in create-elm-app
module.exports = {
configureWebpack: (config, env) => {
const rules = config.module.rules
rules
.map(r => {
// find js rule
if (r.test && r.test.toString().indexOf('js') > -1) {
// find the rule with the actual babel config
if (r.use) {
r.use[0].options.plugins = r.use[0].options.plugins || []
function makeElmCompatible () {
// Prevent content editable from deleting the text node that elm renders to
document.addEventListener('keydown', event => {
const zeroWidthSpace = '​'
// only for content editable
if (event.target.contentEditable !== 'true') {
return
}
// prevent deletion of last character and replace with zero width space instead
if (event.key === 'Backspace') {

Books

  • negotiate like your life depends on it
  • throwing rocks at the google bus
  • kopf schlägt kapital OK
  • an der freiheit des anderen kommt keiner vorbei OK
  • elegant objects OK
  • the war on normal people
  • Kinder der Ewigkeit OK
  • das kalte herz
  • wenn die liebe fremdgeht
console.log('hi')
type Focus<T, T2> = (obj: T) => T2
const setIn = <T, T2>(expr: Focus<T, T2>) => (obj: T) => {
// convert path to array of strings
const propAccess = /\.([A-Za-z](\.[A-Za-z])*)/
const path: string[] = expr.toString()
.match(propAccess)[1]
.split('.')
console.log('hi')
type Focus<T, T2> = (obj: T) => T2
const setIn = <T, T2>(expr: Focus<T, T2>) => (obj: T) => {
// convert path to array of strings
const propAccess = /\.([A-Za-z](\.[A-Za-z])*)/
const path: string[] = expr.toString()
.match(propAccess)[1]
.split('.')
@janwirth
janwirth / stalk.js
Created July 23, 2018 13:34
Monitor a person's whatsapp online status. Use with whatsapp web.
const STATUS_SPAN_SELECTOR = '.O90ur'
function record(data)
{
var a = [];
// Parse the serialized data back into an aray of objects
a = JSON.parse(localStorage.getItem('session') || '[]');
// Push the new data (whether it be an object or anything else) onto the array
a.push(data);
// Alert the array value
@janwirth
janwirth / dsgvo.md
Last active May 24, 2018 09:52
DSGVO

Musterdatenschutzerklärung für Websitebetreiber nach den Vorgaben der DSGVO

Erläuterung zur Musterdatenschutzerklärung

Die folgende Musterdatenschutzerklärung ist als Grundgerüst für eine der EU-Datenschutzgrundverordnung (DSGVO) konforme Datenschutzerklärung für Websitebetreiber zu verstehen. Die Erklärung ist nicht abschließend und umfasst nicht alle erforderlichen Elemente. Zudem können in der

@janwirth
janwirth / kak_extract_rule
Created April 26, 2018 18:58
Kakoune extract rule from parse tree syntax
Zf.lf<space>Hyo<esc>F<esc>PA<space><minus><gt><space><esc>zf[f.lf<space>Hyjpzf[mf.lf<space>HyjA<space><esc>pkhhz
@janwirth
janwirth / fuzzy-file-duplicate-finder
Created January 8, 2018 20:27
Find fuzzy duplicates in a list
import levenshtein from 'fast-levenshtein';
import { filter, join, isEmpty, sortBy, get, identity, flow, map, toLower } from 'lodash/fp'
// https://stackoverflow.com/questions/43241174/javascript-generating-all-combinations-of-elements-in-a-single-array-in-pairs
function getCombinations(array) {
var results = [];
// Since you only want pairs, there's no reason
// to iterate over the last element directly
for (var i = 0; i < array.length - 1; i++) {