Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond. Ping me on Twitter instead:

Christoph Grabo asaaki

I may be slow to respond. Ping me on Twitter instead:
View GitHub Profile
asaaki / bench-env-vars-in-different-scopes.rb
Last active Jul 6, 2020
Ruby: Do ENV vars have a significant impact on the runtime performance?
View bench-env-vars-in-different-scopes.rb
#!/usr/bin/env ruby
# gem install benchmark-ips
require 'benchmark'
require 'benchmark/ips'
class GCSuite
def warming(*); run_gc; end
def running(*); run_gc; end
def warmup_stats(*); end
asaaki /
Created Jun 12, 2020
TCO #rustlang #recursion
// Recursion: TCO (Tail Call Optimization)
// Computerphile:
fn fib(n: usize) -> usize {
fib_go(n, 0, 1)
fn fib_go(n: usize, a: usize, b: usize) -> usize {
match (n, a, b) {
(0, v, _) => return v,
asaaki /
Last active Apr 23, 2020 — forked from twooster/
Create scrolling text gifs for Slack

(Forked fork, that works on macos, too)

Makes little scrolly text jiffs in Flywheel colors.


  • macos: brew install fontconfig imagemagick gifsicle
  • Linux: sudo apt install fontconfig imagemagick gifsicle


View Gemfile
# frozen_string_literal: true
source ''
gem 'puma'
gem 'sinatra'
gem 'sinatra-contrib'
asaaki /
Last active Nov 7, 2019
Env Vars as Booleans

Boolean Environment Variables

Don't overcomplicate things.

I've seen a lot of parse the env var and match it against some known values like:

env_var = ENV['FEATURE_ONE']
case env_var.to_s.downcase
when 'true', 't', 'yes', 'y', 'on', '1' then true
View ruby-sigils.rb
[*('A'..'Z'), *('a'..'z')].map do |c|
puts [c, eval("%#{c}(ls)")].inspect
rescue Exception
puts "#{c} not allowed"
end; 0
asaaki / experiments.rb
Created May 16, 2019
Some Ruby stdlib experiments
View experiments.rb
### Experiments
log =
queue =
group = # pool
5.times do |i|
asaaki / flurlicht.ino
Created Jan 30, 2019
motion sensor / interrupt triggered neopixel light controller
View flurlicht.ino
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#define STRIP_PIN 6
#define TRIGGER_PIN 2
#define CONTROL_LED 13
// Note: this duration should be also longer than the HIGH time of the PIR
asaaki /
Created Oct 22, 2018
(rustup) add or remove list of targets for a list of toolchains
targets=(armv7-unknown-linux-musleabihf thumbv7em-none-eabi armv7-unknown-linux-musleabihf)
toolchains=(stable beta nightly)
for toolchain in $toolchains; do
for target in $targets; do
echo "--> toolchain $toolchain and target $target"
rustup target install $target --toolchain $toolchain
# rustup target remove $target --toolchain $toolchain
View callables_spec.rb
require 'spec_helper'
module CallableSubject
def callable_subject(&_block)
subject { -> { yield } }
RSpec.configure do |c|
You can’t perform that action at this time.