Skip to content

Instantly share code, notes, and snippets.

@talios
talios / TestXtendApp.java
Created February 10, 2012 10:26
Xtend HAL test
package com.talios;
import com.google.common.base.Optional;
import com.talios.App;
import com.theoryinpractise.halbuilder.ResourceFactory;
import com.theoryinpractise.halbuilder.spi.Link;
import com.theoryinpractise.halbuilder.spi.ReadableResource;
import com.theoryinpractise.halbuilder.spi.RenderableResource;
import com.theoryinpractise.halbuilder.spi.Resource;
import java.util.List;
@talios
talios / haltest.clj
Created January 31, 2012 10:48
The first clojure based Halbuilder IT test.
(ns haltest
(:use [clojure.test]))
(deftest haltest
(let [resource-factory (com.theoryinpractise.halbuilder.ResourceFactory.)
resource (doto (.newHalResource resource-factory "/foo")
(.withProperty "name" "Mark")
(.withLink "/home" "home"))]
(println (.renderXml (.asRenderableResource resource)))) )
Process: Google Chrome [1553]
Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Identifier: com.google.Chrome
Version: 17.0.932.0 (932.0)
Code Type: X86 (Native)
Parent Process: launchd [219]
Date/Time: 2011-11-11 10:44:44.513 +1300
OS Version: Mac OS X 10.7.2 (11C74)
Report Version: 9
@talios
talios / gist:1119473
Created August 2, 2011 02:29
F-Script based iTunes playlist sort hack
df := NSDateFormatter new.
df setDateFormat: 'yyyy-MM'.
iTunes := SBApplication applicationWithBundleIdentifier:'com.apple.iTunes'.
playlists := (iTunes sources at: 0) playlists.
playlist := (playlists where: playlists name = 'The Full Daily Play') top.
playlist tracks do: [:track |
skipDate := (NSDate dateWithString: (df stringFromDate: track dateAdded) ++ '-01 00:00:00 +1200').
@talios
talios / gist:1064186
Created July 5, 2011 03:00
Extracting generic class information from generified classes
private ParameterizedType findParameterizedClass(Class clazz) {
if (clazz.getGenericSuperclass() != null && clazz.getGenericSuperclass() instanceof ParameterizedType) {
return (ParameterizedType) clazz.getGenericSuperclass();
} else {
if (clazz.getSuperclass() != null) {
return findParameterizedClass(clazz.getSuperclass());
} else {
throw new ClassCastException(clazz.getName() + " is not generic.");
}
}
@talios
talios / gist:1022190
Created June 13, 2011 01:18
Hacking iTunes playlist for funky sorting.
iTunes := SBApplication applicationWithBundleIdentifier:'com.apple.iTunes'
playlists := ((iTunes sources at: 0) playlists.
playlist := (playlists where: playlists name = 'The Full Daily Play').
playlist tracks do: [:track |
track setSkippedDate: (NSDate dateWithString:
(track dateAdded description substringWithRange: (NSValue rangeWithLocation:0 length:8))
++ '01 00:00:00 +1200')
@talios
talios / gist:997662
Created May 29, 2011 11:19
Top Albums of 2011
American Heritage - Sedentary
Amon Amarth - Surtur Rising
Amorphis - The Beginning of Times
Arch Enemy - Khaos Legions
Avantasia - The Flying Opera ( Around The World in 20 Days )
Beardfish - Mammoth
Becoming The Archetype - Celestial Completion
Believer - Transhuman
Blackfield - Welcome To My DNA
Blood Ceremony - Living With The Ancients
@talios
talios / SomeOther.html
Created November 4, 2010 10:47
A new modification to my concordion eval command that now takes regex based templates
<html xmlns:concordion="http://www.concordion.org/2007/concordion"
xmlns:talios="http://www.talios.com/2010/concordion">
<head>Some Other Test</head>
<body>
<p class="info">
All tests are assumed to be run against username <b concordion:set="#username">username</b> and the password
<b concordion:set="#password">password</b>.
</p>
(require 'clojure.contrib.datalog.tests.test)
(require 'clojure.contrib.datalog.tests.test-database)
(require 'clojure.contrib.datalog.tests.test-literals)
(require 'clojure.contrib.datalog.tests.test-magic)
(require 'clojure.contrib.datalog.tests.test-rules)
(require 'clojure.contrib.datalog.tests.test-softstrat)
(require 'clojure.contrib.datalog.tests.test-util)
(require 'clojure.contrib.mock.test-adapter)
(require 'clojure.contrib.pprint.test-cl-format)
(require 'clojure.contrib.pprint.test-helper)
(deftest symbol-test
(defsymbolmacro sum-2-3 (plus 2 3))
(is (= (macroexpand '(with-symbol-macros (+ 1 sum-2-3)))
'(do (+ 1 (plus 2 3)))))
(is (= (macroexpand '(macrolet [(plus [a b] `(+ ~a ~b))] (+ 1 sum-2-3)))
'(do (+ 1 (clojure.core/+ 2 3)))))
(ns-unmap *ns* 'sum-2-3))