Skip to content

Instantly share code, notes, and snippets.

View ochronus's full-sized avatar

Csaba Okrona ochronus

View GitHub Profile
@ochronus
ochronus / commands.sh
Last active November 21, 2023 11:28
CPU and disk benchmarks
# install sysbench
$ apt-get install sysbench
# CPU benchmark, 1 thread
$ sysbench --test=cpu --cpu-max-prime=20000 run
# CPU benchmark, 64 threads
$ sysbench --test=cpu --cpu-max-prime=20000 --num-threads=64 run
# Disk benchmark, random read. See .fio files in this gist
#!/usr/bin/env python
import socket
import subprocess
import sys
from datetime import datetime
# Clear the screen
subprocess.call('clear', shell=True)
# Ask for input
### Keybase proof
I hereby claim:
* I am ochronus on github.
* I am ochronus (https://keybase.io/ochronus) on keybase.
* I have a public key whose fingerprint is 72AE 03B4 9D2A A667 2AF4 64DE CFB8 486E DED3 A6FE
To claim this, I am signing this object:
ds = diff --staged # git ds - diff your staged changes == review before committing.
st = status -sb # smarter status - include tag and branch info
fup = log --since '1 day ago' --oneline --author <YOUR_EMAIL> # I know what you did yesterday - great for follow-ups
ls = log --pretty=format:"%C(yellow)%h %C(blue)%ad%C(red)%d %C(reset)%s%C(green) [%cn]" --decorate --date=short # pretty one-line log with tags, branches and authors
lsv = log --pretty=format:"%C(yellow)%h %C(blue)%ad%C(red)%d %C(reset)%s%C(green) [%cn]" --decorate --date=short --numstat # a verbose ls, shows changed files too
# some resets without explanation
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
$("a").each(function() {
var $elem = $(this);
var url = $elem.attr("href");
if (url.indexOf("https://news.ycombinator.com") === 0 || url.indexOf("http") === -1) {
return;
}
if ($elem.attr("target") === undefined) {
$elem.attr("target", "_blank");
(defn bf-interpreter [program-code]
(let [
find-bracket (fn [opening-bracket closing-bracket instruction-pointer direction]
(loop [i (direction instruction-pointer) opened 0]
(condp = (nth program-code i)
opening-bracket (recur (direction i) (inc opened))
closing-bracket (if (zero? opened) i (recur (direction i) (dec opened)))
(recur (direction i) opened))))]
(loop [cells [0N], current-cell 0, instruction-pointer 0]
\[ (recur cells current-cell (inc (if (zero? (nth cells current-cell))
(find-bracket \[ \] instruction-pointer inc)
instruction-pointer)))
\] (recur cells current-cell (find-bracket \] \[ instruction-pointer dec))
find-bracket (fn [opening-bracket closing-bracket instruction-pointer direction]
(loop [i (direction instruction-pointer) opened 0]
(condp = (nth program-code i)
opening-bracket (recur (direction i) (inc opened))
closing-bracket (if (zero? opened) i (recur (direction i) (dec opened)))
(recur (direction i) opened))))
\< (recur cells (dec current-cell) (inc instruction-pointer))
\> (let [
next-ptr (inc current-cell)
next-cells (if (= next-ptr (count cells))
(conj cells 0N)
cells)]
(recur next-cells next-ptr (inc instruction-pointer)))
(defn bf-interpreter [program-code]
(loop [cells [0N], current-cell 0, instruction-pointer 0]
(condp = (get program-code instruction-pointer)
\+ (recur (update-in cells [current-cell] inc) current-cell (inc instruction-pointer))
\- (recur (update-in cells [current-cell] dec) current-cell (inc instruction-pointer))
\. (do
(print (char (nth cells current-cell)))
(recur cells current-cell (inc instruction-pointer)))
\, (let [ch (.read System/in)]
(recur (assoc cells current-cell ch) current-cell (inc instruction-pointer)))