Skip to content

Instantly share code, notes, and snippets.

View wilkes's full-sized avatar

Wilkes Joiner wilkes

View GitHub Profile
(ns rabscuttle.parser-combinator)
(comment
"Working through http://www.cs.nott.ac.uk/~gmh//parsing.ps"
"A parser is a function that takes in input and returns lazy list of list of parsed value, and remaining input pairs")
(def letters (map char (lazy-cat (range (int \a) (inc (int \z)))
(range (int \A) (inc (int \Z))))))
(def digits (map char (lazy-cat (range (int \0) (inc (int \9))))))
(ns rabscuttle.parser-combinator)
(comment
"Working through http://www.cs.nott.ac.uk/~gmh//parsing.ps"
"A parser is a function that takes in input and returns lazy list of list of parsed value, and remaining input pairs")
(def letters (map char (lazy-cat (range (int \a) (inc (int \z)))
(range (int \A) (inc (int \Z))))))
(def digits (map char (lazy-cat (range (int \0) (inc (int \9))))))
;; clojure
(require 'clojure-paredit)
;; slime
(require 'slime)
(slime-setup)
;; slime fancy repl
(require 'slime-repl)
(require 'magit)
(defun my-magit-run (&rest args)
(apply #'magit-run (cons "git" args))
(message (mapconcat #'identity args " ")))
(defun my-magit-hack ()
(interactive)
(let ((working-branch (magit-get-current-branch)))
(my-magit-run "checkout" "master")
(ns rabscuttle.parser-combinator)
(comment
"Working through http://www.cs.nott.ac.uk/~gmh//parsing.ps"
"parser is a function that takes in input and returns [[v, inp]]")
;; Primitive Parsers
(defn succeed [v] (fn [inp] [[v inp]]))
(defn fail [inp] [])
(ns rabscuttle.test-json
(:require [rabscuttle.json :as json])
(:use [clojure.contrib.test-is]))
(deftest encode-value
(let [pairs [["string" "\"string\""]
["" "\"\""]
["\"" "\"\"\""]
[:keyword "\"keyword\""]
['symbol "\"symbol\""]
(try
(.createNewFile file)
(catch IOException e
(throw (Exception. (str "Failed to create " file) e))))
(require 'slime)
(slime-setup)
(require 'clojure-auto)
(require 'clojure-paredit)
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
;; These are extra key defines because I kept typing them.
;; Within clojure-mode, have Ctrl-x Ctrl-e evaluate the last
;; expression.
(defn- macosx? []
(-> "os.name" System/getProperty .toLowerCase
(.startsWith "mac os x")))
(defn- macosx? []
(.startsWith (.toLowerCase (System/getProperty "os.name"))
"mac os x"))
(ns org.buntin.github.github
(:require [org.danlarkin.json :as json])
(:import [org.apache.http.impl.client DefaultHttpClient]
[org.apache.http.client.methods HttpGet]
[org.apache.http.util EntityUtils]))
(def user "%s")
(def search "search/%s")
(def commit "%s/%s/commit/%s")
(def recent "%s/%s/commits/%s")