Skip to content

Instantly share code, notes, and snippets.

View jasonjckn's full-sized avatar

Jason Jackson jasonjckn

View GitHub Profile
;;; ~/.doom.d/+evil-enhancements.el -*- lexical-binding: t; -*-
(defun outer-sexp-at-region (beg end &optional skip-comment?)
(pcase-let ((`(,beg1 ,end1)
(save-excursion
(save-match-data
(goto-char beg)
(sp-forward-whitespace)
@jasonjckn
jasonjckn / keybase.md
Created October 1, 2014 02:09
keybase.md

Keybase proof

I hereby claim:

  • I am jasonjckn on github.
  • I am jasonjckn (https://keybase.io/jasonjckn) on keybase.
  • I have a public key whose fingerprint is 6204 6D62 8B47 2280 347E 419C 6DBE FD5E C8CB 22F2

To claim this, I am signing this object:

@jasonjckn
jasonjckn / gist:5c7d537042343d49fff6
Last active August 29, 2015 14:01
combinator parser in scala
// Parser T is a monad around a function that accepts input and returns Result (i.e. Consumed input, or Failed to parse input)
// the a.flatMap(v=>b) function (Monad bind) will produce a new monad with new function that composes the the parser functions in a and b.
abstract class Result[T]
case class Failed[T](desc: String) extends Result[T]
case class Consumed[T](value: T, rest: String) extends Result[T]
trait Parser[T] extends ((String) => Result[T]) {
def flatMap[A](v2m: ((T) => Parser[A])): Parser[A] = {
new Parser[A] {
@jasonjckn
jasonjckn / gist:5cfa1e2c7768f2039154
Created May 20, 2014 01:41
basic combinator parser in scala
abstract class Result[T]
case class Failed[T](desc: String) extends Result[T]
case class Consumed[T](value: T, rest: String) extends Result[T]
trait Parser[T] extends ((String) => Result[T]) {
def flatMap[A](v2m: ((T) => Parser[A])): Parser[A] = {
new Parser[A] {
def apply(input: String) = {
Parser.this(input) match {
case Consumed(v, rest) => v2m(v)(rest)
@jasonjckn
jasonjckn / okay
Created March 17, 2013 06:03
okay
test
one two three
(def identifier (m-re #"[a-zA-Z][a-zA-Z0-9]*")) ;; TODO: Is this accurate?
(def modifier (one-of-symb "public protected private static abstract final native
sychronized transient volatile strictfp"))
(def infix-op (one-of-symb "|| && | ^ & == = < > <= << >> > - + * / %"))
(def prefix-op (one-of-symb "++ -- ! ~ + -"))
(def postfix-op (one-of-symb "++ --"))
(def basic-type (one-of-symb "byte short char int long float double boolean"))
(def void (symb "void"))
(ns test1.core
(:use [clarsec core monad])
(:use [clojure.pprint :only (pprint)]))
(def perm (<$> keyword
(<|> (symb "public")
(symb "private")
(symb "protected"))))
(def type
(def data (slurp "gettysburg.txt"))
(def substrs (for [l (range 10 1 -1)
d (range 0 (- (count data) l))]
(vec (take l (drop d data)))))
(def ff (filter #(= (seq %) (rseq %)) substrs))
#_ (first ff)
(defn Y [f]
(f f))
((Y (fn [coll]
(if-let [[a0 & as] (seq coll)]
(+ a0 ((h h) as))
0)))
[1 2 3 4 5])
(ns xml
(:use
[eu.dnetlib.clojure.clarsec]
[eu.dnetlib.clojure.monad]))
;; Parsing simplified XML:
;;
;; Sample Input:
(def input