Skip to content

Instantly share code, notes, and snippets.

View christianromney's full-sized avatar
🏠
Working from home

Christian Romney christianromney

🏠
Working from home
View GitHub Profile
@christianromney
christianromney / abstraction.clj
Last active August 29, 2015 13:55
An example of how to define abstractions in Clojure
;; BinOp ::= [Symbol Operand Operand]
;; Operand ::= Number | BinaryOperation
(defprotocol Numerical
"A thing which has a numerical value"
(value [this]))
(defprotocol PrintableMathExpression
"A mathematical expression which can be printed
using infix or prefix notation"
;; Geiser settings
(setq geiser-active-implementations '(racket))
(setq geiser-repl-startup-time 10000)
(setq geiser-repl-history-filename "~/.emacs.d/geiser-history")
(setq geiser-repl-query-on-kill-p nil)
(setq geiser-implementations-alist
'(((regexp "\\.scm$") racket)
((regexp "\\.ss$") racket)
((regexp "\\.rkt$") racket)))
;; Geiser settings
(setq geiser-active-implementations '(racket))
(setq geiser-repl-startup-time 10000)
(setq geiser-repl-history-filename "~/.emacs.d/geiser-history")
(setq geiser-repl-query-on-kill-p nil)
(setq geiser-implementations-alist
'(((regexp "\\.scm$") racket)
((regexp "\\.ss$") racket)
((regexp "\\.rkt$") racket)))
@christianromney
christianromney / my-brews.txt
Created February 28, 2014 22:29
Tools I find useful
ack # search
ansible # config mgmt
apachetop # how's apache
apple-gcc42 # helps to build certain software
aria2 # faster downloads
asciidoc # documentation
aspell # for emacs/vim spell-checking
bazaar # every now and then I clone a repo hosted by ubuntu
brew-desc # get better descriptions of homebrew utils
casperjs # javascript testing and screenscraping
@christianromney
christianromney / LDHkw.markdown
Created April 9, 2014 16:46
A Pen by Christian Romney.

Keybase proof

I hereby claim:

  • I am christianromney on github.
  • I am christianromney (https://keybase.io/christianromney) on keybase.
  • I have a public key whose fingerprint is 1A2D 2EE2 4C25 03FD 7D2F CDF6 111F 9EEB 195F 184E

To claim this, I am signing this object:

####<Jul 25, 2008 5:04:19 PM EDT> <Error> <HTTP> <nclwebdevapp02> <NCLWEBDEVAPP02> <ExecuteThread: '12' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-101019> <[ServletContext(id=67489679,name=myncl,context-path=/myncl)] Servlet failed with IOException
java.io.FileNotFoundException: /home/weblogic/bea/user_projects/domains/NCLWEBDEVdom/./NCLWEBDEVAPP02/.wlnotdelete/extract/NCLWEBDEVAPP02_myncl_myncl/jsp_servlet/_common/_layout/__home_template.java (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at java.io.FileWriter.<init>(FileWriter.java:73)
at weblogic.servlet.jsp.Jsp2Java.makeOutputStream(Jsp2Java.java:301)
at weblogic.utils.compiler.CodeGenerator.generateCode(CodeGenerator.java:337)
at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:286)
at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:388)

Clojure does Objects Better

A hopefully short and concise explanation as to how Clojure deals with Objects. If you already write Clojure, this isn't for you.

You know what an Interface is if you write/read Java or PHP 5+. In Clojure it might be called defprotocol.

user> (defprotocol IABC
        (also-oo [this])
        (another-fn [this x]))

IABC

(defn recursive-take
"Recursively take from a list based on the operation list
For example [:h :l :l :h] will take using the following operations
until the list is exhausted: first last last first."
[col operations]
(loop [c col ops (cycle operations) acc []]
(if (empty? c)
acc
(let [op (first ops)
[head-fn tail-fn] (if (= op :h)