Skip to content

Instantly share code, notes, and snippets.

@tfnico
tfnico / fastbuild-pom.xml
Created Jan 14, 2011
An alternative pom
View fastbuild-pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tfnico.examples</groupId>
<artifactId>foo</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>./pom.xml</relativePath>
</parent>
@tfnico
tfnico / guava-functional.java
Created Apr 20, 2011
Solving http://projecteuler.net/index.php?section=problems&id=1 being as functional as possible using Google Guava
View guava-functional.java
static int solution(int limit){
ImmutableSet<Integer> numbers = intRange(1,limit);
return foldInsByAdding(Iterables.filter(numbers, dividableByThreeOrFive()));
}
private static Predicate<Integer> dividableByThreeOrFive(){
return new Predicate<Integer>() {
@Override
public boolean apply(Integer i){
return (i % 3 == 0) || (i % 5 == 0);
View factorial.weel
// Note the tail call optimization!
private func fact_f(n, result)
return n > 0 ? fact_f(n - 1, result * n) : result;
end
func fact(n)
return fact_f(n, 1);
end
@tfnico
tfnico / post-receive-email
Created Jul 27, 2011 — forked from cmcculloh/post-receive-email
Example of a post receive email file called by a git hook that sends a color coded formatted html email of the git diff
View post-receive-email
#!/bin/sh
#
# Copyright (c) 2007 Andy Parkins
#
# An example hook script to mail out commit update information. This hook
# sends emails listing new revisions to the repository introduced by the
# change being reported. The rule is that (for branch updates) each commit
# will appear on one email and one email only.
#
# This hook is stored in the contrib/hooks directory. Your distribution
@tfnico
tfnico / console
Created Sep 5, 2011
Git push output
View console
imac:foo-integration-tests firstname.lastname$ git push
Counting objects: 65, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (25/25), done.
Writing objects: 100% (37/37), 4.20 KiB, done.
Total 37 (delta 10), reused 0 (delta 0)
remote:
remote: *** Error while highlighting:
remote: UnicodeDecodeError: 'utf8' codec can't decode byte 0xa7 in position 1136: unexpected code byte
remote: (file "/usr/lib/python2.5/encodings/utf_8.py", line 16, in decode)
View from flurfunk
➜ ~/projects/viaboxx/flurfunk/flurfunk-server/[limit-number-of-msg]✗>lein test tfnico@raist [16:56:21]
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol (storage.clj:11)
at clojure.lang.Compiler.analyze(Compiler.java:5205)
at clojure.lang.Compiler.analyze(Compiler.java:5151)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4670)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:4941)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:5369)
at clojure.lang.Compiler.analyze(Compiler.java:5190)
at clojure.lang.Compiler.analyze(Compiler.java:5151)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4670)
@tfnico
tfnico / maven.log
Created Nov 9, 2011
maven release branch problems
View maven.log
~/projects/agnes/[(agnes-1.5)]>mvn release:branch -DbranchName=agnes-1.5.x -DautoVersionSubmodules=true -DreleaseVersion=1.5.1 -DupdateBranchVersions=true tfnico@Thomas-Ferris-Nicolaisens-iMac [12:10:23]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building agnes 1.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.2.1:branch (default-cli) @ agnes ---
[INFO] Verifying that there are no local modifications...
[INFO] ignoring changes on: pom.xml.next, release.properties, pom.xml.releaseBackup, pom.xml.backup, pom.xml.branch, pom.xml.tag
@tfnico
tfnico / gof.clj
Created Dec 3, 2011
Started Clojure game-of-life
View gof.clj
(ns conways.test.core
(:use [conways.core])
(:use [clojure.test]))
(def world #{})
(defn isALive? [world x y] (get world [x y]) )
(defn setLive [world x y] (conj world [x y]))
@tfnico
tfnico / Tjohei.java
Created Dec 5, 2011
Splitting tests
View Tjohei.java
@Test(expected=NullPointerException.class)
public void psmThrowsNullPointerExceptionWhenCopying() {
Aristo a = new Aristo();
Runtime r = mock(Runtime.class);
a.setRuntime(r);
a.PSMCopy("oldPSM", "newPSM");
}
@Test(expected=IOException.class)
public void psmThrowsIOExceptionWhenExecuting() {
@tfnico
tfnico / ifelse.java
Created Dec 23, 2011
Some business rule tests
View ifelse.java
public static boolean isCodeAllowed(String code) {
return isNotNullOrEmpty(code) &&
onlyLettersCorrectLength(code) &&
lettersAndNumbersCorrectLength(code) &&
numbersOnlyNotAllowed(code) &&
plusSignOnlyParticularity(code);
}