Skip to content

Instantly share code, notes, and snippets.

Andy Nicholson anicholson

Block or report user

Report or block anicholson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View result.cr
class ResultError < Exception; end
abstract class Result(V, E)
abstract def value : V
abstract def error : E
abstract def ok? : Boolean
abstract def error? : Boolean
abstract def andThen(&block : self -> self) : self
View boom.txt
Error in /Users/andy/projects/consider_crystal/macro.cr:6: expanding macro
JSON.mapping(
^~~~~~~
in /Users/andy/projects/consider_crystal/macro.cr:6: expanding macro
JSON.mapping(
^
View pbcopy
Error in /Users/andy/projects/consider_crystal/macro.cr:6: expanding macro
JSON.mapping(
^~~~~~~
in /Users/andy/projects/consider_crystal/macro.cr:6: expanding macro
JSON.mapping(
^
View wat.cr
require "benchmark"
Benchmark.bm do |x|
(1..10).each do |i|
x.report "ENV[PATH]: in a block" do
# i.times { C.getenv("PATH") }
i.times { 1 * i }
end
end
end
View graal.txt
user system total real
Run 0 14.010000 0.470000 14.480000 ( 2.773481)
Run 1 2.700000 0.210000 2.910000 ( 0.635449)
Run 2 1.170000 0.010000 1.180000 ( 0.300033)
Run 3 1.930000 0.080000 2.010000 ( 0.372750)
Run 4 1.430000 0.020000 1.450000 ( 0.325396)
Run 5 1.460000 0.020000 1.480000 ( 0.346627)
Run 6 1.350000 0.060000 1.410000 ( 0.366876)
Run 7 1.230000 0.020000 1.250000 ( 0.356951)
Run 8 1.020000 0.010000 1.030000 ( 0.452953)
View delayed_job
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require_relative '../config/environment'
require 'rack'
# Take the whole script down if anything goes remotely wrong
Thread.abort_on_exception = true
@anicholson
anicholson / Dockerfile
Last active Oct 23, 2016
Crystal Ubuntu package does not install all required dependencies
View Dockerfile
FROM ubuntu
MAINTAINER Andy Nicholson <andrew@anicholson.net>
RUN apt-get update && \
apt-get install -y apt-transport-https && \
apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54 && \
echo "deb https://dist.crystal-lang.org/apt crystal main" > /etc/apt/sources.list.d/crystal.list && \
apt-get update && \
apt-get install -y crystal
@anicholson
anicholson / README.md
Created Aug 31, 2016
Crystal Language resources
View README.md

Installing Crystal

  • On OSX: brew install crystal-lang
  • On Linux: [See instructions][installation_instructions]
  • On Windows: Sorry, not yet. You may be able to, but it’s not officially supported.

Further talks

  • [Matz' Keynote @ RubyConf 2014][matz]
  • [Consider Static Typing: Tom Stuart @ RubyConfAU 2015][stuart]
View boot.sh
#!/bin/bash
wait_until_up () {
echo "Waiting for $1 to come up!"
until $(curl --output /dev/null --silent --fail "$2"); do
printf '.'
sleep 1
done
You can’t perform that action at this time.