Skip to content

Instantly share code, notes, and snippets.

@odyssomay
odyssomay / gist:4027155
Created Nov 6, 2012
Better bracket highlighting for the SpaceCadet color scheme in sublime
View gist:4027155
<dict>
<key>settings</key>
<dict>
...
<!-- add: -->
<key>bracketsForeground</key>
<string>#FF0000</string>
<key>bracketsOptions</key>
@odyssomay
odyssomay / split.cljs
Created Oct 25, 2012
jQuery Split pane
View split.cljs
(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 / rresize.js
Created Oct 25, 2012
rresize: jquery plugin for recursive resizing
View rresize.js
/*
* rresize, jquery plugin by Jonathan Fischer Friberg
* https://github.com/odyssomay
*
* Licensed under WTFPL
* http://sam.zoy.org/wtfpl/
*/
/*
* Usage:
@odyssomay
odyssomay / gist:3893111
Created Oct 15, 2012
"Failed" dungeon generation
View gist:3893111
(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 / profile.clj
Created Aug 4, 2012
clojure.contrib.profile for 1.3+
View profile.clj
;;; 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 / test.cljs
Created Oct 18, 2011
Clojurescript symbol to string
View test.cljs
(ns test)
(console/log (str 'a))
@odyssomay
odyssomay / SpecRunner.html
Created Oct 14, 2011
Clojurescript testing using jasmine
View SpecRunner.html
<!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>
View gist:1209498
(ns trace
(:use clojure.pprint))
(declare trace-form)
(def *ignore*
'#{def quote var try monitor-enter monitor-exit})
(defmulti trace-special-form (fn [form] (first form)))
@odyssomay
odyssomay / gist:1078370
Created Jul 12, 2011
the longest java stacktrace I have seen
View gist:1078370
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)
View gist:1073506
(defn extract-points [iterator]
(fn []
(let [points (make-array Double/TYPE 6)]
(.currentSegment iterator points)
(.next iterator))))
(defn extract-all-points [path_iterator]
(doall
(take-while (fn [_] (not (.isDone path_iterator)))
(repeatedly (extract-points path_iterator))))
You can’t perform that action at this time.