Skip to content

Instantly share code, notes, and snippets.


Ori Livneh atdt

View GitHub Profile
atdt /
Created Sep 21, 2020 — forked from skyzyx/
Using GNU command line tools in macOS instead of FreeBSD tools

macOS is a Unix, and not built on Linux.

I think most of us realize that macOS isn't a Linux OS, but what that also means is that instead of shipping with the GNU flavor of command line tools, it ships with the FreeBSD flavor. As such, writing shell scripts which can work across both platforms can sometimes be challenging.


Homebrew can be used to install the GNU versions of tools onto your Mac, but they are all prefixed with "g" by default.

All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.

View init.lua
- menubar items
- print(hs.inspect(...))"mode: %s x %s", mode.w, mode.h))
local function sendSystemKey(key)
atdt / knockd.conf
Last active Jul 26, 2020
View knockd.conf
sequence = 1000,2000,3000 # change me
seq_timeout = 5
start_command = ufw insert 1 allow from %IP% to any port 22
tcpflags = syn
cmd_timeout = 10
stop_command = ufw delete allow from %IP% to any port 22
atdt /
Created Jul 26, 2020
Port-knocking client (e.g. for knockd) in Python
#!/usr/bin/env python3
# Port-knocking client
# Usage: knock HOST PORT [PORT...]
import socket
import sys
host = sys.argv[1]
ports = [int(p) for p in sys.argv[2:]]
View gist:d36bcfec2907e190b118083b75c5037d
I don't get the appeal of dungeon crawlers. It seems like i could recreate the essential experience by opening Microsoft Excel scrolling down 10,000 pages with the down cursor key, and then typing "the most marvelous trousers of them all".
atdt / benchmark_webp
Last active Jun 6, 2020
Benchmark webp vs png for images on enwiki main page
View benchmark_webp
#!/usr/bin/env bash
while IFS= read -r URL ; do
echo "$URL"
echo "WEBP:"
wrk -c1 -t1 -d5 -H 'accept: image/webp' --latency "$URL"
echo ""
echo "PNG:"
wrk -c1 -t1 -d5 --latency "$URL"
atdt / or_null.txt
Created May 25, 2020
Names of functions in MediaWiki that return 'X or (null|false)'
View or_null.txt
# Names of functions in MediaWiki that return 'X or (null|false)'
# git grep -A2 -P '@return .*(\||or )(null|false)' -- '*.php' | grep -Po '(?<=function )[^(]+(?=\()' | sort
atdt / apcu_vs_opcache.php
Last active Dec 13, 2019
loading i10n messages from opcache vs apc
View apcu_vs_opcache.php
// apcu vs. opcache benchmark
// loads mediawiki en messages from cache 1000 times
// you need languages/i18n/en.json in the same directory as this script.
// ini settings you need:
// opcache.enable=1
// opcache.enable_cli=1
atdt / package.json
Last active Aug 7, 2019
for code next
View package.json
"name": "furry-garbanzo ",
"description": "blah blah blah",
"author": "",
"version": "0.0.1",
"devDependencies": {
"scripts": {
"test": "jshint **/*.js"
atdt /
Created May 19, 2019
Human-readable duration
def human_duration(seconds):
if seconds <= 1:
return '0 seconds'
units = (
('day', 86400),
('hour', 3600),
('minute', 60),
('second', 1),
parts = []
You can’t perform that action at this time.