Skip to content

Instantly share code, notes, and snippets.

@alexklapheke
alexklapheke / badwolf-term.vim
Created June 22, 2021 17:25
badwolf color scheme, adapted for terminal
" This scheme was created by CSApproxSnapshot
" on Sun, 12 Feb 2012
hi clear
if exists("syntax_on")
syntax reset
endif
if v:version < 700
let g:colors_name = expand("<sfile>:t:r")
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import StrMethodFormatter
darkgray = "#4c4c4c"
def barh(
series,
label_fmt,
@alexklapheke
alexklapheke / thesaurus.py
Created August 15, 2020 19:33
Parse Wiktionary thesaurus entries into a vim-compatible format
from lxml import etree
import re
# Export thesaurus pages from <https://en.wiktionary.org/wiki/Special:Export>
infile = "Wiktionary-20200814035046.xml"
outfile = "/home/alex/.vim/wikisaurus-2020-08-13.txt"
entries = []
def iterate_xml(xml_file):
digraph menu {
rankdir = "LR"
node [
fontname = "Linux Libertine O"
fontsize = 10
shape = "record"
];
Dish [ label = "Dish.csv | <id> id | name" ];
Menu [ label = "Menu.csv| <id> id | date | page_count | dish_count" ];
MenuItem [ label = "MenuItem.csv | <id> id | <mpid> menu_page_id | <did> dish_id | price" ];
#!/usr/bin/env python3
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.dates import MonthLocator
plt.style.use("alex")
# Read in & parse data
nyt = pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv", parse_dates=["date"])
# To use:
# 1. Place in ~/.config/matplotlib/stylelib/
# 2. In Python file: plt.style.use("alex")
# Text formatting
font.family : Linux Libertine O
axes.unicode_minus : True
figure.titlesize : 12
axes.titlesize : 12
axes.labelsize : 12
#!/usr/bin/env Rscript
library(ggplot2)
library(dplyr)
library(lubridate)
library(moments)
pdf("test.pdf", width=7, height=5)
kickstarter <- read.csv("DSI_kickstarterscrape_dataset.csv", header=T)
@alexklapheke
alexklapheke / pythagorean.tex
Last active June 13, 2019 04:34
Some of my favorite proofs of the Pythagorean Theorem
% PDF output: http://people.fas.harvard.edu/~klapheke/pythagorean.pdf
% Sources:
% 1. <https://en.wikipedia.org/wiki/Pythagorean_theorem>
% 2. <http://www.faculty.umb.edu/gary_zabel/Courses/Phil%20281b/Philosophy%20of%20Magic/Arcana/Neoplatonism/Pythagoras/index.shtml.html>
% 3. <https://www.cut-the-knot.org/pythagoras/index.shtml>
% 4. <https://math.stackexchange.com/questions/803/what-is-the-most-elegant-proof-of-the-pythagorean-theorem>
% 5. <https://math.stackexchange.com/questions/540415/what-is-the-simplest-proof-of-the-pythagorean-theorem-you-know?noredirect=1>
% 6. <https://math.stackexchange.com/questions/675522/whats-the-intuition-behind-pythagoras-theorem?noredirect=1>
% 7. Mathologer: <https://www.youtube.com/watch?v=p-0SOWbzUYI>
#!/usr/bin/env runhaskell
import Control.Applicative
import System.Environment
-- Usage: $ ./rowbalance.hs ./items
-- Writes file ./items-balanced.csv
main :: IO ()
main = do arg <- head <$> getArgs
file <- lines <$> readFile arg
items <- return $ case square $ length file of
@alexklapheke
alexklapheke / nemo_script_shell.sh
Last active April 10, 2018 04:48
Template for nautilus/nemo scripts
#!/bin/bash
# Template for Nemo scripts.
# Place in $HOME/.local/share/nemo/scripts/
# For Nautilus: s/NEMO/NAUTILUS/g
export IFS=$'\n'
curpath=${NEMO_SCRIPT_CURRENT_URI#file://}
files=$NEMO_SCRIPT_SELECTED_FILE_PATHS
cd "$curpath"