Skip to content

Instantly share code, notes, and snippets.

View edef1c's full-sized avatar

edef edef1c

  • Earth
View GitHub Profile
@edef1c
edef1c / default.nix
Last active July 12, 2023 10:09
NixOS module for qemu-user binfmt_misc
{ pkgs, ... }:
let inherit (pkgs) stdenv qemu getopt; in
{
systemd.additionalUpstreamSystemUnits = [
"proc-sys-fs-binfmt_misc.automount"
"proc-sys-fs-binfmt_misc.mount"
];
environment.etc."binfmt.d/qemu-user.conf".source = stdenv.mkDerivation {
name = "qemu-binfmt";
inherit (qemu) src;
@edef1c
edef1c / playground.rs
Created February 17, 2019 16:08
for .. { .. } else { .. } macro for Rust
macro_rules! for_expr {
( $lhs:pat in $iter:ident $body:block else $else:block ) => {
for_expr!($lhs in ($iter) $body else $else)
};
( $lhs:pat in ($iter:expr) $body:block else $else:block ) => {{
let mut iter = ::core::iter::IntoIterator::into_iter($iter);
if let Some(mut item) = iter.next() {
loop {
let $lhs = item;
let result = $body;
@edef1c
edef1c / default.nix
Last active February 3, 2019 18:25
the software for Glasgow, the Scottish Army Knife for electronics, packaged for Nix
{ python3Packages, fetchgit, fetchFromGitHub, sdcc, makeWrapper, yosys, nextpnr, icestorm }:
let
self = python3Packages // (with self; {
fx2 = buildPythonPackage rec {
pname = "fx2";
version = "0.6";
src = fetchPypi {
inherit pname version;
sha256 = "c2126cd9fff71e399d664ac0e40958d609e80209ac8950b4e2ca07d2e8fb06d9";
};
@edef1c
edef1c / default.nix
Last active April 20, 2022 06:32
DNS-over-HTTPS module for NixOS
{ pkgs, ... }:
let
doh-proxy = pkgs.callPackage ./doh-proxy.nix {};
in {
systemd.sockets.doh-stub = {
wantedBy = [ "sockets.target" ];
socketConfig.Service = "doh-stub.service";
socketConfig.ListenDatagram = "[::1]:53";
};
systemd.services.doh-stub = {
@edef1c
edef1c / gpg-export-ssh-keys
Last active August 18, 2019 05:03
convert PGP authentication subkeys to OpenSSH authorized_keys format, discarding expiry information
#!/usr/bin/env bash
set -ue
if [ $# -ne 1 ]; then
echo "usage: $0 [exact PGP user ID]"
exit 255
fi
gpg --with-colons -k "=$1" |\
awk -F: '$1 == "sub" && $2 ~ /^[fu]$/ && $12 ~ /a/ { getline; print $10"!" }' |\

Keybase proof

I hereby claim:

  • I am edef1c on github.
  • I am edef (https://keybase.io/edef) on keybase.
  • I have a public key ASCPm4ELwf7Iypg_CxFDa4Gw8UP-gjK3OR7SPvH_jEtN2Qo

To claim this, I am signing this object:

@edef1c
edef1c / Makefile
Last active January 19, 2016 15:14
all: env
install: env
install -D env $(out)/bin/env
@edef1c
edef1c / binfmt_dispatch.go
Last active January 22, 2016 22:43
NixOS module: dispatch PE execution to either WINE or Mono based on whether it is a CLR executable
package main
import (
"debug/pe"
"errors"
"fmt"
"os"
"syscall"
)
@edef1c
edef1c / config-security
Last active August 29, 2015 14:12
Sane security defaults for SSH clients. Disables everything old and nasty.
# vim: ft=sshconfig
# Sane security defaults for SSH clients. Disables everything old and nasty.
# Unfortunately, SSH appears to provide no way to *exclude* old protocols,
# so we have a list of known-secure key exchange algorithms, symmetric ciphers,
# and message authentication codes.
# Config taken from [https://stribika.github.io/2015/01/04/secure-secure-shell.html]
Host *
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
@edef1c
edef1c / talk-proposal.md
Last active August 29, 2015 14:07
Talk Proposal: Rethinking the bedrock of computers

Computing has changed a lot in the past 50 years, but we're still programming computers like it's 1970. Especially our operating systems suffer from this, but our programming languages aren't far off either.

We've made huge advances in managing modularity, and package management has moved forward to match. In node-land, we've moved with that, even actively driven innovation in these areas. We already have extreme modularity, good ways of handling versioning, and isolating concerns.

To fully take advantage of this, and to build computer systems that embody this, we need to rethink our entire stack from the ground up. The goal is to remove as many assumptions as possible from the lowest layers of our stack, and rethink even the fundamentals of operating systems.

In this mad science modular future, nothing is sacred. Drop the filesystem, and replace it with a database — or even a decentralised block storage system!