Skip to content

Instantly share code, notes, and snippets.

View ulsa's full-sized avatar

Ulrik Sandberg ulsa

  • IKEA IT
  • Skåne, Sweden
  • X @ulsa
View GitHub Profile
CopyTask copy = new CopyTask();
Fileset fileset = new Fileset();
fileset.setDir("src_dir");
copy.setToDir("../new/dir");
copy.setFileset(fileset);
copy.execute();
<define-function return-type="int" name="add">
<arguments>
<argument type="int">arg1</argument>
<argument type="int">arg2</argument>
</arguments>
<body>
<return>
<add value1="arg1" value2="arg2" />
</return>
</body>
<task name="Test">
<echo message="Hello World!"/>
</task>
<Test />
<copy todir="../new/dir">
<fileset dir="src_dir"/>
</copy>
(defn test []
    (println "Hello World!")
)
(test)
@ulsa
ulsa / core.cljs
Created April 9, 2012 21:59
ClojureScript code for accessing the Karotz toy rabbit
(ns clojurekarotz.core
(:require [clojurekarotz.util :as u]))
(def quit (fn [event] (if (= event "TERMINATED") (js/exit))))
(defn onKarotzConnect [data]
(.moveRelative (.-ears js/karotz) 5 -5 (fn [_]))
(.start (.-tts js/karotz) "Buenos dias Clojure. Como estas? Tienes animales?" "es" quit))
(.connectAndStart js/karotz "192.168.1.13" 9123 onKarotzConnect (js-obj))
@ulsa
ulsa / neighbors.clj
Created May 4, 2012 07:45
neighbors for a cell in clojurescript
cljs.user> (neighbors [1 1])
([0 0] [0 1] [0 2] [1 0] [1 2] [2 0] [2 1] [2 2])
@ulsa
ulsa / changed.clj
Created June 27, 2012 14:45
Finding Out Who Changed What with Datomic
user=> (distinct (map :e (d/datoms (d/since (db conn) #inst "2012-06-25T10:33:16.436-00:00") :eavt)))
(13194139534683 17592186045460)
@ulsa
ulsa / add-attr.clj
Created June 27, 2012 15:23
Find Out Who Changed What with Datomic, 2
user=> @(d/transact conn
[{:db/id #db/id[:db.part/db]
:db/ident :audit/user
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/index true
:db.install/_attribute :db.part/db}])
@ulsa
ulsa / destructuring1.clj
Created August 4, 2012 17:04
Decimal to Roman Numeral converter
(let [lst (filter odd? [1 2 3 4 5])
fst (first lst)
snd (second lst)]
(println fst snd))
=> 1 3