Skip to content

Instantly share code, notes, and snippets.

@mrdomino
mrdomino / genpass.py
Last active March 25, 2017 22:12
Passphrase generator
#!/usr/bin/env python3
"""
Generates random memorable passphrases.
This script builds a set of unique suitable words from a dictionary file, then
produces one or more passphrases chosen at random form that set. It also
optionally prints estimates of the entropy (i.e. difficulty to guess) of the
produced passphrases based on the number of items in the set and the number of
words per phrase.
@mrdomino
mrdomino / chrome
Created December 31, 2016 23:16
OpenBSD script to run chrome as a separate user in a Xephyr window
#!/bin/sh
set -eux
NDISPLAY=:13
if [ $# -ge 1 ]
then
case $1 in
:*)
NDISPLAY=$1
shift
@mrdomino
mrdomino / browse.sh
Created December 5, 2016 14:40
run firefox as a separate user in openbsd
#!/bin/sh
set -eu
tmpfile=$(mktemp)
xauth -q -f $tmpfile generate $DISPLAY . untrusted
xauth_data=$(xauth -f $tmpfile nlist $DISPLAY)
rm -f $tmpfile
DOAS_XAUTH="xauth -q remove $DISPLAY ; echo $xauth_data | xauth nmerge - ;"
export DOAS_XAUTH
#include <stdio.h>
int main() {
while (1) puts("whee");
}
#!/bin/sh
# usage: flag <flag> [args...]
# e.g.: flag --foo= x y z
# --foo=x --foo=y --foo=z
trap "awk '/^# /' $(which $0) | cut -d' ' -f2-" EXIT
set -eu; flag=$1; shift; for arg in "$@"; do echo $flag$arg; done
exec true
#!/bin/sh
exec git $@
@mrdomino
mrdomino / quine.hs
Last active December 12, 2015 06:59
e '\\' = "\\\\"
e '\n' = "\\n"
e '\"' = "\\\""
e x = [x]
q = concatMap e
m s = s ++ "\"" ++ q s ++ "\""
main = putStrLn $ m s
where s = "e '\\\\' = \"\\\\\\\\\"\ne '\\n' = \"\\\\n\"\ne '\\\"' = \"\\\\\\\"\"\ne x = [x]\nq = concatMap e\nm s = s ++ \"\\\"\" ++ q s ++ \"\\\"\"\nmain = putStrLn $ m s\n where s = "
#include <cstdio>
#include <exception>
#include <utility>
// hypothetically...
class MyException : public std::exception {
public:
const char *what() const noexcept {
return "nope";
@mrdomino
mrdomino / copies.c++
Last active October 24, 2015 17:41
copy and assignment operator autogeneration
class A {};
class B {
public:
B() = default;
B(B const&) = delete;
};
class C {
public:
#!/bin/sh
function main {
for cpu in ${CPUS[@]}
do
echo ==== $cpu ====
check bazel build --ios_cpu=$cpu $DEPS
check mkdir -p $WORK/$cpu
for dep in $DEPS
do