Skip to content

Instantly share code, notes, and snippets.

View matzew's full-sized avatar
💩
hacking hacking hacking!

Matthias Wessendorf matzew

💩
hacking hacking hacking!
  • Red Hat
  • Emsdetten, Germany
View GitHub Profile
@matzew
matzew / gist:2922867
Created June 13, 2012 08:45
Java7 Driver and Connection
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;
@matzew
matzew / gist:3138888
Created July 18, 2012 21:04
NSMutableArray
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 July 30, 2012 13:07
Unit testing blocks with AFNetworking example
/*
* 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 July 30, 2012 13:07
Unit testing blocks with AFNetworking example
/*
* 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 August 17, 2012 14:48
Pipeline and Pipe BASIC functionality

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 August 20, 2012 14:24
fail to create project in browser
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 August 20, 2012 14:51
Creating a project with CURL
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 August 20, 2012 17:15
AeroGear-iOS: first API draft

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 August 22, 2012 13:42
Returning URL from a Pipe?
var todo = aerogear.pipeline([
{
name: "tasks",
settings: {
url: "/todo-server/tasks"
}
},
....
Tasks = todo.pipes[ "tasks" ];
....
@matzew
matzew / gist:3425758
Created August 22, 2012 13:49
baseURL
...
// 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:........];