Skip to content

Instantly share code, notes, and snippets.

View LauJensen's full-sized avatar

Lau B. Jensen LauJensen

View GitHub Profile
;; Burn down chart, input something like "200 175 160 155 152"
;; This relies on Dejcartes which is out in "Super pre-alpha".
;; Much credit and praise to Chouser for ping-ponging with me on this.
(require '[com.markmfredrickson.dejcartes :as chart])
(import '(org.jfree.chart ChartFrame))
(defn make-window [title chart]
(def queue (ref (with-meta
clojure.lang.PersistentQueue/EMPTY
{:tally 0})))
(def seats 3)
(defn debug
[msg n]
(println msg (apply str (repeat (- 35 (count msg)) \space)) n)
(flush))
(ns dk.bestinclass.ikeda
(:import (javax.swing JFrame JPanel)
(java.awt Color Graphics)
(java.awt.image BufferedImage)
(java.awt.event MouseListener)))
;= Definitions
(def x-axis [-10 10])
(def y-axis [-10 10])
#!/usr/bin/perl
use CGI":standard";chdir($0=~s~[^/]*$~~);import_names("x");while($x::t){open$f,">$x::t.r";print$f "$x::l$/$x::v$/".($x::i?$x::i:localtime);close$f;CGI::delete(split(//,~~tlvi));$x::t=0}@r=$x::s?<*$x::s*.r>:<*.r>;print header,start_html,start_form,textfield(-name=>'s',-value=>"search"),submit,end_form,start_form,textfield(-name=>~~t,-value=>"title"),textfield(-name=>~~l,-value=>"link"),hidden(-name=>v,-value=>0),submit,end_form,ul li([sort{$s=sub{$_=$_[0];s~<.*?>~~g;$_};$s->($b)cmp$s->($a)}map{open$f,$_;@a=<$f>;chomp@a;m/(.*)\.r/;(a{href=>"?t=$1&l=$a[0]&i=$a[2]&v=".($a[1]+1)},"^").$a[1].(a{-href=>"?t=$1&l=$a[0]&i=$a[2]&v=".($a[1]-1)},"v")." ".(a{-href=>$a[0]},$1).br.small"added: ".$a[2]}@r]),end_html
# Note: you may need to chmod the directory containing the script to 777.
# Warning: DO NOT host on a public website. It will open up all sorts of nasty security holes.
#!/usr/bin/perl4
# Horrible, horrible, horrible edit of someone's
# even more horrible "reddit clone in 4 lines of perl".
use CGI ':standard';
$dir = File::Basename::dirname( $0 );
chdir $dir;
@LauJensen
LauJensen / cells.clj
Created February 23, 2010 20:08 — forked from richhickey/cells.clj
; Copyright (c) Rich Hickey. 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 agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
(ns com.wangdera.slideshow
(:import (java.io File)
(javax.imageio ImageIO)
(javax.swing JFrame JPanel Timer)
(java.awt Dimension Frame Color)))
(def imagelist (atom []))
(def running (atom true))
(defmacro props [obj & properties]
(reduce #(assoc %1 %2 (inc (get %1 %2 0))) {}
(make-a-seq of-IPs
(line-seq (File. ip-log))
(defmacro do-board [[w h] & body]
`(let [w# (int ~w) h# (int ~h)]
(loop [~'i (int 1)]
(when (< ~'i h#)
(loop [~'j (int 1)]
(when (< ~'j w#)
(do ~@body)
(recur (unchecked-inc ~'j))))
(recur (unchecked-inc ~'i))))))
;sample use idea:
(defn mapx
"Returns a lazy sequence consisting of the result of applying f to the
set of first items of each coll, followed by applying f to the set
of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments."
[f coll]
(gen-iter iter [f seq-cell]