Skip to content

Instantly share code, notes, and snippets.

Error in bin/micrate:4: instantiating 'Micrate::Cli:Module#run()'
Micrate::Cli.run
^~~
in lib/micrate/src/micrate/cli.cr:89: instantiating 'run_up()'
run_up
^~~~~~
abstract class Transformation(I, O)
def self.transform(input : I) : O
O.new(input)
end
end
macro trans(name, input, output, &block)
class {{name}} < Transformation({{input}}, {{output}})
class_getter from = {{input}}
class_getter to = {{output}}
@Willamin
Willamin / dirlist.xslt
Created April 27, 2018 18:07 — forked from wilhelmy/dirlist.xslt
make nginx dirlistings look like lighttpd's through the magic of xslt-transforming xml dirlistings. I don't even.
<?xml version="1.0"?>
<!--
dirlist.xslt - transform nginx's into lighttpd look-alike dirlistings
I'm currently switching over completely from lighttpd to nginx. If you come
up with a prettier stylesheet or other improvements, please tell me :)
-->
<!--
Copyright (c) 2016 by Moritz Wilhelmy <mw@barfooze.de>
raspberry pi 0 w:
$ 10.00
https://www.adafruit.com/product/3400
lipo shim:
$ 9.95
https://www.adafruit.com/product/3196
lipo battery (3.7v 2000mAh):
$ 12.50
$ # no cache crystal run
$ rm -rf $(crystal env CRYSTAL_CACHE_DIR)/*
$ time crystal run sample.cr
hello
real 0m1.289s
user 0m1.916s
sys 0m0.375s
$ # cached crystal run
$ # no cache crystal run
$ rm -rf $(crystal env CRYSTAL_CACHE_DIR)/*
$ time crystal run sample.cr
hello
real 0m1.289s
user 0m1.916s
sys 0m0.375s
$ # cached crystal run
$ # no cache crystal run
$ rm -rf $(crystal env CRYSTAL_CACHE_DIR)/*
$ time crystal run sample.cr
hello
real 0m1.289s
user 0m1.916s
sys 0m0.375s
$ # cached crystal run
@Willamin
Willamin / retry.rb
Last active August 7, 2018 18:27
Travis Retry but in Ruby
#!/usr/bin/env ruby
count = 1
attempts = (ENV['TRAVIS_RETRY'] || 3).to_i
command = ARGV.join(" ")
puts "Attempting to run \"#{command}\". Will retry up to #{attempts} times."
attempts.times do |attempt_number|
attempt_number += 1
#!/usr/bin/env crystal
class Thread
class MyThread
@thread : LibC::PthreadT
setter proc : Proc(Pointer(Void), Pointer(Void))
def initialize
@thread = uninitialized LibC::PthreadT
@proc = uninitialized Proc(Pointer(Void), Pointer(Void))
macro do_debug(name)
module MyDebug{{name.id}} # use the run macro to md5 the name or something
def name
{{name}}
end
def debug(thing)
puts("#{name}: #{thing}")
end
end
include MyDebug{{name.id}} # use the run macro to md5 the name or something