This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.eclipse.jetty:jetty-webapp:9.4.0.v20161208') | |
@Grab('org.langrid:jp.go.nict.langrid.service.language_1_2:1.0.10') | |
@Grab('org.langrid:jp.go.nict.langrid.servicecontainer.handler.axis:1.0.10') | |
import jp.go.nict.langrid.service_1_2.translation.TranslationService; | |
import jp.go.nict.langrid.servicecontainer.handler.annotation.Service; | |
import jp.go.nict.langrid.servicecontainer.handler.axis.SGAxisServlet; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.webapp.WebAppContext; | |
public class TestServiceImpl implements TranslationService{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.assertFalse; | |
import static org.junit.Assert.assertTrue; | |
import java.util.Collection; | |
import java.util.Iterator; | |
import java.util.function.Consumer; | |
public class CollectionFixture<T> { | |
public CollectionFixture(Collection<T> collection){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test{ | |
@Test | |
public void test_tunnelingExecute() throws Throwable{ | |
try{ | |
tunnelingExecute( | |
Arrays.asList(1, 2, 3)::forEach, | |
v -> {throw new IOException();} | |
); | |
Assert.fail(); | |
} catch(IOException e){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Testing LinkedList | |
com.dzyoba.alex.TestAlloc: [7, 25, 276] | |
com.dzyoba.alex.TestInsert: [7069, 19437, 24856] | |
com.dzyoba.alex.TestInsertHead: [0, 1, 2] | |
com.dzyoba.alex.TestInsertTail: [0, 1, 1] | |
com.dzyoba.alex.TestSearch: [17372, 53823, 70404] | |
com.dzyoba.alex.TestDelete: [5, 9, 11] | |
com.dzyoba.alex.TestAlloc: [6, 36, 98] | |
com.dzyoba.alex.TestRemove: [6472, 8434, 9857] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script src="${langrid-address}/js"></script> | |
<script> | |
new LangridClientFactory({ | |
apiKey: "${your-api-key}" | |
}) | |
.create("${service-id}") | |
.translate("en", "ja", "Hello") | |
.done(function(res){ | |
console.log(res.result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.codehaus.groovy.runtime.ReflectionMethodInvoker | |
class Base{} | |
class Derived extends Base{} | |
class Derived2 extends Derived{} | |
class Hello{ | |
public void hello(Base b){ | |
println "base" | |
} | |
public void hello(Derived d){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.ObjectStreamClass; | |
import java.net.URL; | |
import java.net.URLClassLoader; | |
import java.nio.file.Paths; | |
import java.util.HashMap; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.util.Arrays.asList; | |
import static org.junit.Assert.assertEquals; | |
import org.json.JSONArray; | |
import org.json.JSONObject; | |
import org.junit.Test; | |
public class JSONObjectExample { | |
@Test | |
public void java_json_literal() throws Throwable{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.InvocationHandler; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Proxy; | |
import java.util.EventListener; | |
public class EventListenerList<T extends EventListener> extends javax.swing.event.EventListenerList{ | |
public EventListenerList(Class<T> clazz){ | |
this.clazz = clazz; | |
this.fireProxy = clazz.cast(Proxy.newProxyInstance( | |
Thread.currentThread().getContextClassLoader(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
public class HtmlEncoderTest { | |
static public void main(String[] args) { | |
System.out.println(new HtmlEncoder().encode("<script>alert('注意!');</script>")); | |
System.out.println(HtmlEncoder.count); | |
} | |
} |
NewerOlder