Skip to content

Instantly share code, notes, and snippets.

View rhizoome's full-sized avatar
💭
Gluing elephants to the ceiling

Jean-Louis Fuchs rhizoome

💭
Gluing elephants to the ceiling
View GitHub Profile
@rhizoome
rhizoome / kinda-polymorphism.elm
Created August 21, 2018 12:25
Kinda Polymorphism
module Main exposing (main)
import Html exposing (Html)
type alias Positioned a =
{ a | x : Float, y : Float }
type alias Named a =
{ a | name : String }
@rhizoome
rhizoome / .bashrc
Last active August 23, 2018 15:21
dcomp - accesses docker-containers from any directory, while keeping the directory (with bash-completion!)
#!/bin/bash
# stuff
if [ -f "/.docker-pwd" ]; then
cd $(cat /.docker-pwd) > /dev/null 2> /dev/null
fi
# other stuff
-- Read more about this program in the official Elm guide:
-- https://guide.elm-lang.org/architecture/user_input/buttons.html
import Html exposing (beginnerProgram, div, button, text, audio)
import Html.Events exposing (onClick)
import Html.Attributes exposing (src, autoplay)
main =
beginnerProgram { model = model, view = view, update = update }
if [ ! -f .ldocker ]; then
sudo docker create \
-e "LDOCKER=$(pwd)" \
-e "DISPLAY=$DISPLAY" \
-e "XAUTHORITY=$XAUTHORITY" \
-e "TERM=$TERM" \
-e "SHELLTOKEN=sid " \
-e "QT_X11_NO_MITSHM=1" \
-h "$(hostname)" \
-v "$HOME:$HOME" \
@rhizoome
rhizoome / asound.conf
Created August 5, 2018 18:35
Minimal asound conf for enabling dmixer
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:CARD=PCH,DEV=0"
@rhizoome
rhizoome / build.sh
Created August 5, 2018 18:10
Smallest rust binary size in stable (using musl based OS)
$> rustc -C opt-level=2 -C lto=fat hello.rs; strip hello; ls -lh hello
-rwxr-xr-x 1 ganwell ganwell 150.2K Aug 5 20:08 hello
@rhizoome
rhizoome / main.cpp
Created April 23, 2018 09:59
Cool cpp
#include <vector>
#include <numeric>
struct sum_f
{
template<class T, class U>
auto operator()(T x, U y) const
{
auto p = x * y;
return x + y + p;
@rhizoome
rhizoome / 1results.txt
Last active April 14, 2018 13:33
cython and indexing
test1: 0.08422580
test2: 0.06810107
test3: 0.04625974
test4: 0.04655976
test5: 0.00176943
test6: 0.00161580
test7: 0.00752258
test8: 0.07144928
root@e4140f069f31:/# slapadd -b cn=config
dn: olcDatabase={1}mdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcMdbConfig
olcDatabase: {1}mdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=edubs,dc=ch
olcLastMod: TRUE
olcRootDN: cn=admin,dc=edubs,dc=ch
olcRootPW:: e1NTSEF9V3c3MTV3NmlJUlpzdktSMWVFSW95OWZNQlZWNk1uNlY=
@rhizoome
rhizoome / affine.py
Created January 5, 2018 14:22
Check if crc32 and md5 are affine
"""Affinity test."""
from hashlib import md5
from binascii import crc32
from hypothesis import given
from hypothesis.strategies import integers, lists, tuples
# In practice, CRC operations are often started with a nonzero state. Because
# of this, the actual equation is usually of the form:
# crc(a)⊕crc(b)=crc(a⊕b)⊕c