This file contains 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 TwitterFuture getTrends() throws TwitterException { | |
final HttpResponse res = get(conf.getRestBaseURL() + "trends.json"); | |
return new TwitterFuture(){ | |
@Override | |
public void get(TwitterListener listener) throws TwitterException { | |
listener.gotTrends(new TrendsJSONImpl(res, conf)); | |
} | |
}; | |
} |
This file contains 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
class GAEAsyncTwitterImpl extends TwitterBaseImpl | |
implements Twitter { | |
public QueryResult search(Query query) throws TwitterException { | |
try { | |
return LazyEntityFactory.newQueryResult( | |
get(conf.getSearchBaseURL() + "search.json", query.asHttpParameterArray()) | |
, conf); | |
} catch (TwitterException te) { | |
if (404 == te.getStatusCode()) { | |
return new QueryResultJSONImpl(query); |
This file contains 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
// workaround for http://jira.twitter4j.org/browse/TFJ-556 | |
System.setProperty("http.keepAlive", "false"); | |
TwitterStream s = new TwitterStreamFactory().getInstance(); | |
s.setOAuthConsumer("CONSUMER", "SECRET"); | |
s.setOAuthAccessToken(new AccessToken("ACCESSTOKEN", "SECRET")); | |
s.addListener(new StatusAdapter(){ | |
public void onStatus(Status status) { | |
System.out.println(String.format("[%s] @%s: %s" | |
, status.getCreatedAt() | |
, status.getUser().getScreenName() |
This file contains 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.trie4j.doublearray.DoubleArray; | |
import org.trie4j.louds.LOUDSTrie; | |
import org.trie4j.patricia.simple.PatriciaTrie; | |
public class Sample { | |
public static void main(String[] args) throws Exception{ | |
PatriciaTrie pat = new PatriciaTrie(); | |
pat.insert("Hello"); | |
pat.insert("World"); | |
pat.insert("Wonder"); |
This file contains 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
package seimei; | |
import jp.go.nict.langrid.commons.util.Pair; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.Arrays; |
This file contains 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 MsgPackTest { | |
public static void main(String[] args) throws Exception { | |
MessagePack msgpack = new MessagePack(); | |
List<String> lines = Arrays.asList("hello", "world"); | |
byte[] bytes = msgpack.write(lines); | |
msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance())); | |
for(Value v: (List<Value>)msgpack.read(bytes, List.class)){ | |
System.out.println(new String(v.asRawValue().getByteArray(), "UTF-8")); | |
} | |
} |
This file contains 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
Arrays.stream(new File("lib").listFiles(f -> f.getName().endsWith(".jar"))) | |
.map(f -> f.getAbsolutePath()) | |
.reduce(".", (l, r) -> l + File.pathSeparator + r) |
This file contains 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 javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
import scala.tools.nsc.interpreter.IMain; | |
import scala.tools.nsc.settings.MutableSettings.BooleanSetting; | |
public class ScalaTest { | |
public static void main(String[] args) throws Exception{ | |
ScriptEngine engine = new ScriptEngineManager().getEngineByName("scala"); | |
((BooleanSetting)(((IMain)engine).settings().usejavacp())).value_$eq(true); |
This file contains 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.IOException; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map; | |
public class LZ77 { | |
public static void compress1(CharSequence src, Appendable out, int windowSize) | |
throws IOException{ |
This file contains 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.IOException; | |
import java.util.BitSet; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map; | |
public class LZSS { | |
public static class LZSSData{ |
OlderNewer