Skip to content

Instantly share code, notes, and snippets.

View justinwyer's full-sized avatar

Justin Wyer justinwyer

  • Johannesburg, South Africa
View GitHub Profile
@justinwyer
justinwyer / Card.m
Last active December 12, 2015 09:18
Simplest way to make the test pass.
@implementation Card {
}
- (int)match:(NSArray *)cards {
return 0;
}
@justinwyer
justinwyer / CardTest.m
Last active December 12, 2015 09:18
TDD examples for blog
@implementation CardTest
- (void)testShouldKnowCardCannotMatchEmptyCardList {
Card *card = [Card new];
NSArray *otherCards = [NSArray new];
STAssertEquals(0, [card match:otherCards], @"Should not match empty card list.");
}
@end
public class Main {
private static <T> T readValue(String response, Class<T> returnType) {
try {
return returnType.newInstance();
} catch (InstantiationException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IllegalAccessException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
public class Main {
private class Foo {
}
private static <T> T readValue(String response, Class<T> returnType) {
try {
return returnType.newInstance();
} catch (InstantiationException e) {
@justinwyer
justinwyer / Deed.java
Created July 8, 2012 16:27
Java EE 6 Web Profile Without the App Server. Part 3.
@Entity
public class Deed implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column
private String altruist;
@Column
private String recipient;
@justinwyer
justinwyer / pom.xml
Created July 8, 2012 12:41
Java EE 6 Web Profile without the app server. Part 3.
<dependency>
<groupid>com.sun.faces</groupid>
<artifactid>jsf-api</artifactid>
<version>2.1.7</version>
</dependency>
<dependency>
<groupid>com.sun.faces</groupid>
<artifactid>jsf-impl</artifactid>
<version>2.1.7</version>
<scope>runtime</scope>
@justinwyer
justinwyer / DeedService.java
Created July 8, 2012 12:33
Java EE 6 Web Profile without the app server. Part 2.
@Path("/deed")
@RequestScoped
public class DeedService
{
@Inject
private GoodStuff goodStuff;
@POST
@Path("/good")
public Response doGoodDeed()
@justinwyer
justinwyer / App.java
Created July 8, 2012 12:17
Java EE 6 Web Profile without the app server. Part 1.
public class App
{
private static String[] jettyConfigurationClasses =
{
"org.eclipse.jetty.webapp.WebInfConfiguration",
"org.eclipse.jetty.webapp.WebXmlConfiguration",
"org.eclipse.jetty.webapp.MetaInfConfiguration",
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.plus.webapp.EnvConfiguration",
@justinwyer
justinwyer / pom.xml
Created May 22, 2012 15:40
jetty weld enabled jersey and jsf 2
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>manager</name>
@justinwyer
justinwyer / web.xml
Created May 22, 2012 08:54
jetty weld enabled jersey and jsf 2
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>foobar</display-name>
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>