Skip to content

Instantly share code, notes, and snippets.

@vanzaj
vanzaj / urls_should_work.txt
Created October 12, 2022 03:13
URLs for testing regex
SHOULD MATCH:
http://foo.com/blah_blah
http://foo.com/blah_blah/
http://foo.com/blah_blah_(wikipedia)
http://foo.com/blah_blah_(wikipedia)_(again)
http://www.example.com/wpstyle/?p=364
https://www.example.com/foo/?bar=baz&inga=42&quux
http://✪df.ws/123
http://userid:password@example.com:8080
@vanzaj
vanzaj / sum100.py
Created June 22, 2019 08:52
sum to 100
#!/usr/local/bin/python3
from itertools import chain, product
flatten = chain.from_iterable
digits = [ str(x+1) for x in range(9) ]
P, M, C = [ ' + ', ' - ', '']
''' operators = add, sub, concat (str, str)
1 + 2 + 3 + ...
#!/bin/bash
hash_string() {
if [[ -z "$1" ]]; then
echo "Usage: $0 input_string [hash_length]"
exit 0
fi
echo "$1" | git hash-object --stdin | cut -c 1-"${2:-8}"
}
@vanzaj
vanzaj / ofs.dot
Created October 13, 2017 02:54
OFS topics viz
digraph G {
rankdir=LR;
OFS [shape=box];
HW [shape=box];
Coding [shape=box];
AltEdu [shape=box];
edu_trends [shape=box, label="Edu\nTrends"];
current_state [shape=box, label="Current\nState"];
OFS -> HW;
OFS -> Coding;

Keybase proof

I hereby claim:

  • I am vanzaj on github.
  • I am vanzaj (https://keybase.io/vanzaj) on keybase.
  • I have a public key ASBYgX0BtNA_at4Goa9W-KaORsLRmnkk77abe3vYWYbRLQo

To claim this, I am signing this object:

@vanzaj
vanzaj / enex2md.py
Created November 29, 2016 09:05
Convert evernote (enex) files to markdown
#!/usr/bin/env python
# coding=utf-8
#
# convert evernote enex files to markdown
# depends on https://github.com/claytron/ever2simple
# assumes enex files are named as CATEG-foo-bar.enex
import datetime
import glob
import json
@vanzaj
vanzaj / conda_install.sh
Created June 27, 2016 06:06
miniconda installer
#!/usr/bin/env bash
#dld="https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh"
dld="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh"
curl -o miniconda_install.sh $dld
test -d $HOME/local || mkdir $HOME/local
sh ./miniconda_install.sh -b -p $HOME/local/miniconda
@vanzaj
vanzaj / rules_evdev.xml
Created December 16, 2015 09:03
custom_xkb_ru_phonetic
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
<xkbConfigRegistry version="1.1">
<modelList>
<model>
<configItem>
<name>pc101</name>
<description>Generic 101-key PC</description>
<vendor>Generic</vendor>
</configItem>
@vanzaj
vanzaj / mystery_curve
Created June 6, 2015 04:14
mystery_curve
# http://www.johndcook.com/blog/2015/06/03/mystery-curve/
import matplotlib.pyplot as plt
from numpy import pi, exp, real, imag, linspace
def f(t):
'''$\exp^{it} – \exp^{6it}/2 + i \exp^{-14it}/3$ with $t$ running from 0 to 2$\pi$.'''
return exp(1j*t) - exp(6j*t)/2 + 1j*exp(-14j*t)/3