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
(ns async.core
(:require [clojure.core.async :as async :refer :all]
[clojure.core.async.lab :as lab]
[clojure.data.generators :as gen])
(:gen-class))
;; A Message carries some text to be communicated
;; and a wake channel which notifies the originator
;; that it may transmit again.
(defrecord Message [text wake])
(ns circuito.core
(:require [clojure.core.async :as async :refer :all])
(:gen-class))
(def ^:dynamic *timeout* 300)
;; Like defn, but executes body in a go block, allowing at most *timeout* milliseconds for completion
(defmacro defcommand [name args & body]
`(defn ~name ~args
(let [t# (timeout *timeout*)
NameVirtualHost *:80
<Directory "/Users/christian/src/work/ncl/drupal">
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<Location /balancer-manager>
SetHandler balancer-manager
(ns async.core
(:require [clojure.core.async :as async :refer :all])
(:gen-class))
;; Based on http://talks.golang.org/2012/concurrency.slide#30
;;
;; The Go semantics don't quite translate the same way to core.async
;; I've swapped the talk and wait channels so that each "boring"
;; goroutine creates its own _private_ wait channel / semaphore.
;;

Emacs Cheatsheet

C-c C-s +show source code for function C-c C-d +show documentation for function C-c C-j +show Javadoc for symbol at point

C-c C-k +compile Clojure file C-c M-n +change nrepl namespace to current C-c M-o +clear nrepl C-x C-e +send sexp to nrepl

(ns commons.core
(import [org.apache.commons.lang3.builder
ToStringBuilder
EqualsBuilder
HashCodeBuilder])
(:gen-class))
(defn- make-hash-code
[obj prop value]
(doto (HashCodeBuilder.)
# [RTC:XXXX] Some piece of code learned to do something new
#
# After a blank line, I can give more details about the
# nature of the change. Don't just list the files you
# changed. Tell us something about *why* the change was
# needed or about the way in which you met the requirement.
# In other words, something we wouldn't know by merely
# looking at the commit details.
#
# --- Additional guidance (from Linus Torvalds) ---
*.7z
*.bak
*.bz2
*.bzip
*.class
*.deb
*.dmg
*.ear
*.egg
*.gem
@christianromney
christianromney / append.js
Last active December 16, 2015 22:29
Requires underscore.js
function append(x, y) {
if (!(_.isArray(x)) || 0 == x.length) return y;
var t = append(_.rest(x), _.clone(y));
t.unshift(_.first(x));
return t;
}
/*
append([1,2,3], [4,5,6]);
@christianromney
christianromney / partial.rkt
Last active December 16, 2015 22:29
Partial function application
#lang racket
(define append
(lambda (x y)
(cond ((empty? x) y)
(else (cons (first x)
(append (rest x) y))))))
(define partial
(lambda (f . args)
(lambda x