Skip to content

Instantly share code, notes, and snippets.

View tomoima525's full-sized avatar
🎯
Focusing

tomo tomoima525

🎯
Focusing
View GitHub Profile
@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: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,
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 / 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;
@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 / 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 / installFromBundle
Created July 12, 2018 19:01 — forked from keyboardsurfer/installFromBundle
Build & extract a set of apk from an aab for a specific device and install the results on it.
#!/bin/sh
# Build & extract a set of apk from an aab for a specific device and install the results on it.
#
# This needs https://github.com/google/bundletool to be available as `bundletool`.
# Also **exactly** one device needs to be connected to adb.
# Usage: installFromBundle bundle.aab
# optional `--extract-apks` to keep the set on your workstation as well.
basename=${1%%.*}
keystore="~/.android/debug.keystore"
@ReactMethod
fun generate(imagePath: String,
renderSettings: ReadableArray,
width: Int,
height: Int,
promise: Promise
) {
Log.d("Thumbnail", "====== called $renderSettings $imagePath")
launch(CommonPool) {
try {
@tomoima525
tomoima525 / clear.txt
Created October 18, 2018 07:31 — forked from EQuimper/clear.txt
React-Native clear Watchman + Cache
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start -- --reset-cache