Skip to content

Instantly share code, notes, and snippets.

Avatar

David Ellis davidkellis

View GitHub Profile
@davidkellis
davidkellis / Vagrantfile
Created Nov 19, 2019
vagrant box: ubuntu 18.04 + rustup + rust + tesseract
View Vagrantfile
# -*- 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
View able v1 parse tree and ast example
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=""
View gist:b87695e8cf8cf7b762a67ea7c60a6b39
# 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 Dec 10, 2018
bar project in Crystal (that calls the foo library, implemented in Rust - https://gist.github.com/davidkellis/78bd7c65f31539b183f1b60c43339ff9)
View README.md

How to run:

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

confefe

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

confefe supports 8 different data types, plus comments:

  • nil/null
  • bool
  • int
  • decimal
  • string
View bot.cf
server:
address: "localhost:6667"
channel: "#hello"
greetings:
- passthru: true
filter: "boss"
message: "Hi, boss!"
- passthru: false
filter: ".*"
View package.cf
name: "confefe"
version: "1.2.0"
tags:
- "foo"
- "bar"
- "baz"
authors: ["Bill", "Bob"]
dependencies: [ # dependencies captured in a nested array
["stdlib", "~> 1.2"],
View gist:999db7501342ca2c85d4e49513c67d2c
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