Skip to content

Instantly share code, notes, and snippets.

View tronje's full-sized avatar
🦀

Tronje tronje

🦀
View GitHub Profile
@tronje
tronje / Makefile
Last active November 24, 2018 21:24
C Makefile
### constants ###
NAME = name_of_program
# directories
SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = build
TARGET_DIR = $(BUILD_DIR)/debug
RELEASE_TARGET_DIR = $(BUILD_DIR)/release
@tronje
tronje / run.py
Last active May 19, 2018 14:16
wttr.in conky color replacement
#!/usr/bin/env python
"""The script replaces colors contained in output from
`curl -s wttr.in/$Location` with conky-compatible color codes.
Use it like this:
```
conky.text = [[
${execpi 1800 curl -s wttr.in/Hamburg | head -7 | tail -5 | /path/to/run.py}
]]
```
@tronje
tronje / sdt
Last active December 4, 2017 14:23
Sub des Tages script
#!/bin/bash
day=`date +"%a"`
case "$day" in
Mon)
echo "Italian B.M.T."
;;
Tue)
@tronje
tronje / EightQueens.hs
Last active October 10, 2019 18:54
Eight Queens puzzle in Haskell
#!/usr/bin/env runhaskell
{-
0 1 2 3 4 5 6 7
0 □ ■ □ ■ □ ■ □ ■
1 ■ □ ■ □ ■ □ ■ □
2 □ ■ □ ■ □ ■ □ ■
3 ■ □ ■ □ ■ □ ■ □
4 □ ■ □ ■ □ ■ □ ■
5 ■ □ ■ □ ■ □ ■ □
data Tree a = Empty | Leaf a | Tree a (Tree a) (Tree a) deriving Show
treeInsert :: Ord a => a -> Tree a -> Tree a
treeInsert n Empty = Leaf n
treeInsert n (Leaf m)
| n <= m = Tree m (Leaf n) Empty
| n > m = Tree n (Leaf m) Empty
treeInsert n (Tree v left right)
| n == v = Tree n left right
data List a = Empty | Cons a (List a)
instance (Show a) => Show (List a) where
show xs = "<" ++ show' xs ++ ">"
where
show' Empty = ""
show' (Cons x Empty) = show x
show' (Cons x xs) = show x ++ "," ++ show' xs
reverse' :: [a] -> [a]
reverse' [] = []
reverse' xs = (last xs) : (reverse' $ init xs)
sort' :: Ord a => [a] -> [a]
sort' [] = []
sort' (pivot:xs) =
sort' [x | x <- xs, x < pivot]
++ [pivot]
@tronje
tronje / build.sh
Last active December 10, 2019 23:18
C program to click the mouse n times in X11
#!/bin/bash
gcc -o click click.c -lX11 -lXtst -O2 -flto -march=native -mtune=native -DDELAY_SECONDS=0 -DDELAY_NSECONDS=35000000