Skip to content

Instantly share code, notes, and snippets.

View paudirac's full-sized avatar
🐍
Code's a journey, not a destination

paudirac

🐍
Code's a journey, not a destination
View GitHub Profile
@paudirac
paudirac / router.py
Created May 6, 2022 12:38
django migrations multiple databases
class LegacyRouter:
route_app_labels = {'legacy',}
legacy_database = 'legacy'
def db_for_read(self, model, **hints):
if model._meta.app_label in self.route_app_labels:
return self.legacy_database
return None
def db_for_write(self, model, **hints):
@paudirac
paudirac / .Xmodmap
Created August 8, 2021 07:31
Remap CapsLock to Ctrl
clear lock
clear control
keycode 66 = Control_L
add control = Control_L Control_R
@paudirac
paudirac / m
Created May 24, 2020 16:37
Full code for markdown parser of blog post http://self.paudirac.com/blog/classical-web-pages/
#!/usr/bin/env python3
import sys
from paudirac.markdown import to_html
to_html(sys.stdin.read(), writer=sys.stdout)
@paudirac
paudirac / inspect-git-objects.sh
Created July 10, 2019 16:20
Inspect git objects of a folder
#!/bin/bash
list_objects () {
find .git/objects/ -type f | sed s:.git/objects/:: | sed s:/::
}
list_types () {
list_objects | xargs -n1 git cat-file -t
}
@paudirac
paudirac / church
Last active December 31, 2017 23:53
Happy new
λf.λx.f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
@paudirac
paudirac / emacs-env
Last active August 7, 2021 07:23
Select from multiples emacs.d
#!/bin/bash
function show_options {
readlink $(find $HOME -maxdepth 1 -type l -iname '.*emacs.d') \
| awk 'sub(/\.d\//,"",$0) { print "Current emacs is \t\t" substr($0,2) }'
echo
echo "Call with following options to change:"
find $HOME/emacs -maxdepth 1 -mindepth 1 -type d -printf "\t%f\n"
}
print "right\n" if chr ord 'a' eq 'a';
print "wrong\n" if not chr ord '·' eq '·';
@paudirac
paudirac / poly.clj
Last active February 21, 2017 13:07
Eval and derive polynomials
(defn accumulate [op initial sequence]
(if (empty? sequence)
initial
(op (first sequence)
(accumulate op initial (rest sequence)))))
(defn eval-poly [x coefs]
(accumulate (fn [c0 cs]
(+ c0 (* x cs)))
0
-[--->+<]>----.---[-->+++<]>.++[->+++<]>.+++++++++++++.---------.-----.+++++++++++.[--->+<]>-----.[-->+++++++<]>.++.-------------.[--->+<]>----.----------.-----.+.+++++++++.++++++.+++[->+++<]>.-[->+++<]>.------------.----[->++++<]>+.++++.++[->+++<]>.+++++++++++++.---------.-----.+++++++++++.[--->+<]>-----.++++++[->++<]>+.-[------>+<]>-.--[--->+<]>---.---------.--------.+++++++++++++.+.>++++++++++..>-[--->+<]>----.---[-->+++<]>.------------.----.+++++++++++++.---.[--->+<]>-----.+[->+++<]>.++++++++++++.--.++++++++.-------.-----.------.--.--[--->+<]>---.++.+++[->+++<]>.-[->+++<]>.------------.[-->+++++++<]>.-.+++.[-->+++++<]>+++.+[----->+<]>.--------.-.+++++.++++++.[--->+<]>-----.+[->+++<]>+.+.--[--->+<]>-.+[->+++<]>++.[--->+<]>----.+.+[->+++<]>++.--[--->+<]>--.+[---->+<]>+++.++[--->++<]>.-[->+++++++<]>.>+[------->++<]>.---------.----.--[--->+<]>--.-[++>---<]>+.------------.+[----->+<]>.----.[--->+<]>---.+[->+++<]>+.+.--.++++++.++++++++++.----------.++[--->++<]>+.+[-->+++<]>.-[->+++++<]>-.+[->+++<]>+.+.--[--->+<
import sys
def read(): return raw_input()
def selected_employees():
return (read(), read())
def read_relation():
manager, managed = read().split()
return managed, manager