Skip to content

Instantly share code, notes, and snippets.

@YusukeIwaki
YusukeIwaki / default.xml
Last active February 6, 2017 08:42
droidkaigi
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="github" fetch="https://github.com/" />
<default revision="master" remote="github" />
<project name="square/okhttp.git" path="okhttp3" />
<project name="square/retrofit.git" path="retrofit" />
<project name="square/picasso.git" path="picasso" />
<project name="ReactiveX/RxJava.git" path="RxJava_1" revision="1.x" />
@YusukeIwaki
YusukeIwaki / chrome-remote-desktop.patch
Created March 26, 2017 23:43
chrome-remote-desktopをdisplay 0表示するように改造するための修正ポイント
diff --git a/chrome-remote-desktop.orig b/chrome-remote-desktop
index a40063b..de1b3b0 100755
--- a/chrome-remote-desktop.orig
+++ b/chrome-remote-desktop
@@ -66,11 +66,11 @@ XORG_DUMMY_VIDEO_RAM = 1048576 # KiB
# with large or multiple monitors. This is a comma-separated list of
# resolutions that will be made available if the X server supports RANDR. These
# defaults can be overridden in ~/.profile.
-DEFAULT_SIZES = "1600x1200,3840x2560"
+DEFAULT_SIZES = "1920x1080"
@YusukeIwaki
YusukeIwaki / RealmResultsObservable
Created April 27, 2017 12:57
RealmResults#asObservableをRxJava2対応に
package io.github.yusukeiwaki.realm_java_helpers;
import java.util.IdentityHashMap;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.MainThreadDisposable;
import io.realm.RealmChangeListener;
import io.realm.RealmModel;
package io.github.yusukeiwaki.example;
import android.os.Handler;
import android.os.Message;
// Activityに以下のような感じで実装する
//
// @Override public void onBackPressed() {
// if (backPressHandler.handleBackPressed()) {
// Toast.makeText(this, "アプリを終了するにはもう一回戻るキーを押して", Toast.LENGTH_SHORT).show();
@YusukeIwaki
YusukeIwaki / backing_field_practice.kt
Created January 6, 2018 06:05
backing fieldのgetでCloseしないといけないリソースを返して、そいつをuseしたときにitで新たなリソースが生成されないことを確認する
import java.io.Closeable
class Resource: Closeable {
init {
println("resource ref +1")
}
fun play() {
println("play")
}
import java.net.InetAddress
import java.net.Socket
import javax.net.ssl.SSLSocket
import javax.net.ssl.SSLSocketFactory
/**
* Enables TLS v1.2 when creating SSLSockets.
*
* For some reason, android supports TLS v1.2 from API 16, but enables it by
* default only from API 20.
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.Transformations
fun <X, Y> LiveData<X>.map(f: (X?) -> Y?): LiveData<Y> {
return Transformations.map(this, f)
}
fun <X, Y> LiveData<X>.switchMap(f: (X?) -> LiveData<Y>): LiveData<Y> {
return Transformations.switchMap(this, f)
}
apt-get update
apt-get install -y ant exuberant-ctags tomcat7 unzip || true
mkdir /tmp/opengrok
wget https://github.com/OpenGrok/OpenGrok/files/467358/opengrok-0.12.1.6.tar.gz.zip -O /tmp/opengrok.tar.gz.zip
wget http://jflex.de/release/jflex-1.6.1.tar.gz -O /tmp/jflex.tar.gz
unzip /tmp/opengrok.tar.gz.zip -d /tmp/
tar xzvf /tmp/opengrok-0.12.1.6.tar.gz -C /tmp/opengrok
tar xzvf /tmp/jflex.tar.gz -C /tmp/opengrok
cp /tmp/opengrok/jflex-1.6.1/lib/jflex-1.6.1.jar /tmp/opengrok/opengrok-0.12.1.6/lib/
cp -Rap /tmp/opengrok/opengrok-0.12.1.6/bin /usr/local/
<manifest>
<projects>
<project name="rails"
remote="https://github.com/rails/rails"
path="rails" />
<project name="rspec-core"
remote="https://github.com/rspec/rspec-core"
path="rspec-core" />
<project name="rspec-rails"
remote="https://github.com/rspec/rspec-rails"
@YusukeIwaki
YusukeIwaki / rakuten_bank_walking.js
Created June 11, 2018 19:53
puppeteer-page-walkerを使った、楽天銀行残高の確認コード
const userId = "??????????????";
const loginPassword = "???????????";
const branchCode = "???";
const accountNumber = "???????";
const secretWords = {
"卒業した中学校": "???????",
"母親の旧姓": "??????",
"??????": "??????"
};