Skip to content

Instantly share code, notes, and snippets.

View hishamhm's full-sized avatar

Hisham Muhammad hishamhm

View GitHub Profile
@hishamhm
hishamhm / units.lua
Last active October 21, 2023 19:11
Type checked units using records in Teal
-- units.tl
------------------------------------------------------------------------------
local type Hour = record
n: number
metamethod __call: function(self: Hour, n: number): Hour
metamethod __add: function(d1: Hour, d2: Hour): Hour
metamethod __tostring: function(self: Hour): string
end
diff --git example/kong/config/kong.yaml example/kong/config/kong.yaml
index c96cf73..4853d19 100644
--- example/kong/config/kong.yaml
+++ example/kong/config/kong.yaml
@@ -1,3 +1,34 @@
-# a very minimal declarative config file
-_format_version: "2.1"
+_format_version: "1.1"
_transform: true
+
#!/usr/bin/env resty
setmetatable(_G, nil)
local tests = require("spec.fixtures.router_path_handling_tests")
local tabular = require("tabular")
print(tabular(tests))
local function every(xs, field_name)
local vs = {}
local set = {}
2019/12/17 17:15:43 [warn] 24602#0: 4096 worker_connections exceed open file resource limit: 1024
[==========] Running tests from scanned files.
[----------] Global test environment setup.
[----------] Running tests from spec/01-unit/08-router_spec.lua
spec/01-unit/08-router_spec.lua:271: could not categorize route
stack traceback:
spec/01-unit/08-router_spec.lua:271: in function <spec/01-unit/08-router_spec.lua:270>
[ RUN ] spec/01-unit/08-router_spec.lua @ 2823: Router exec() #slash handling (1-1) plain, / with uri /, strip = off, v0. req: /
@hishamhm
hishamhm / 2monitors.sh
Created November 10, 2019 17:41
xrandr script to configure dual monitors
#!/bin/sh
# --- check which is the second monitor, if any ---
if xrandr | grep -q "HDMI1 connected"
then
monitor=HDMI1
elif xrandr | grep -q "^DP1 connected"
then
monitor=DP1
@hishamhm
hishamhm / appveyor-slowest-tests.txt
Created May 28, 2018 20:16
cat log.txt | grep 'OK ]' | grep @ | sed 's,\(.*\)(\([0-9.]*\) ms).*,\2 \1,g' | sort -n | tac > appveyor-slowest-tests.txt
28125.00 [00:05:47] [ OK ] spec\install_spec.lua @ 172: luarocks install #blackbox #b_install more complex tests handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138
27718.00 [00:09:12] [ OK ] spec\test_spec.lua @ 38: luarocks test #blackbox #b_test busted backend with rockspec, installing busted
17593.00 [00:05:19] [ OK ] spec\install_spec.lua @ 152: luarocks install #blackbox #b_install more complex tests handle versioned modules and commands from different files when upgrading #302
15078.00 [00:02:36] [ OK ] spec\build_spec.lua @ 217: LuaRocks build tests #blackbox #b_build LuaRocks build - more complex tests LuaRocks build with https
13422.00 [00:07:41] [ OK ] spec\pack_spec.lua @ 53: LuaRocks pack #blackbox #b_pack src
13094.00 [00:04:40] [ OK ] spec\install_spec.lua @ 74: luarocks install #blackbox #b_install basic tests installs a package with a dependency
13000.00 [00:01:43] [ OK ] spec\build_spec.lua @ 95: LuaRocks build tes
@hishamhm
hishamhm / slowest_tests.txt
Created May 25, 2018 17:26
cat log.txt | grep 'OK ]' | grep @ | sed 's,\(.*\)(\([0-9.]*\) ms).*,\2 \1,g' | sort -n | tac
download "Raw Log" of Travis, then run it through this:
cat log.txt | grep 'OK ]' | grep @ | sed 's,\(.*\)(\([0-9.]*\) ms).*,\2 \1,g' | sort -n | tac
9097.85 [ OK ] spec/test_spec.lua @ 38: luarocks test #blackbox #b_test busted backend with rockspec, installing busted
6656.32 [ OK ] spec/build_spec.lua @ 177: LuaRocks build tests #blackbox #b_build LuaRocks build - more complex tests LuaRocks build luacheck show downloads test_config
6067.46 [ OK ] spec/pack_spec.lua @ 53: LuaRocks pack #blackbox #b_pack src
5725.12 [ OK ] spec/build_spec.lua @ 217: LuaRocks build tests #blackbox #b_build LuaRocks build - more complex tests LuaRocks build with https
5695.56 [ OK ] spec/install_spec.lua @ 172: luarocks install #blackbox #b_install more complex tests handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138
5473.71 [ OK ] spec/test_spec.lua @ 38: luarocks test #blackbox #b_test busted backend with rockspec, installing busted
@hishamhm
hishamhm / all_in_one.lua
Created May 8, 2018 11:28
LuaRocks all-in-one executable bundler
#!/usr/bin/env lua
--[[
All-in-one packager for LuaRocks
* by Hisham Muhammad <hisham@gobolinux.org>
* licensed under the same terms as Lua (MIT license).
Based on:
* srlua.c - Lua interpreter for self-running programs
-- A hastily-written Lua solution to the arithmetic puzzle
-- written about in http://composition.al/blog/2016/12/31/a-simple-but-difficult-arithmetic-puzzle-and-the-rabbit-hole-it-took-me-down/
-- Took me longer to write than I initially thought, but at least the first approach I thought of worked.
-- I deliberately kept the code as I wrote it (took me 69 minutes to get to this), no post-facto cleanups done.
local function copy_table(t)
local u = {}
for k,v in pairs(t) do
if type(v) == "table" then
u[k] = copy_table(v)
@hishamhm
hishamhm / Meter.c.diff
Created July 26, 2016 05:59
Variation on Explorer09's graph-style-test-1 for htop
diff --git a/Meter.c b/Meter.c
index 5490028..3b7b94f 100644
--- a/Meter.c
+++ b/Meter.c
@@ -339,72 +339,38 @@ typedef struct GraphStyle_ {
// Num of bytes per multibyte character. Every character must be padded to
// this num of bytes.
char length;
- // Must be "\0\0"
- char reserved[2];