Skip to content

Instantly share code, notes, and snippets.

View edef1c's full-sized avatar

edef edef1c

  • Earth
View GitHub Profile
@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"!" }' |\
@edef1c
edef1c / nixos-option
Last active August 17, 2019 23:22
NixOS deployment scripts
nixos-rebuild
@edef1c
edef1c / sigevent.c
Last active August 13, 2019 03:42
proof-of-concept of siglongjmp/ppoll-based signal handling in an event loop
#define _GNU_SOURCE
#include <err.h>
#include <errno.h>
#include <poll.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
define-command nix-jump %{
execute-keys <esc><a-i><a-w>
edit %sh{
if [[ "$kak_selection" =~ ^\<(.*)\>$ ]]; then
path="$(nix-instantiate --find-file "${BASH_REMATCH[1]}")"
else
cd "$(dirname "$kak_buffile")"
path="$(realpath "$kak_selection")"
fi
if [ -d "$path" ]; then
@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";
};

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 May 4, 2017 13:55
Multiple inheritance with ES6 proxies, in both ES6 and CoffeeScript. Literate.
%.coffee: %.coffee.md
sed -n -e '/^ \{4\}/s/^ \{4\}//p' $< > $@
%.js: %.js.md
sed -n -e '/^ \{4\}/s/^ \{4\}//p' $< > $@
%.js: %.coffee
coffee -cb $<
all: multi-inherit.coffee multi-inherit.future.js
clean:
@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 / Makefile
Last active January 19, 2016 15:14
all: env
install: env
install -D env $(out)/bin/env