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
// We often see sequential method call. | |
AlertDialog.Builder builer = new AlertDialog.Builder(this); | |
builer.setTitle("タイトル"); | |
builer.setMessage("メッセージ"); | |
builer.setPositiveButton(android.R.string.ok, this.listener); | |
// We can use method chain. | |
AlertDialog.Builder builer = new AlertDialog.Builder(this); | |
.setTitle("タイトル") | |
.setMessage("メッセージ") |
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
// https://github.com/mokelab/android-HTTPClient-Rx-OkHTTP | |
HTTPClient client = new HTTPClientImpl(new OkHttpClient()); | |
// client.send()はObservableを返す | |
client.send(Method.GET, "https://gae-echoserver.appspot.com/test", null, null) | |
.subscribeOn(Schedulers.computation()) // sendの中身はワーカースレッドで実行する | |
.observeOn(AndroidSchedulers.mainThread()) // Observerの中はAndroidのメインスレッドで実行する | |
.subscribe(new Observer<HTTPResponse>() { | |
@Override | |
public void onSubscribe(Disposable d) { } |
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
03-07 21:34:50.984 27340 27340 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {org.twentyeight.momo/org.twentyeight.momo.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference | |
03-07 21:34:50.984 27340 27340 E AndroidRuntime: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103) | |
03-07 21:34:50.984 27340 27340 E AndroidRuntime: at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) | |
03-07 21:34:50.984 27340 27340 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481) | |
0 |
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 DemoDialogFragment extends DialogFragment { | |
public static DialogFragment newInstance(int requestCode) { | |
DialogFragment dialog = new DemoDialogFragment(); | |
Bundle args = new Bundle(); | |
args.putBoolean(ARGS_CALLER_ACTIVITY, true); | |
args.putInt(ARGS_REQUEST_CODE, requestCode); | |
dialog.setArguments(args); | |
return dialog; | |
} |
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
<?php | |
// あってそうだけど、だめな例 | |
// 1 : 普通 | |
// 2 : 当座 | |
// 3 : 定期 という対応があるとする。 | |
$bankType = "1"; // DBに入っている銀行口座の種類 | |
$label = ($bankType == '1') ? '普通' : | |
($bankType == '2') ? '当座' : '定期'; | |
echo $label; |
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 impl | |
import ( | |
m "../" | |
"database/sql" | |
) | |
type userDAO struct { | |
connection *Connection | |
} |
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 csv | |
import sys | |
#Description,Transaction Date,Transaction Time,Tax Type,Transaction Type,Refund Type,Product Title,Product id,Product Type,Sku Id,Hardware,Buyer Country,Buyer State,Buyer Postal Code,Buyer Currency,Amount (Buyer Currency),Currency Conversion Rate,Merchant Currency,Amount (Merchant Currency) | |
def debugPrint(row): | |
print "Description=%s" % (row[0]) | |
print "Transaction Date=%s" % (row[1]) | |
print "Transaction Time=%s" % (row[2]) | |
print "Tax Type=%s" % (row[3]) | |
print "Transaction Type=%s" % (row[4]) |
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
var MyException = (function () { | |
function MyException(status, body) { | |
this.status = status; | |
this.body = body; | |
} | |
return MyException; | |
})(); | |
function moke() { | |
try { | |
throw new MyException(404, { "msg": "not found" }); |
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
module demo { | |
export interface App { | |
// ノンブロッキングAPI。callbackで結果を受け取るので結果はany | |
login(username:string, password:string, callback:LoginCallback); | |
// ブロッキングAPI。この場合はUserオブジェクトを返したい | |
login(username:string, password:string) : User; | |
} | |
export class AppImpl implements App { | |
} |
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
abstract class BlockingTask<T> { | |
private boolean mDone; | |
private T mResult; | |
private Exception mException; | |
public void execute() { | |
mDone = false; | |
doAsyncCall(); | |
while (!mDone) { | |
try { Thread.sleep(300); } catch (Exception e) { } |