Skip to content

Instantly share code, notes, and snippets.

View W4RH4WK's full-sized avatar
🔱
A demon, killing demons

Alex Hirsch W4RH4WK

🔱
A demon, killing demons
View GitHub Profile
/* CFLAGS = -Wall -Wextra -std=c99 -O2
*
* Simply build and run, it will generate 4 images in pbm format. Use
* imagemagick's `convert` commandline tool, to scale them as well as generate
* an animated gif.
*
* $ convert *.pbm -scale 300x300 -loop 0 -delay 50 frames.gif
*
*/
@W4RH4WK
W4RH4WK / FSM.cs
Last active April 28, 2024 08:55
C# Generic Finite State Machine
using System;
using System.Collections.Generic;
using System.Reflection;
namespace GenericFSM {
public class FSM<T> where T : struct, IConvertible {
public T State { get; private set; }
module Try.Rewrite where
import qualified Data.Rewriting.Term as T
import qualified Data.Rewriting.Rule as R
import qualified Data.Rewriting.Rules as Rs
import qualified Data.Rewriting.Problem as P
-- operations
data Fun = Const Integer
| Add
@W4RH4WK
W4RH4WK / blacklist.txt
Last active January 5, 2016 12:55
unRAID string decrypt
0000-0000-0000-000000000000
0000-0000-0463-000360044655
0000-0000-2008-100909290981
0000-0000-2620-090844540040
0000-0000-7084-704000000724
0000-0000-7084-705000002215
0000-0000-7090-704000000470
0000-0000-7091-0J3000003249
0000-0000-7093-3J2000000828
0000-7777-0000-000059F8010F
#!/usr/bin/env python3
from pygments import lexers
for a in (alias for _, aliases, _, _ in lexers.get_all_lexers() for alias in aliases):
print(a)
@W4RH4WK
W4RH4WK / tex2svg
Last active January 17, 2016 12:25
#!/usr/bin/env python3
""" Convert LaTeX to SVG
This script will read LaTeX from stdin into a temporary file, compile it,
convert it to SVG and write it to stdout. Temporary files are removed upon
success.
Usage: ./tex2svg [template]
#!/usr/bin/env python3
from datetime import datetime, timedelta
from time import sleep
def time_mark(**timedelta_kwargs):
mark = datetime.now() + timedelta(**timedelta_kwargs)
while True:
yield datetime.now() > mark
@W4RH4WK
W4RH4WK / 50-synaptics.conf
Created November 29, 2015 10:04
Lenovo E330 Touchpad Settings
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
Option "VertResolution" "100"
Option "HorizResolution" "65"
Option "MinSpeed" "1"
Option "MaxSpeed" "1"
Option "AccelerationProfile" "2"
Option "AdaptiveDeceleration" "16"
@W4RH4WK
W4RH4WK / tile
Last active November 26, 2015 10:13
Tmux run program in parallel
#!/bin/bash
# requires:
# set-option -ga update-environment ' TILE_NUM'
SESSION="$(date +%Y-%m-%d-%H-%M-%S)"
TILES="$1"
re='^[0-9]+$'
if [[ ! $TILES =~ $re ]]; then
@W4RH4WK
W4RH4WK / worker.py
Created September 15, 2015 15:17
WorkerThread paradigm
from time import sleep
class Worker(object):
def do_stuff(self):
print 'working'
def loop(self):
while True: