Skip to content

Instantly share code, notes, and snippets.

View luislavena's full-sized avatar

Luis Lavena luislavena

View GitHub Profile
@luislavena
luislavena / 2-console-output.log
Last active October 2, 2017 16:06
Docker + VirtualBox VM + Alpine - FS issue
$ pwd
/home/luis/code/_sandbox/testing-alpine
$ echo 'foo' > file.txt
$ ls
file.txt
$ cat file.txt
foo
require "../src/beryl"
# This sample showcases how to use a separate action
class HelloRouter < Beryl::Router
routing do
get "/", HelloAction
end
end
class HelloAction
clang++-3.7 -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc `/usr/bin/llvm-config-3.7 --cxxflags`
src/llvm/ext/llvm_ext.cc:122:27: error: no member named 'setSubprogram' in 'llvm::Function'
unwrap<Function>(Func)->setSubprogram(Sub);
~~~~~~~~~~~~~~~~~~~~~~ ^
src/llvm/ext/llvm_ext.cc:214:100: error: too few arguments to function call, expected at least 2,
have 1
...*CT = Dref->createSubroutineType(DITypeRefArray(unwrap<MDTuple>(ParameterTypes)));
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/lib/llvm-3.7/include/llvm/IR/DIBuilder.h:383:5: note: 'createSubroutineType' declared here
DISubroutineType *createSubroutineType(DIFile *File,
struct Wrapper(T)
module Interface
abstract def unwrap
end
include Interface
def unwrap
T
end
require "option_parser"
number = 0
parser = OptionParser.new do |op|
op.on "-n N", "--number N", "Set the number" { |n| number = n.to_i }
op.missing_option do |option|
puts "Missing value for '#{option}'"
end
$ bin/crystal build --debug foo.cr
Using compiled compiler at .build/crystal
$ ./foo
BOOM (Exception)
0x0000000000434c20: *baz:NoReturn at /home/luis/code/crystal-lang/crystal/foo.cr 10:3
0x0000000000434c06: ??? at /home/luis/code/crystal-lang/crystal/foo.cr 6:3
0x0000000000434bf6: ??? at /home/luis/code/crystal-lang/crystal/foo.cr 2:3
0x00000000004306e1: ??? at /home/luis/code/crystal-lang/crystal/src/signal.cr 129:1
0x0000000000434ad9: main at /home/luis/.cache/crystal/macro70478608.cr 12:15
@luislavena
luislavena / 0-create.log
Last active May 13, 2018 16:18
Setup fixed IP for docker-machine (boot2docker)
$ docker-machine create --driver virtualbox --virtualbox-cpu-count 2 --virtualbox-memory 2048 --virtualbox-hostonly-cidr "192.168.59.3/24" default
$ docker-machine ssh default
# add script (shown below) and reboot
$ docker-machine regenerate-certs default

Crystal benchmark (nightly vs new-fibers)

This benchmark compares the performance of new fibers implementation vs current (PCL backed one).

  • Code was compiled with --release flag
  • Benchmarks were performed on same computer (localhost)

Benchmarks

require "benchmark/ips"
require "granola"
require "json"
require "oj"
require "yajl"
require "multi_json"
require "multi_json/adapters/json_gem"
require "multi_json/adapters/oj"
@luislavena
luislavena / [email protected]
Created August 13, 2015 21:15
Setup GnuPG agent on systemd (Ubuntu)
# place unit in /etc/systemd/system/[email protected]
# start and enable with `systemctl start|enable gpg-agent@username`
[Unit]
Description=GnuPG private key agent for %I
IgnoreOnIsolate=true
[Service]
User=%i
Type=forking
ExecStart=/usr/bin/gpg-agent --daemon --write-env-file "${HOME}/.gpg-agent-info"