Skip to content

Instantly share code, notes, and snippets.

View luislavena's full-sized avatar

Luis Lavena luislavena

View GitHub Profile

Ref: crystal-lang/distribution-scripts#127 (comment)

Synthetic micro benchmark of basic HTTP server against localhost, this time Crystal 1.2.1 on multiple versions of Alpine:

# A very basic HTTP server
require "http/server"

server = HTTP::Server.new do |context|
  context.response.content_type = "text/plain"
# syntax = docker/dockerfile:1.2
# ---
FROM alpine:3.12 AS base
# upgrade system and install dependencies
RUN set -eux; \
apk upgrade --no-cache
# download and copy crystal
[automount]
enabled=true
mountFsTab=true
options="metadata,uid=1000,gid=1000,fmask=11,umask=22"
[network]
generateHosts=true
generateResolvConf=true
@luislavena
luislavena / 0-source-drone.jsonnet
Last active August 24, 2019 09:56
Drone CI - missing `purge` when converting jsonnet to YAML
local Pipeline(version) = {
kind: "pipeline",
steps: [
{
name: "build",
image: "plugins/docker",
settings: {
dockerfile: "builder-" + version + ".dockerfile",
registry: "img.company.com",
repo: "img.company.com/builder",
[core]
autocrlf = false
excludesfile = ~/.gitignore.global
[color]
ui = auto
[push]
default = current
followTags = true
$ crystal --version
Crystal 0.24.2 [4f9ed8d03] (2018-03-08)
LLVM: 4.0.0
Default target: x86_64-unknown-linux-gnu
$ time make crystal stats=true
Using /usr/bin/llvm-config-5.0 [version=5.0.0]
g++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm-5.0/include -std=c++0x -fuse-ld=gold -Wl,--no-keep-files-mapped -Wl,--no-map-whole-files -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -DNDEBUG -g1 -fno-exceptions -DLLVM_BUILD_GLOBAL_ISEL -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC -c -o src/ext/sigfault.o src/ext/sigfault.c
@luislavena
luislavena / 0-ubuntu-wsl.aptfile
Last active August 20, 2019 15:02
Quick setup of my Ubuntu (WSL)
#!/usr/bin/env aptfile
# NOTE:
# This script uses `bash-aptfile`, which can be obtained from GitHub:
# https://github.com/seatgeek/bash-aptfile
#
# Once `aptfile` has been installed (per instructions), you can invoke this
# script with `sudo`:
#
# $ sudo aptfile path/to/my_setup.aptfile
@luislavena
luislavena / 0-intro.md
Last active December 14, 2021 06:39
Collecting information about Ruby gems installed

Introduction

Hello! I'm doing some analysis of installed Ruby gems, specially those that require a compiler toolchain to be installed.

This analysis will help me determine an usage pattern and potentially work with gem authors to improve platform support for those gems.

Will be great if you can help me collect this information.

abstract class Foo
VERBS = %w(GET POST PUT)
{% for method in ::Foo::VERBS %}
macro {{ method.downcase.id }}(*args, **params)
\{% params[:via] = {{ method.downcase }} %}
match(\{{*args}}, \{{**params}})
end
{% end %}
require "benchmark"
class Foo
getter query : String?
def initialize(@query)
end
def method1
@query if @query && !@query.try(&.empty?)