Skip to content

Instantly share code, notes, and snippets.

View mikera's full-sized avatar

Mike Anderson mikera

View GitHub Profile
@weavejester
weavejester / gist:1001206
Created May 31, 2011 20:27
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
@searls
searls / maven-git-flow.sh
Created June 24, 2011 00:25
My approximation of nvie's git flow when using maven-release-plugin to cut releases. - http://nvie.com/posts/a-successful-git-branching-model/
# How to perform a release with git & maven following the git flow conventions
# ----------------------------------------------------------------------------
# Finding the next version: you can see the next version by looking at the
# version element in "pom.xml" and lopping off "-SNAPSHOT". To illustrate,
# if the pom's version read "0.0.2-SNAPSHOT", the following instructions would
# perform the release for version "0.0.2" and increment the development version
# of each project to "0.0.3-SNAPSHOT".
# branch from develop to a new release branch
git checkout develop
@mikera
mikera / gist:1104578
Created July 25, 2011 16:57
Clojure quick tutorial
;; Objective
;; 1. Learn Clojure by doing Clojure
;;
;; Pre-requisites
;; You need to have a running Clojure REPL
;; see: http://clojure.org/getting_started
; Hello World in Clojure
(println "Hello World")
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@elimisteve
elimisteve / goroutines2.go
Last active February 18, 2024 01:52
Programming Challenge: Launch 4 threads, goroutines, coroutines, or whatever your language uses for concurrency, in addition to the main thread. In the first 3, add numbers together (see sample code below) and pass the results to the 4th thread. That 4th thread should receive the 3 results, add the numbers together, format the results as a strin…
// Steve Phillips / elimisteve
// 2013.01.03
// Programming Challenge: Launch 4 threads, goroutines, coroutines, or whatever your language uses for concurrency,
// in addition to the main thread. In the first 3, add numbers together (see sample code below) and pass the results
// to the 4th thread. That 4th thread should receive the 3 results, add the numbers together, format the results as
// a string (see sample code), and pass the result back to `main` to be printed.
//
// Do this as succinctly and readably as possible. _Go!_ #golang #programming #concurrency #challenge
package main
@codification
codification / core.clj
Last active December 16, 2015 00:30
FP-meetup Token-Ring
(ns tokenring.core
(:require [lamina.core :as lamina])
(:require [aleph.tcp :as aleph])
(:require [gloss.core :as gloss]))
(defn connect-and-send [message]
(println (str "connecting and sending: " message))
(let [ch (lamina/wait-for-result
(aleph/tcp-client {:host "192.168.48.35"
;;:host "localhost"
@vilmibm
vilmibm / dnd.clj
Created October 15, 2013 01:22
I forgot my dice during d&d tonight so I wrote this.
(defmacro roll [rolls _ sides & body]
`(+ (if (nil? ~body) 0 ~body) (reduce + (repeatedly ~rolls #(+ 1 (rand-int ~sides))))))
(roll 1 d 4) ; dagger
(roll 1 d 20 + 6) ; initiative
(roll 4 d 4 + 4) ; 7th level magic missle
@rm-hull
rm-hull / chess.cljs
Last active August 29, 2015 13:56
OM version of Garry Kasparov - Veselin Topalov ; Hoogovens A Tournament Wijk aan Zee NED 1999.01.20 - adapted from https://raw2.github.com/danieroux/rubyfuza2014/master/src/rubyfuza/core.cljs
; Adapted from https://raw2.github.com/danieroux/rubyfuza2014/master/src/rubyfuza/core.cljs
(ns rubyfuza.core
(:require-macros
[cljs.core.async.macros :refer [go]])
(:require
[clojure.string :as str]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :as async :refer [put! chan <! >! timeout]]))
@candera
candera / ssh-repl.org
Last active February 9, 2019 07:50
ssh-repl

Embedding an SSH-accessible REPL in a Clojure process

N.B. This is now a library, thanks to the efforts of the wonderful @mtnygard. And the README does a good job of making clear just how terrible an idea it is to actually do this. :)

As any Clojurist knows, the REPL is an incredibly handy development tool. It can also be useful as a tool for debugging running programs. Of course, this raises the question of how to limit access to the REPL to authorized parties. With the Apache SSHD library, you can embed an SSH server in any JVM process. It takes only a little code to hook this up to a REPL, and to limit access either by public key or

@ctford
ctford / map.clj
Created May 30, 2014 21:15
An alternative implementation of map that won't silently return nils for missing keys.
(ns strict-map.map)
(deftype StrictMap [inner]
clojure.lang.IPersistentMap
(assoc [this k v]
(StrictMap. (.assoc inner k v)))
(assocEx [this k v]
(StrictMap. (.assocEx inner k v)))
(without [this k]
(StrictMap. (.without inner k)))