Skip to content

Instantly share code, notes, and snippets.

View straight-shoota's full-sized avatar

Johannes Müller straight-shoota

View GitHub Profile

Keybase proof

I hereby claim:

  • I am straight-shoota on github.
  • I am straightshoota (https://keybase.io/straightshoota) on keybase.
  • I have a public key ASAGiaf3Yvn1msqOmBzwkgy5gS0QDS3qsi_tIeZjYmpc6Ao

To claim this, I am signing this object:

@straight-shoota
straight-shoota / install-crystal-nightly.sh
Last active May 5, 2020 21:39
install-crystal-nightly.sh
#! /usr/bin/env bash
#
# This script looks up the latest successfull nightly build of crystal on
# Circle CI, extracts the build number of `dist_artifacts` job and retrieves
# it's artifacts list.
#
# From this artifacts list, the specified tar package is downloaded and
# extracted in $INSTALL_DIR.
# The binaries `bin/crystal` and `bin/shards` are linked as `crystal-nightly`
# and `shards-nightly` in `/usr/local/bin`.
@straight-shoota
straight-shoota / empty.ll
Created April 22, 2018 13:10
[Crystal] LLVM module validation failed: Both operands to a binary operator are not of the same type!
This file has been truncated, but you can view the full file.
; ModuleID = 'main_module'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%String = type { i32, i32, i32, i8 }
%"Slice(UInt8)" = type { i32, i1, i8* }
%"Array(String)" = type { i32, i32, i32, %String** }
%"->" = type { i8*, i8* }
%"Array(Pointer(Void))" = type { i32, i32, i32, i8** }
%Fiber = type { i32, i8*, %"(Event::Event | Nil)", i8*, i8*, %Fiber*, %Fiber*, %String*, %"(Proc(Nil) | Proc(Void))" }
@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 / reuseport.c
Last active June 21, 2022 11:57
Test support of SO_REUSEPORT
// Simple program to test support of SO_REUSEPORT
// Adapted from https://blog.dubbelboer.com/2016/04/23/so-reuseport.html
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <unistd.h>
int main() {
#ifdef SO_REUSEPORT
@straight-shoota
straight-shoota / crystal-api.cr
Last active April 14, 2020 23:06
Crystal::API
require "json"
module Crystal::Docs
record Program,
project_info : ProjectInfo,
constants : Array(Constant),
types : Array(Type),
methods : Array(Method),
macros : Array(Macro)
@straight-shoota
straight-shoota / Vagrantfile
Created November 13, 2018 15:40
Crystal Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
clone_crystal_from_vagrant = lambda do |config|
config.vm.provision :shell, privileged: false, inline: %(
# Checkout crystal repository
git clone /vagrant crystal
)
end
@straight-shoota
straight-shoota / pre-commit
Last active April 4, 2019 10:26
Git pre-commit hook for `crystal tool format`
#!/bin/sh
#
# This script ensures Crystal code is correctly formatted before committing it.
# It won't apply any format changes automatically.
#
# Only staged files (the ones to be committed) are being processed, but each file is checked
# entirely as it is stored on disc, even parts that are not staged.
#
# To use this script, it needs to be installed in the local git repository. For example by running
# curl https://gist.githubusercontent.com/straight-shoota/fdaf4cf1954e084cd5abccf8f77975f6/raw/pre-commit > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
@straight-shoota
straight-shoota / software_version.cr
Created April 5, 2019 19:09
Crystal SoftwareVersion
# The `SoftwareVersion` type represents a version number.
#
# An instance can be created from a version string which consists of a series of
# segments separated by periods. Each segment contains one ore more alpanumerical
# ASCII characters. The first segment is expected to contain only digits.
#
# There may be one instance of a dash (`-`) which denotes the version as a
# pre-release. It is otherwise equivalent to a period.
#
# Optional version metadata may be attached and is separated by a plus character (`+`).
@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