Skip to content

Instantly share code, notes, and snippets.

@odyssomay
odyssomay / test.cljs
Created October 18, 2011 15:39
Clojurescript symbol to string
(ns test)
(console/log (str 'a))
@odyssomay
odyssomay / profile.clj
Created August 4, 2012 14:05
clojure.contrib.profile for 1.3+
;;; profile.clj: simple code profiling & timing
;; by Stuart Sierra, http://stuartsierra.com/
;; May 9, 2009
;; Copyright (c) Stuart Sierra, 2009. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this
;; distribution. By using this software in any fashion, you are
@odyssomay
odyssomay / gist:3893111
Created October 15, 2012 15:30
"Failed" dungeon generation
(defn rooms-intersect?
[{[x1 y1] :offset [sx1 sy1] :size} {[x2 y2] :offset [sx2 sy2] :size}]
(not (or (>= x1 (+ x2 sx2))
(>= y1 (+ y2 sy2))
(>= x2 (+ x1 sx1))
(>= y2 (+ y1 sy1)))))
(defn is-inside-room? [[x y] {[xr yr] :offset [sx sy] :size}]
(and (> x xr)
(< x (dec (+ xr sx)))
@odyssomay
odyssomay / rresize.js
Created October 25, 2012 17:50
rresize: jquery plugin for recursive resizing
/*
* rresize, jquery plugin by Jonathan Fischer Friberg
* https://github.com/odyssomay
*
* Licensed under WTFPL
* http://sam.zoy.org/wtfpl/
*/
/*
* Usage:
@odyssomay
odyssomay / split.cljs
Created October 25, 2012 21:36
jQuery Split pane
(ns ui.split
(:require [ui.trigger :as trigger]
[jayq.util :as util])
(:use [jayq.core :only [$ append css inner]]))
(defn set-css [outer f-elem s-elem options]
(let [{:keys [split-type start-position]} options
base-css (case split-type
:vertical {:width "100%"}
:horizontal {:float "left" :height "100%"})
@odyssomay
odyssomay / gist:4027155
Created November 6, 2012 20:04
Better bracket highlighting for the SpaceCadet color scheme in sublime
<dict>
<key>settings</key>
<dict>
...
<!-- add: -->
<key>bracketsForeground</key>
<string>#FF0000</string>
<key>bracketsOptions</key>
@odyssomay
odyssomay / SpecRunner.html
Created October 14, 2011 12:35
Clojurescript testing using jasmine
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css">
<script type="text/javascript" src="jasmine/jasmine.js"></script>
@odyssomay
odyssomay / gist:1078370
Created July 12, 2011 16:34
the longest java stacktrace I have seen
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.util.IdentityHashMap.get(IdentityHashMap.java:331)
at javax.swing.RepaintManager.extendDirtyRegion(RepaintManager.java:576)
at javax.swing.RepaintManager.addDirtyRegion0(RepaintManager.java:404)
at javax.swing.RepaintManager.addDirtyRegion(RepaintManager.java:468)
at javax.swing.JComponent.repaint(JComponent.java:4736)
at java.awt.Component.repaint(Component.java:3117)
at javax.swing.text.DefaultCaret.repaint(DefaultCaret.java:245)
at javax.swing.text.DefaultCaret.changeCaretPosition(DefaultCaret.java:1261)
at javax.swing.text.DefaultCaret.handleSetDot(DefaultCaret.java:1170)