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 / crystal-windows.sh
Last active March 9, 2024 17:57
Crystal compiler wrapper for Windows Subsystem for Linux
#!/usr/bin/env bash
# MSVC 2017
# MSVC_BUILD_TOOLS="C:\\Program^ Files^ ^(x86^)\\Microsoft^ Visual^ Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvarsall.bat"
# MSVC 2015
MSVC_BUILD_TOOLS="C:\\Program^ Files^ ^(x86^)\\Microsoft^ Visual^ C++^ Build^ Tools\\vcbuildtools.bat"
set -euo pipefail
@straight-shoota
straight-shoota / Makefile
Last active February 5, 2024 00:21
Makefile for Crystal + Shards
.POSIX:
all:
# Recipes
## Build application
## $ make
## Run tests
## $ make test
## Install application
@straight-shoota
straight-shoota / executables.md
Last active January 31, 2024 11:58
Shards with `postinstall` scripts or `executables`
@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 / 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 / spindle.cr
Last active November 18, 2023 06:10
Spindle - Structured Concurrency for Crystal (PoC)
def bob
10.times do
puts "B"
sleep 0.006
end
end
def alice
3.times do
puts "A"
@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"
},{