$ ./bin/crystal --version
Using compiled compiler at .build/crystal
Crystal 1.8.0-dev [58fb584cb87] (2023-01-21)
LLVM: 14.0.1
Default target: aarch64-apple-darwin21.6.0
unless ARGV.size > 0 | |
puts " Missing executable file argument" | |
puts " Usage (in a Dockerfile)" | |
puts " RUN crystal run ./path/to/list-deps.cr -- ./bin/executable" | |
exit 1 | |
end | |
executable = File.expand_path(ARGV[0]) | |
unless File.exists?(executable) |
$ ./bin/crystal --version
Using compiled compiler at .build/crystal
Crystal 1.8.0-dev [58fb584cb87] (2023-01-21)
LLVM: 14.0.1
Default target: aarch64-apple-darwin21.6.0
A Pen by Brian J. Cardiff on CodePen.
require "compiler/crystal/**" | |
class Object | |
def dump_inspect(io, level) | |
io << " " * level | |
to_s(io) | |
io << " :: " << self.class | |
end | |
end |
These configuration will let you use CodeLLDB extension to debug Crystal programs.
Store them as .vscode/tasks.json
and .vscode/launch.json
in your project.
When starting the debugging the current file will be built in the bin/
folder (as in shards build
).
Note: You will need to set the crystal binary path in tasks.json
"command"
field and the whole path in launch.json "initCommands"
. Read more at #8538
class ScopedCache | |
attr_reader :name | |
def initialize(cache, name, options = nil) | |
@cache = cache | |
@name = name | |
@options = options | |
end | |
def read(key) |
data = [{"Brian", 42}, {"Alan", 30}, {"Brian", 32}] | |
# unstable | |
data.sort_by &.[0] # => [{"Brian", 42}, {"Alan", 30}, {"Brian", 32}] | |
# stable | |
data.map_with_index { |d,i| {d,i} }.sort_by { |di| {di[0][0], di[1]} }.map { |di| di[0] } # => [{"Alan", 30}, {"Brian", 42}, {"Brian", 32}] |
FROM ruby:2.2 | |
RUN \ | |
# node | |
curl -sL https://deb.nodesource.com/setup_5.x | bash - && \ | |
apt-get install -y nodejs && \ | |
# cleanup | |
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
# The lock is at the end of the unions | |
# | |
# CHECK: %"(Bool | Int32)" = type { i32, [1 x i64], i32 } | |
local_var = uninitialized Int32 | Bool | |
# After the alloca the lock is initialized as free (1) | |
# | |
# CHECK: %local_var = alloca %"(Bool | Int32)" | |
# CHECK: %0 = getelementptr inbounds %"(Bool | Int32)", %"(Bool | Int32)"* %local_var, i32 0, i32 2 |