Skip to content

Instantly share code, notes, and snippets.

View barnslig's full-sized avatar

Leonard barnslig

  • Hamburg, Germany
View GitHub Profile
@barnslig
barnslig / Dockerfile
Last active May 19, 2018 10:28
compiler construction!
FROM ubuntu:artful
RUN apt-get update \
&& apt-get -y install build-essential llvm-4.0 clang libedit-dev libgmp-dev bison flex libz-dev ghc curl \
&& curl -sSL https://get.haskellstack.org/ | sh \
&& stack --resolver lts-8.13 --install-ghc install BNFC alex happy \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get -y install cmake libgtest-dev \
@barnslig
barnslig / blocklist.txt
Last active February 18, 2020 07:31
Nachrichtenseiten Drunterkommentare-Blockliste für uBlock
! zeit teaser comment count
zeit.de##.js-update-commentcount
! zeit main teaser
zeit.de##.teaser-classic__metadata *:nth-last-child(2):after
zeit.de##.teaser-dossier__metadata *:nth-last-child(2):after
zeit.de##.teaser-fullwidth__metadata *:nth-last-child(2):after
zeit.de##.teaser-large__metadata *:nth-last-child(2):after
zeit.de##.teaser-small-minor__metadata *:nth-last-child(2):after
zeit.de##.teaser-small__metadata *:nth-last-child(2):after
import React from 'react';
import PropTypes from 'prop-types';
/**
* React component that keeps you up to date about navigator.onLine
*
* @example
* <Online>
* {isOnline => (isOnline ? <span>online!</span> : <span>offline!</span>)}
* </Online>
@barnslig
barnslig / schema.graphql
Last active January 15, 2019 00:29
GraphQL schema representing media.ccc.de
# An ISO 8601 encoded date string.
scalar Date
# An ISO 8601 encoded UTC date string.
scalar DateTime
# An RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI string.
scalar URI
# An object with an ID.
@barnslig
barnslig / redux-watch.js
Last active June 19, 2019 13:30
Subscribe to changes of part of a redux tree
import get from "lodash.get";
import isEqual from "lodash.isequal";
/**
* Subscribe to changes of part of a redux tree
*
* @example
* watch(Store, "dataset.currentId", id => {
* console.log(id);
* });
/**
* Turn an array into chunks
*
* @param {Array} arr - Array that should be chunked
* @param {number} size - Chunk size
* @returns {Array} Array of Arrays where each array has at max `size` elements
*/
const chunkify = (arr, size) =>
arr.reduce(
(acc, cur) =>
<?php
use Ds\Map;
use Ds\Vector;
/**
* JSON de-/encoder that throws on error and decodes into PHP Data Structures
*/
final class JSON
{
import get from 'lodash.get';
/**
* Subscribe partially to redux store changes
*
* @example
* subscribe(store, "backup.url", (state, prevState) => console.log("change!", state, prevState));
*
* @param {Redux.Store} store - Redux store
* @param {String} path - Path within the store object that should be watched for change. See https://lodash.com/docs/4.17.15#get
@barnslig
barnslig / bad.vue
Last active May 8, 2020 12:22
Vue.js: watch vs computed
<script>
export default {
props: {
foobar: {
type: String,
required: true
}
},
data() {
/**
* Parse a duration string
*
* A duration string is a sequence of decimal numbers, each with optional
* fraction and a unit suffix such as "300ms", "1.5h", "2h45m12s" etc.
*
* Valid units are: "h", "m", "s", "ms"
*
* A decimal without unit is considered to be a second, e.g. "1m13" === "1m13s".
*