Skip to content

Instantly share code, notes, and snippets.

View tomoima525's full-sized avatar
🎯
Focusing

tomo tomoima525

🎯
Focusing
View GitHub Profile
@tomoima525
tomoima525 / LocalDataSource.java
Created November 15, 2017 04:20
Storing state
BehaviorProcessor<List<Article>> articleList = BehaviorProcessor.create();
LocalDataSource(ArticleDao articleDao) {
this.articleDao = articleDao;
articleDao.subscribeOn(Schedulars.io()).getAll().subscribe(articleList::onNext)
}
public Completable saveArticles(List<Article> article) {
return Completable.fromAction(() -> articleDao.insert(article))
@tomoima525
tomoima525 / ArticleViewModel.java
Last active May 2, 2023 22:38
Observer pattern sample
/// ArticleViewModel.java
disposables.addAll(
articleService.getArticles()
.subscribeOn(Schedular.io())
.subscribe(() -> { }, e -> {}),
articleService.observeArticles()
.toSingle()
.observeOn(Android.mainthread())
.subscribe(list -> view::bind)
@tomoima525
tomoima525 / EndlessRecyclerViewScrollListener.java
Created January 6, 2017 00:20 — forked from rogerhu/EndlessRecyclerViewScrollListener.java
Endless RecyclerView scrolling for different layout managers
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load.
private boolean loading = true;
from requests_oauthlib import OAuth1Session
import configparser
import json
import csv
config = configparser.ConfigParser()
config.read('config.txt')
url = 'https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=tomoaki_imai&count=200&exclude_replies=true'
params = {}
options = config["keys"]
twitter = OAuth1Session(options["ConsumerKey"], options["ConsumerSecret"], options["AccessToken"], options["AccessSecret"])
@tomoima525
tomoima525 / gist:59298f6aee6bc0ef5e9e00f992101552
Created May 12, 2016 06:27
A custom implementation of CursorJoiner. Allows you to compare int type. Also configures order.
/**
* Custom implementation of {@Link android.database.CursorJoiner.java}
* Does a join on two cursors using specific columns. This class allows join by int type.
* Tomoaki Imai 2016
* reference: http://poly.hatenablog.com/entry/20101006/p1
* MIT License
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
@tomoima525
tomoima525 / gist:7681d427961ba89a459c
Created December 31, 2015 03:20
@habomaijiro氏が食べたラーメン価格帯
価格帯は¥500以上、¥2000以下でソート
```
for (Entry<String, Integer> entry : entries) {
result.put(entry.getKey(), entry.getValue());
if ((entry.getValue() >= 1)) {
try {
int price = Integer.parseInt(entry.getKey());
if(price >500 && price < 2000){
System.out.println("" + entry.getValue() +"\t\t" + price);
@tomoima525
tomoima525 / gist:d554cd960b82e697dd30
Created December 30, 2015 15:39
@habomaijiro 氏の全ツイートログ
id,tweet,retweetCount,isRetweetedByMe,favCount,date
,平成27年12月30日水曜日、ラーメン二郎 三田本店、大ラーメン ニンニク 650YEN<n>麺、ツルとしてザクザク喰えるもの。<n>汁、ウンメ〜ッ!スッキリと飲みやすい汁、カラダに優しい癒し汁。<n>ぶた、プリップリで脂身甘いもの。<n>完飲。 https://t.co/F48ssmuRce,511,false,430,2015/12/30 10:18:10
,平成27年12月29日火曜日、ラーメン二郎 西台駅前店、小豚+味噌+白ネギ+味付うずら+生卵+生卵 ニンニク 1200YEN<n>汁、アッツアツ、凍えた体ポッカポカ。<n>生姜加えて、メッチャウンメ〜ッ!<n>豚、端豚、巻豚、神域ィ!<n>完飲。 https://t.co/P8UMRZhZZE,698,false,555,2015/12/29 21:52:36
,平成27年12月28日月曜日、ラーメン二郎 歌舞伎町店、普通盛+煮玉子 ニンニク800YEN<n>麺、モチとした食感の喰いごたえあるもの。<n>汁、ヤサイと合う、ニンニク溶けてウマい汁。<n>ブタ、いささかパサも、汁に浸しておいて吉。<n>完飲。 https://t.co/WtikdoVhHr,546,false,439,2015/12/28 19:41:00
,平成27年12月27日日曜日、ラーメン二郎大宮店、大ラーメン アブラカラメ生姜 700YEN<n>完飲。 https://t.co/kCB8tBUqYS,1888,false,1054,2015/12/27 18:36:02
,平成27年12月26日土曜日、ラーメン二郎 三田本店夜の部、大ラーメン ニンニクカラメ 650YEN<n>ぶた切れ無念。<n>麺、デッロプリに液体アブラ絡んでウッメェェッ!<n>汁、ウマ味と醤油利いたスッキリしたもの。クタヤサイと合う。<n>完飲。 https://t.co/DshC89IF7L,516,false,395,2015/12/26 21:42:08
,平成27年12月26日土曜日、ラーメン二郎 三田本店、ぶた入り大ラーメン ニンニク 750YEN<n>麺、プリとした柔らかめの食感。俺好み。<n>汁、ウマ味利いてウンメ〜ッ!<n>ブタ、喰いごたえあるぶ厚い端ブタ。しっとりとしてウマい。<n>完飲。
@tomoima525
tomoima525 / gist:be8ddb4de7a26c9b5a75
Last active December 31, 2015 03:00
@habomaijiro 氏のツイートの単語頻出度
val: 364 t: 汁
val: 309 t: 麺
val: 304 t: ラーメン二郎
val: 300 t: 完飲
val: 255 t: 味
val: 249 t: ニンニク
val: 238 t: 生卵
val: 227 t: ラーメン
val: 162 t: 大
val: 132 t: ブタ
@tomoima525
tomoima525 / TutorialActivity.java
Created November 12, 2015 21:40 — forked from fiskurgit/TutorialActivity.java
How to do code the slick 'product' tour' view pager animations with fading background colours and parallax scrolling seen in newer Google products
package eu.fiskur.pennineway.tutorial;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
@tomoima525
tomoima525 / gist:97eaf11e59698b57afe6
Created November 25, 2014 07:08
/gradlew :app:dependencies
$ ./gradlew :app:dependencies
current task: :app:dependencies
single_task: :app:dependencies
****************************************************
* CONFIGURATION
* TASK: :app:dependencies
* SDK_FLAVOR: Production
* SDK_BUILD TYPE: Release
* aviarySdkPackageName: com.aviary.android.feather.sdk
* aviarySdkVersionName: 3.4.3