Skip to content

Instantly share code, notes, and snippets.

public void concatEager() {
final TestSubscriber<List<String>> testSubscriber = new TestSubscriber<>();
final long startTime = new Date().getTime();
System.out.println("Start.");
Observable.concatEager( //
asyncObservable("uno", 4), //
asyncObservable("dos", 3), //
@ytRino
ytRino / RetrofitSingleSubscriber.java
Last active March 28, 2016 08:16
RetrofitSingleSubscriber
public abstract class RetrofitSingleSubscriber<T> extends SingleSubscriber<T> {
public abstract void onHttpError(HttpException e);
public abstract void onNonHttpError(Throwable e);
@Override public void onError(Throwable error) {
if (error instanceof HttpException) {
onHttpError((HttpException) error);
} else {
@ytRino
ytRino / log
Created February 26, 2013 09:44
pulic static void logd(String format, Object... args) {
Log.d(TAG, String.format(Locale.getDefault(), format, args));
}
public static long copyFileStream(FileInputStream is, FileOutputStream os)
throws IOException {
FileChannel srcChannel = null;
FileChannel destChannel = null;
try {
srcChannel = is.getChannel();
destChannel = os.getChannel();
return srcChannel.transferTo(0, srcChannel.size(), destChannel);
} finally {
@ytRino
ytRino / FormalLanguageTheory3.md
Created November 12, 2012 17:29
形式言語理論 3 認識問題 命題3.1

形式言語理論 3 認識問題

定義とか

  • Σ: アルファベット(有限集合)
  • Ω = Σ ∪ { [, ]}
  • Ω^* : Ω上の語全体からなる集合
  • L_p : Ω上の言語 (括弧言語)
    • 基底 : Σの元と空語λ
    • 帰納ステップ : u,vL_pの元ならば uv[u]L_pの元
@ytRino
ytRino / Hoge.java
Created September 28, 2012 09:08
assetsが許されるのは、sy(
public static Twitter getTwitter(Context ctx) {
InputStream is = null;
TwitterFactory tf;
try {
is = ctx.getResources().getAssets().open("twitter4j.properties");
PropertyConfiguration conf = new PropertyConfiguration(is);
tf = new TwitterFactory(conf);
} catch (IOException e) {
tf = new TwitterFactory();
@ytRino
ytRino / gist:3760595
Created September 21, 2012 09:33
lib

##ListView読み込み

  • 件数指定
  • 自動・手動
  • 追加ボタン・オーバースクロール
  • リストアイテム非同期読み込みとか

##AsyncTask

  • 結果のコールバック
@ytRino
ytRino / fragment_memo.txt
Created September 18, 2012 15:45
fragment_memo
FragmentStatePagerで持ってるfragmentはめくっていくとonStopが呼ばれるのでここでよしなにするとよい(かも
527 /**
528 * Set the descendant focusability of this view group. This defines the relationship
529 * between this view group and its descendants when looking for a view to
530 * take focus in {@link #requestFocus(int, android.graphics.Rect)}.
531 *
532 * @param focusability one of {@link #FOCUS_BEFORE_DESCENDANTS}, {@link #FOCUS_AFTER_DESCENDANTS},
533 * {@link #FOCUS_BLOCK_DESCENDANTS}.
534 */
535 public void setDescendantFocusability(int focusability) {
536 switch (focusability) {
@ytRino
ytRino / is2String.java
Created September 3, 2012 08:41
InputStreamを丸々Stringにしちゃうやつ
text = client.execute(httpGet, new ResponseHandler<String>() {
@Override
public String handleResponse(HttpResponse resp)
throws ClientProtocolException, IOException {
if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new IOException(resp.getStatusLine().getStatusCode() + "returned.");
}
HttpEntity entity = resp.getEntity();
if (entity != null) {
InputStream is = entity.getContent();