Skip to content

Instantly share code, notes, and snippets.

View wulfgarpro's full-sized avatar
🤘

James Fraser wulfgarpro

🤘
View GitHub Profile
@wulfgarpro
wulfgarpro / gist:3462159
Created August 25, 2012 07:36
config.json for phantomjs
{
'localToRemoteUrlAccessEnabled' : true,
'webSecurityEnabled' : false
}
@wulfgarpro
wulfgarpro / gist:3462131
Created August 25, 2012 07:33
spec that loads store
if(!store) {
store = ctlr.getStore('Users');
}
it("should have users",function() {
expect(store.getCount()).toBeGreaterThan(1);
});
@wulfgarpro
wulfgarpro / gist:2005650
Created March 9, 2012 08:30
Solution to tutorial 1, q2
# this is the O(n) solution for tutorial 1, question 2 in ruby
A = [2,4,6,8] # elements to multiply
B = [] # left products
C = [] # right products
output = [] # to hold final result
product = 1
@wulfgarpro
wulfgarpro / gist:1992341
Created March 7, 2012 10:03
Parenthesis matching in Java
package uni.rev.q0;
import java.util.Stack;
public class q0 {
static class Parenthesis {
private char parenthesis;
private int position;
public Parenthesis(char par, int pos) {
@wulfgarpro
wulfgarpro / gist:1775930
Created February 9, 2012 00:40
Example use of the maven-bundle-plugin for pom.xml
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<executions>
<execution>
<id>wrap-my-dependency</id>
<phase>package</phase>
<goals>
<goal>wrap</goal>
@wulfgarpro
wulfgarpro / gist:1366772
Created November 15, 2011 10:54
DAO pattern with Factory Method
public interface GenericDao<T, K> {
public K insert(T object);
}
public class GenericDaoMongoDBImpl<T, K> implements GenericDao<T, K> {
public K insert(T object) {
return null;
}
}
@wulfgarpro
wulfgarpro / gist:1326855
Created October 31, 2011 03:38
Setting visibility of fields for Jackson ObjectMapper
ObjectMapper mapper = new ObjectMapper();
VisibilityChecker<?> vc = mapper.getVisibilityChecker();
vc = vc.withFieldVisibility(Visibility.ANY);
mapper.setVisibilityChecker(vc);
@wulfgarpro
wulfgarpro / gist:1252834
Created September 30, 2011 06:09
sample json
{"user":"system-user","synapseVersion":"2.2.3","mapping":"{\"fieldMapperStore\":[{\"userFieldName\":\"name\",\"synapseTypeName\":\"O4.PersonName\",\"synapseFieldName\":\"Name\",\"displayName\":\"Name\",\"fieldMinimumValue\":5e-324,\"fieldMaximumValue\":1.7976931348623157e+308},{\"userFieldName\":\"age\",\"synapseTypeName\":\"O4.Integer\",\"synapseFieldName\":\"Age\",\"displayName\":\"Age\",\"fieldMinimumValue\":5e-324,\"fieldMaximumValue\":1.7976931348623157e+308},{\"userFieldName\":\"loc\",\"synapseTypeName\":\"O4.CompoundProperty\",\"synapseFieldName\":\"Location\",\"displayName\":\"Location\",\"fieldMinimumValue\":5e-324,\"fieldMaximumValue\":1.7976931348623157e+308,\"miscellaneousInfo\":{\"fieldMapperStore\":[{\"userFieldName\":\"address\",\"synapseTypeName\":\"O4.String\",\"synapseFieldName\":\"Address\",\"displayName\":\"Address\",\"fieldMinimumValue\":5e-324,\"fieldMaximumValue\":1.7976931348623157e+308},{\"userFieldName\":\"zip\",\"synapseTypeName\":\"O4.Integer\",\"synapseFieldName\":\"Zip\",\"displa
@wulfgarpro
wulfgarpro / gist:1249914
Created September 29, 2011 03:32
Useful js snippet detecting console in firebug
if (typeof console != 'undefined') {
console.log("Useful error message");
}
@wulfgarpro
wulfgarpro / gist:1220791
Created September 15, 2011 23:29
Using Jackson's TreeModel to parse types from JSON
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readValue(compoundCriteria,
JsonNode.class);
if(rootNode.has("ContextualCriteria"))
{
JsonNode contextualNode = rootNode.get("ContextualCriteria");
ContextualCriteria contextualCriteria = (ContextualCriteria)
fromJson(contextualNode.toString(),