Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View straight-shoota's full-sized avatar

Johannes Müller straight-shoota

View GitHub Profile
@straight-shoota
straight-shoota / errno_location.cr
Created January 11, 2024 13:56
Errno location
ERNNOS = Hash(Pointer(Int32), Int32).new(0)
enum Errno
def self.pointer
{% if flag?(:netbsd) || flag?(:openbsd) || flag?(:android) %}
LibC.__errno
{% elsif flag?(:linux) || flag?(:dragonfly) %}
LibC.__errno_location
{% elsif flag?(:wasi) %}
raise NotImplementedError.new("Errno.pointer")
@straight-shoota
straight-shoota / README.md
Last active January 5, 2024 21:48
Gl-iNET AR300M Network Mode Toggle
  1. Download network-mode.sh
  2. Set executable flag and upload network-mode.sh to router (at $IP)
    chmod +x network-mode.sh
    scp network-mode.sh root@$IP:/etc/gl-switch.d/network-mode.sh
  3. Go to router web UI (http://$IP).
  4. Go to System > Toggle Button Settings, select Network Mode.
  5. Profit.
@straight-shoota
straight-shoota / Makefile
Last active January 13, 2024 23:31
Crystal combined `unreachable` tallies
## Generate database of def tallies
## $ make
SOURCES := $(shell find src -name '*.cr')
SPEC_SOURCES := $(shell find spec -name '*.cr')
CRYSTAL := bin/crystal
SQLITE := sqlite3
SQLITE-UTILS := sqlite-utils
@straight-shoota
straight-shoota / README.md
Last active August 25, 2023 20:50
crystal-tool-demo unreachable results

This output is generated by the prototype unreachable tool from bcardiff/crystal-tool-demo.

Usage (working directory is expected to be the crystal repository)

git clone https://github.com/bcardiff/crystal-tool-demo
cd crystal-tool-demo
sed -i -E 's|require "compiler/crystal/\*\*"|require "compiler/requires"|' src/unused.cr
make bin/unused
cd ..

This output is generated by a prototype of crystal tool unreachable (straight-shoota:feat/tool-unreachable@81ea65e8).

Usage:

git fetch git@github.com:straight-shoota/crystal feat/tool-unreachable
git checkout FETCH_HEAD
make crystal
bin/crystal tool unreachable src/compiler/crystal.cr -c src/compiler/ > unreachable.log
[
{
"author": "HertzDevil",
"state": "APPROVED",
"pr": "PR_kwDOAGkZhc5QGNG7"
},{
"author": "HertzDevil",
"state": "APPROVED",
"pr": "PR_kwDOAGkZhc5QGL6i"
},{
@straight-shoota
straight-shoota / regession-io.no-debug.ll.diff
Last active January 20, 2023 11:16
[Regression] Dwarf loader breaks socket IO in Crystal 1.7 (LLVM IR diff)
This file has been truncated, but you can view the full file.
diff --git 1/regression-io.no-debug.bad.ll 2/regression-io.no-debug.good.ll
index 6e89ec43b..6d5084431 100644
--- 1/regression-io.no-debug.bad.ll
+++ 2/regression-io.no-debug.good.ll
@@ -123,16 +123,14 @@ target triple = "x86_64-unknown-linux-gnu"
%"struct.LibC::Addrinfo" = type { i32, i32, i32, i32, i32, %"struct.LibC::Sockaddr"*, i8*, %"struct.LibC::Addrinfo"* }
%"struct.LibC::Sockaddr" = type { i16, [14 x i8] }
%"struct.LibC::StackT" = type { i8*, i32, i64 }
+%"Char::Reader" = type { %String*, i32, i32, i32, %"(UInt8 | Nil)", i1 }
+%"(UInt8 | Nil)" = type { i32, [1 x i64] }
@straight-shoota
straight-shoota / id_ed25519.pub
Last active October 13, 2022 16:22
SSH keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOZzoh/ZzxqO6+SVFlTrdVqkrq842RvfV6UonV7sdAZ5 Johannes@Milos
@straight-shoota
straight-shoota / console.md
Created July 2, 2022 13:15
Crystal comparison Windows vs Linux (with `samples/havlak.cr`)

Comparing compile time and run time performance of Crystal on Windows and Linux. The sample program is https://github.com/crystal-lang/crystal/blob/b7f3f102fd68fcf9fe4f074513c9e374ec98b492/samples/havlak.cr

Both binaries are built and executed on the same system via WSL (this might cause a little bias, but WSL2 performance is very comparative between Windows and Linux). Hardware is a XPS 9710 with i7 11800H.

;TLDR: Compiler performance is very similar, except for LLVM codegen where Windows has the edge (this is probably due to the newer LLVM version). Runtime performance

@straight-shoota
straight-shoota / error-trace.txt
Created January 21, 2022 13:22
Crystal compiler error `--error-trace`
Using /home/linuxbrew/.linuxbrew/bin/llvm-config [version= 13.0.0]
In src/compiler/crystal/program.cr:45:69
 45 | getter splat_expansions : Hash(Def, Type) = ({} of Def => Type).compare_by_identity
^------------------
Error: instantiating 'Hash(Crystal::Def, Crystal::Type)#compare_by_identity()'
In src/hash.cr:976:5