Skip to content

Instantly share code, notes, and snippets.

View bfncs's full-sized avatar

Marc Löhe bfncs

View GitHub Profile
@andrebrait
andrebrait / keychron_linux.md
Last active December 2, 2023 19:28
Keychron keyboards on Linux + Bluetooth fixes
View keychron_linux.md

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

View ghmatch.clj
#!/usr/bin/env boot
(set-env! :dependencies '[[org.clojure/clojure "1.8.0"]
[http-kit "2.2.0"]
[org.clojure/data.json "0.2.6"]])
(require '[org.httpkit.client :as http])
(require '[clojure.data.json :as json])
(require '[boot.cli :refer [defclifn]])
@Avaq
Avaq / request.js
Last active November 24, 2020 14:42
Request adapted to work with Fluture
View request.js
'use strict';
const request = require('request');
const Future = require('fluture');
module.exports = o => Future((l, r) => {
const socket = request(o, (err, res) => err ? l(err) : r(res));
return () => socket.abort();
});
@andymatuschak
andymatuschak / States-v3.md
Last active November 19, 2023 09:03
A composable pattern for pure state machines with effects (draft v3)
View States-v3.md

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@davestevens
davestevens / LetsEncrypt.md
Last active August 29, 2023 23:35
Let’s Encrypt setup for Apache, NGINX & Node.js
View LetsEncrypt.md

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@conspect
conspect / cult_of_ignorance.md
Last active February 28, 2022 12:01
A Cult Of Ignorance, Isaac Asimov
View cult_of_ignorance.md

It's hard to quarrel with that ancient justification of the free press: "America's right to know." It seems almost cruel to ask, ingeniously, "America's right to know what, please? Science? Mathematics? Economics? Foreign languages?"

None of those things, of course. In fact, one might well suppose that the popular feeling is that Americans are a lot better off without any of that tripe.

There is a cult of ignorance in the United States, and there always has been. The strain of anti-intellectualism has been a constant thread winding its way throughout political and cultural life, nurtured by the false notion that democracy means that "my ignorance is just as good as your knowledge."

Politicians have routinely striven to speak the language of Shakespeare and Milton as ungrammaticaly as possible in order to avoid offending their audiences by appearing to have gone to school. Thus, Adlai Stevenson, who incautiously allowed intelligence and learning and wit to peep out of his speeches, found the American people

@gaearon
gaearon / slim-redux.js
Last active November 19, 2023 10:16
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
View slim-redux.js
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@paulirish
paulirish / what-forces-layout.md
Last active December 1, 2023 15:06
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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
@bitjockey42
bitjockey42 / mopidy.md
Created April 20, 2014 16:39
An installation and setup guide for mopidy on Arch Linux.
View mopidy.md

Mopidy on Arch Linux

mopidy

Installation

Install from the AUR.

@joyrexus
joyrexus / README.md
Last active August 21, 2023 16:59
Node.js streams demystified
View README.md

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.