Skip to content

Instantly share code, notes, and snippets.

@JustAPerson
JustAPerson / renumber.gawk
Last active March 18, 2020 03:44
jellyfin renumbering
match($0,/([[:digit:]]+).*(\..+)/,a) { printf "%s %s%s%s\n", ENVIRON["title"], ENVIRON["EPPREFIX"], a[1], a[2] }
@JustAPerson
JustAPerson / yaku.txt
Last active November 15, 2019 07:40
Most common Riichi Mahjong yaku. Sourced from http://tenhou.net/sc/prof.html
- 44% Riichi (1h closed)
- 39% Yakuhai (1h open) - dragons/round wind/seat wind
- 22% Tanyao (1h open) - only 2-8
- 20% Pinfu (1h closed) - no triples/quads/yakuhai
- 18% Menzen Tsumo (1h closed)
- 6% Honitsu/Honiisou (2h open+) - One suit + honors
- 4% Iipeiko (1h closed) - same sequence twice
- 4% Sanshoku Doujun (1h open+) - same sequence in all 3 suits
- 3% Toitoi (2h open) - No sequences
@JustAPerson
JustAPerson / pingplot.py
Created May 11, 2019 17:44
convert output of `ping domain > file` into a graph
import sys
import re
import matplotlib.pyplot as plot
file_name = sys.argv[1]
with open(file_name) as f:
data = f.read()
domain = re.search('PING (.+) 56', data)
seq = re.findall('icmp_seq=(\d+)', data)
@JustAPerson
JustAPerson / gtile.lua
Created March 14, 2019 02:52
manually move/resize windows in a variety of grid arrangements
local gears = require 'gears';
local awful = require 'awful';
--- Move a client to a location within a grid
-- @param c the client to move
-- @param sx the number of columns in the grid
-- @param sy the number of rows in the grid
-- @param px the zero-indexed destination column
-- @param py the zero-indexed destination row
function client_move_to_grid(c, sx, sy, px, py)
@JustAPerson
JustAPerson / mousemem.lua
Created March 14, 2019 02:49
remember mouse position when re-focusing window, or just center if we've never visited window before
local awful = require('awful');
local memory = {}
local function client_focus(c)
-- do nothing if focusing client under cursor
if mouse.current_client == c then
return
end
@JustAPerson
JustAPerson / mousemem.lua
Created October 4, 2018 18:34
Remember mouse positions when alt-tabbing with AwesomeWM
local awful = require('awful');
local memory = {}
local function client_focus(c)
-- do nothing if focusing client under cursor
if mouse.current_client == c then
return
end
@JustAPerson
JustAPerson / sort.py
Last active May 3, 2018 17:50
Extra fast radix sort variant. O(n log(w / log(n)) where w is the width of the number in bits. http://courses.csail.mit.edu/6.897/spring05/psets/ps7.pdf http://courses.csail.mit.edu/6.897/spring05/psets/ps7-sol.pdf
import random
import math
def hi(x, halfw):
return x >> halfw
def lo(x, halfw):
return x & (1 << halfw) - 1
def get_hiS(S, halfw):
def split_into(ls, k):
output = []
for i in range(k):
output.append([])
i = 0
for item in ls:
output[i % k].append(item)
i += 1
return output
; x = 5;
; fac = fun(x){
; if(x <= 1){
; return x;
; }
; v = fac(x-1);
; print("fac of " + (x-1) + " is " + v);
; return x * v;
; };
;
TARGET(elf32-i386)
INPUT(beta.o) /* assembly stage1 */
INPUT(gamma.o) /* rust code */
OUTPUT_ARCH(i386)
OUTPUT_FORMAT("binary")
SECTIONS
{