Skip to content

Instantly share code, notes, and snippets.

View davidkellis's full-sized avatar

David Ellis davidkellis

View GitHub Profile
@davidkellis
davidkellis / Vagrantfile
Created November 19, 2019 20:37
vagrant box: ubuntu 18.04 + rustup + rust + tesseract
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
david:~/Dropbox/projects/able/compiler $ crystal src/cli.cr -- -f ../examples/helloworld.able
parse tree:
(apply File ; id=5414918336 rule_name="File" label=""
(choice ; id=5414918416 label=""
(seq ; id=5414918496 label=""
(apply PackageDecl ; id=5414919936 rule_name="PackageDecl" label=""
(choice ; id=5414920016 label=""
(seq ; id=5414920096 label=""
"package"[id=5452605472 label=""]
(apply package_ident ; id=5414904128 rule_name="package_ident" label=""
@davidkellis
davidkellis / gist:b87695e8cf8cf7b762a67ea7c60a6b39
Last active December 21, 2018 19:23
guessing game (ruby)
# solution to https://www.reddit.com/r/dailyprogrammer/comments/pii6j/difficult_challenge_1/
def main
lower_bound = 1
upper_bound = 100
puts "Think of a number between 1 and 100, inclusive."
puts "At each guess, answer with 'l' to indicate your number is lower than the guess, 'h' to indicate your number is higher than the guess, or 'y' to indicate the guess is correct."
while true
guess = (lower_bound + upper_bound) / 2
puts "Is #{guess} your number?"
@davidkellis
davidkellis / README.md
Last active December 10, 2018 22:19
bar project in Crystal (that calls the foo library, implemented in Rust - https://gist.github.com/davidkellis/78bd7c65f31539b183f1b60c43339ff9)

How to run:

$ crystal run src/bar.cr
hello from crystal
Just called a Rust function from C!
@davidkellis
davidkellis / Cargo.toml
Last active December 10, 2018 22:19
foo project in rust (to be called from a crystal project called bar - https://gist.github.com/davidkellis/f40588787a354aa7d44c4dec4c52ad50)
[package]
name = "foo"
version = "0.1.0"
authors = ["davidkellis <davidkellis@gmail.com>"]
[dependencies]
[lib]
crate-type = ["cdylib"]
@davidkellis
davidkellis / part1.rb
Created December 7, 2018 18:15
aocday1
ints = File.readlines("input.txt").map(&:to_i)
puts ints.sum

confefe

confefe, pronounced con-feef, is a simple configuration language

confefe supports 8 different data types, plus comments:

  • nil/null
  • bool
  • int
  • decimal
  • string
server:
address: "localhost:6667"
channel: "#hello"
greetings:
- passthru: true
filter: "boss"
message: "Hi, boss!"
- passthru: false
filter: ".*"
name: "confefe"
version: "1.2.0"
tags:
- "foo"
- "bar"
- "baz"
authors: ["Bill", "Bob"]
dependencies: [ # dependencies captured in a nested array
["stdlib", "~> 1.2"],
davidellis@davidellis:~/Dropbox/projects/benchmarks (master) $ ./run.rb
Running base64 benchmark suite
base64/crystal0.25.0
base64/ruby2.5.1
Running helloworld benchmark suite
helloworld/crystal0.25.0
helloworld/ruby2.5.1
Running json benchmark suite