Skip to content

Instantly share code, notes, and snippets.

View alexkehayias's full-sized avatar

Alex Kehayias alexkehayias

View GitHub Profile
@alexkehayias
alexkehayias / main.rs
Created November 19, 2016 23:24
Generic linked list in Rust
use std::fmt;
enum LinkedList<T> {
// Can't have a recursive type declaration here because there is no way
// to size it. So we put it on the Heap by using a Box and now we can
// have a recursive type.
Pair(T, Box<LinkedList<T>>),
Nil,
}

Keybase proof

I hereby claim:

  • I am alexkehayias on github.
  • I am alexkehayias (https://keybase.io/alexkehayias) on keybase.
  • I have a public key whose fingerprint is 9675 1D76 2AB1 35E5 1C0F FC9A DC77 D1B3 483E 882E

To claim this, I am signing this object:

@alexkehayias
alexkehayias / Gemfile
Last active May 23, 2019 23:00
Rails environment using Nix
source 'https://rubygems.org'
# OAuth
gem 'oauth2', '~> 1.0.0'
gem 'rails'
@alexkehayias
alexkehayias / org-mode-grammar.clj
Last active March 15, 2022 16:30
The start of an EBNF grammer to parse org-mode docs
(require '[instaparse.core :as insta])
(def org-parse
(insta/parser
"<DOC> = <EOL>* heading*
heading = level <SPC> [status <SPC>] text tag* [<EOL> content]
sub-heading = sub-level <SPC> [status <SPC>] text tag* [<EOL> content]
EOL = '\n' | '\r\n' | #'$'
SPC = ' '
level = #'\\*+'
Verifying that +alexkehayias is my blockchain ID. https://onename.com/alexkehayias
@alexkehayias
alexkehayias / gist:f1e81c164e1feb9877f8
Created February 22, 2015 00:46
Call some function asynchronously, reduce the results, and call the callback with the result
(ns user
(:require [cljs.core.async :refer [chan <! >!]]
[cljs.core.async :as async]
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn async-reduce
"Reduce a value over a collection of functions asynchronously
and merge the results.
Example:
@alexkehayias
alexkehayias / main.clj
Created August 17, 2012 15:02
Setting dotcloud env variables (not working)
(defmacro maybe
"Assuming that the body of code returns X, this macro returns [X nil] in the case of no error
and [nil E] in event of an exception object E."
[& body]
`(try [(do ~@body) nil]
(catch Exception e#
[nil e#])))
(defn safe-slurp
"Slurp content of given filename. Return nil on error reading the file."
@alexkehayias
alexkehayias / gist:1604151
Created January 13, 2012 01:28
Lein error
user=> computer_name:one user$ ./script/deps
Getting lein deps...
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6476)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$script_opt.invoke(main.clj:339)