Skip to content

Instantly share code, notes, and snippets.

module Foo
end
remove_const ::Foo
@purplefox
purplefox / gist:4729823
Created February 7, 2013 09:30
Possible bug in JDK URL class? Certainly the behaviour seems odd. I would expect URL.getFile() to url unencode the url.
// Make sure you have a directory which has a space in it's name, e.g:
File f = new File("/home/tim/dir foo/foo.txt");
System.out.println("exists?" + f.exists()); // 'exists?true'
// Convert it to a file URL
URL url = f.toURI().toURL();
System.out.println("url is:" + url); // 'url is:file:/home/tim/dir%20foo/foo.txt' - space has been correctly URL encoded
// Now convert the url back to a file name
function foo() {
// do something
console.log("hello");
bar();
}
function bar() {
nettyEventLoop.runTaskOnLoop(foo)
}
// Clearly this won't actually work since obs2 would need to be final but then you can't assign it inside the handler
MyEventBus eb = new MyEventBus();
Observable obs1 = eb.send("foo", "msg1");
Observable obs2;
obs1.subscribe(new Action1<String>() {
@Override
public void call(String str) {
io.netty.channel.ChannelException: Unable to create Channel from class class io.netty.channel.socket.nio.NioServerSocketChannel
at io.netty.bootstrap.AbstractBootstrap$BootstrapChannelFactory.newChannel(AbstractBootstrap.java:436)
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:289)
at io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:271)
at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:267)
at io.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:43)
at org.vertx.java.core.http.impl.DefaultHttpServer.listen(DefaultHttpServer.java:205)
at org.vertx.mods.WebServer.start(WebServer.java:80)
at org.vertx.java.platform.impl.DefaultPlatformManager$16.run(DefaultPlatformManager.java:1122)
at org.vertx.java.core.impl.DefaultContext$2.run(DefaultContext.java:143)
@purplefox
purplefox / gist:5487084
Created April 30, 2013 07:08
Why can't I call this method which has default argument values like this? Am I misunderstanding how Groovy default values work?
void deployModule(String moduleName, Map<String, Object> config = [:], int instances = 1, Closure doneHandler = {}) {
}
deployModule("foo", {} )
tim@tim-laptop ~/projects/dynjs-vertx-module $ rm -rf ~/.m2/repository/org/projectodd/rephract ~/.m2/repository/org/dynjs/dynjs
tim@tim-laptop ~/projects/dynjs-vertx-module $ mvn clean install -s support/settings.xml -B -q
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.vertx.lang.dynjs.integration.APIIntegrationTests
log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
import org.vertx.java.core.Handler;
import org.vertx.java.core.net.NetSocket;
import org.vertx.java.core.streams.Pump;
import org.vertx.java.core.sockjs.*;
import org.vertx.java.platform.Verticle;
import org.vertx.java.core.buffer.*;
import org.vertx.java.core.json.*;
import org.vertx.java.core.http.*;
public class Example extends Verticle {
SEVERE: Unhandled exception
java.lang.UnsupportedOperationException
at io.netty.buffer.DefaultCompositeByteBuf.nioBuffer(DefaultCompositeByteBuf.java:990)
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:262)
at io.netty.buffer.DefaultCompositeByteBuf.nioBuffer(DefaultCompositeByteBuf.java:988)
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:967)
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:956)
at io.netty.handler.codec.http.multipart.MemoryAttribute.getValue(MemoryAttribute.java:47)
at org.vertx.java.core.http.impl.DefaultHttpServerRequest$InternalMemoryAttribute.attributeCreated(DefaultHttpServerRequest.java:527)
at org.vertx.java.core.http.impl.DefaultHttpServerRequest$InternalMemoryAttribute.addContent(DefaultHttpServerRequest.java:552)
void someAsyncOperation(String str, Handler<Void> handler) {}
public void foo() {
int count = 10;
final MyBarrier barrier = new MyBarrier(new VoidHandler() {
@Override
protected void handle() {