Skip to content

Instantly share code, notes, and snippets.

Avatar
💩
hacking hacking hacking!

Matthias Wessendorf matzew

💩
hacking hacking hacking!
View GitHub Profile
@matzew
matzew / gist:2922867
Created Jun 13, 2012
Java7 Driver and Connection
View gist:2922867
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/datasource/DummyConnection.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/datasource/DummyConnection.java
index 064788c..d85777e 100644
--- a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/datasource/DummyConnection.java
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/datasource/DummyConnection.java
@@ -35,6 +35,7 @@ import java.sql.Statement;
import java.sql.Struct;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.Executor;
View gist:3138888
NSMutableArray* ma = [[NSMutableArray alloc] init];
// about 0.015 seconds
for (int i = 0; i<10000; i++) {
[ma addObject:[NSString stringWithFormat:@"%@ %d", @"ABC", i]];
}
// really slow: takes more than 7 seconds.....
for (int i = 0; i<10000; i++) {
[ma removeObject:[NSString stringWithFormat:@"%@ %d", @"ABC", i]];
@matzew
matzew / gist:3206755
Created Jul 30, 2012
Unit testing blocks with AFNetworking example
View gist:3206755
/*
* SenTestingKit does not wait for blocks to finish by default so your test would simply complete
* as successful. You need to use a semaphore and keep the run loop going in order for the test
* to properly run.
*/
- (void)testGetSpots {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
CLLocation location = [[CLLocation alloc] initWithLatitude:70.0 longitude:50.0];
[Spot spotsWithURLString:@"/spots" near:location parameters:[NSDictionary dictionaryWithObject:@"128" forKey:@"per_page"] block:^(NSArray *records) {
//sample assert
@matzew
matzew / gist:3206756
Created Jul 30, 2012
Unit testing blocks with AFNetworking example
View gist:3206756
/*
* SenTestingKit does not wait for blocks to finish by default so your test would simply complete
* as successful. You need to use a semaphore and keep the run loop going in order for the test
* to properly run.
*/
- (void)testGetSpots {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
CLLocation location = [[CLLocation alloc] initWithLatitude:70.0 longitude:50.0];
[Spot spotsWithURLString:@"/spots" near:location parameters:[NSDictionary dictionaryWithObject:@"128" forKey:@"per_page"] block:^(NSArray *records) {
//sample assert
@matzew
matzew / gist:3379392
Created Aug 17, 2012
Pipeline and Pipe BASIC functionality
View gist:3379392

For the pipeline, the basic functionality is:

@interface AGPipeline : NSObject

// class factory methods to create the pipeline object
+(id) pipelineWithPipe:(NSString*) pipe;
+(id) pipelineWithPipes:(NSString*) pipe, ...;
//TODO: define factory method to create a pipeline w/ config object (can be an NSDictionary...)

// pipeline object methods
@matzew
matzew / gist:3404692
Created Aug 20, 2012
fail to create project in browser
View gist:3404692
16:24:08,892 SEVERE [org.jboss.resteasy.core.SynchronousDispatcher] (http--127.0.0.1-8080-1) Failed executing POST /project: org.jboss.resteasy.spi.UnsupportedMediaTypeException: Cannot consume content type
at org.jboss.resteasy.core.registry.Segment.match(Segment.java:117) [resteasy-jaxrs-2.3.2.Final.jar:]
at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:33) [resteasy-jaxrs-2.3.2.Final.jar:]
at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327) [resteasy-jaxrs-2.3.2.Final.jar:]
at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374) [resteasy-jaxrs-2.3.2.Final.jar:]
at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367) [resteasy-jaxrs-2.3.2.Final.jar:]
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:307) [resteasy-jaxrs-2.3.2.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:173) [resteasy-jaxrs
@matzew
matzew / gist:3404887
Created Aug 20, 2012
Creating a project with CURL
View gist:3404887
curl -v -H "Content-type: application/json" -X POST -d '{"title":"A new project"}' http://localhost:8080/todo-server/project
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /todo-server/project HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
@matzew
matzew / gist:3405912
Created Aug 20, 2012
AeroGear-iOS: first API draft
View gist:3405912

Basic functionality of the aerogear-ios pipeline structure - DRAFT Version 0.1

The pipeline object (AGPipeline):

/**
 * AGPipeline represents a 'collection' of server connections (pipes) and
 * their corresponding data models. This object provides a standard way to
 * communicate with the server no matter the data format or transport expected.
 * 
 * A pipeline must have at least one pipe.
@matzew
matzew / gist:3425678
Created Aug 22, 2012
Returning URL from a Pipe?
View gist:3425678
var todo = aerogear.pipeline([
{
name: "tasks",
settings: {
url: "/todo-server/tasks"
}
},
....
Tasks = todo.pipes[ "tasks" ];
....
View gist:3425758
...
// create a shared client for the demo app:
NSURL* testURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/todo-server/"];
restClient = [AGHttpClient sharedClientFor:testURL];
...
// path is the 'endpoint':
[restClient postPath:@"projects" parameters:parameters success:........];