Skip to content

Instantly share code, notes, and snippets.

@flxai
flxai / compare_emd_loss.py
Created February 9, 2019 16:57
compare-emd-loss-wasserstein-distance
import torch
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import wasserstein_distance
from emd import EMDLoss
def gaussian(x, mu, sig):
return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.)))
@flxai
flxai / tmux-grid
Created July 18, 2019 16:13
Run commands in tmux grid layout
#!/bin/bash
# Run a number of commands within tmux in a grid layout
# Session name
s=exp
# Command
c="for i in {1..10}; do echo -n .; sleep 1; done; read"
if tmux has-session -t $s 2>/dev/null; then
echo "Session '$s' exists already, bailing out!"
@flxai
flxai / box.svg
Last active September 29, 2019 21:49
Talk to Clippy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flxai
flxai / PrimeFactorCount.ipynb
Last active October 20, 2019 21:07
Prime factor count
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flxai
flxai / grab.py
Created December 9, 2019 13:21
Grab data for a category from Geizhals
#!/usr/bin/env python3
import re
import requests
import sys
import time
from bs4 import BeautifulSoup
from matplotlib.lines import Line2D
import numpy as np
@flxai
flxai / carpet.sh
Last active February 10, 2020 17:05
#!/bin/bash
# Draws an endless carpet
# carpet [REPETITION] [FLICKER_MODE]
[[ $# -gt 0 ]] && s="$1" || s=4
[[ $# -gt 1 ]] && m="$2" || m=0
while :; do
if [[ -z "$b" ]]; then
p=$(pyceau -m "$m" -r 18+18 -d $(tput cols)x1 -s "$s")
else
p=$(pyceau -m "$m" -r 18+18 -d $(tput cols)x1 -s "$s" -b $b)
#!/usr/bin/env python3
# Send stuff to the landscape flipdot panel
from socket import *
from time import sleep
FD_ADDRESS = ('192.168.1.132', 1234)
SLEEP_S = 1.5
TEXT = ["1 flipdot", "2 hacker", "3 space", "4 kassel"]
while True:

Plot COVID-19 data on the city of Kassel. Data source is the city's own dedicated website which was scraped from a bot who posted changes in IRC. These changes have then been scraped again using some regexes:

echo 'day,time,county,total,total_rel,recovered,recovered_rel,infected,infected_rel,dead,dead_rel' > covid-ks-$(date -I).csv
grep -E 'Kassel (Stadt|Land):.+tot$' ~/.weechat/logs/irc.freenode.\#flipdot.weechatlog | sed -re 's/(,|\[psa\]|insgesamt|genesen|infiziert|tot|\)|\+|Kassel)//g' -e 's/@flipbot//' -e 's/(: )/ /g' -e 's/Stadt/0/' -e 's/Land/1/g' -e 's/(\s|\t|\(| )+/,/g' -e 's/,$//' >> covid-ks-$(date -I).csv

To see interactive plots, download the necessary libraries first:

@flxai
flxai / 30d.svg
Created September 20, 2020 19:07
Comparison of flipdot chat activity by protocol
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flxai
flxai / dfget.py
Created October 7, 2020 21:12
dfget
#!/usr/bin/env python
# dfget gets URL and interprets interactively selected table as Pandas DataFrame
import inquirer
import requests
import sys
import IPython
import pandas as pd