Skip to content

Instantly share code, notes, and snippets.

@hkurokawa
hkurokawa / file0.txt
Last active August 29, 2015 14:05
モバイルアプリ開発者のための mitmproxy 入門 ref: http://qiita.com/hkurokawa/items/9034274cc1b9e1405c68
pip install mitmproxy
@hkurokawa
hkurokawa / jsonTime.go
Last active August 29, 2015 14:06
Serialize/Deserialize time.Time to/from JSON
// This code snippet demonstrates how to serialize/deserialize a struct
// who has one or more date fields to/from JSON.
//
// Though, this example implements both encoding.TextMarshaler and json.JSONMarshaler,
// either is necessary to format/parse time.Time in JSON format.
package main
import (
"encoding/json"
"fmt"
#include "stdio.h"
int unique_1(char* str) {
int count[256] = {0};
int i = 0;
while(1) {
char c = str[i];
if (c == '\0') return 1;
if (count[c] > 0) {
return -1;
@hkurokawa
hkurokawa / postNewReviewsHipchat.sh
Last active March 10, 2016 06:54
Post Google Play App. Reviews to HipChat
verifyCmd() {
for cmd in ${@}; do
if [ -z "$(which $cmd)" ]; then
echo "$cmd not found in PATH: $PATH"
return 1
fi
done
}
: ${GOOGLE_BUCKET_ID?"Need to set GOOGLE_BUCKET_ID"}
@hkurokawa
hkurokawa / MyApplication_app_build.gradle
Created January 14, 2015 02:57
Android Studio Sample Project importing Facebook SDK
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.hkurokawa.myapplication"
minSdkVersion 14
targetSdkVersion 21
@hkurokawa
hkurokawa / CachedAsyncTaskLoader.java
Created March 27, 2015 08:40
AsyncTaskLoader Sample
/**
* <p>
* This loader caches the result so that it can be taken later - for example, after configuration
* was changed and activity is re-created.
* </p>
* Created by hiroshi on 2014/12/03.
*/
public abstract class CachedAsyncTaskLoader<T> extends AsyncTaskLoader<T> {
private T mCached;
private Throwable mError;
@hkurokawa
hkurokawa / readDeviceIdleController.md
Last active August 29, 2015 14:23
DeviceIdleController を読んでみた

DeviceIdleController とは

SystemService で常に実行されている。M Preview の Doze モードを実装するためのもの。

挙動

以下のイベントを監視する。

  1. Screen on/off
  2. Charging status
  3. Significant motion detect
@hkurokawa
hkurokawa / MainActivity.java
Created August 24, 2015 22:17
Screen is flashing when adding a SurfaceView
package com.hkurokawa.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends AppCompatActivity {
ViewGroup content;
@hkurokawa
hkurokawa / MainActivity.java
Created August 25, 2015 04:06
SurfaceView を足そうとすると画面が点滅する ref: http://qiita.com/hkurokawa/items/e80f6525005b81bb5636
package com.hkurokawa.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends AppCompatActivity {
ViewGroup content;
@hkurokawa
hkurokawa / MainActivity.java
Created September 29, 2015 06:19
Really simple sample application
package com.hkurokawa.sampleapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;