Skip to content

Instantly share code, notes, and snippets.

View shikajiro's full-sized avatar

shikajiro shikajiro

View GitHub Profile
echo "start adb shell capture"
DATE=$(date +%Y%m%d%H%M%S)
FILENAME=${DATE}.mp4
DROPBOX_ID=******
adb shell screenrecord --verbose --time-limit 5 /sdcard/demo.mp4
adb pull /sdcard/demo.mp4 ~/Dropbox/Public/capture/${FILENAME}
adb shell rm /sdcard/temp.png
DROPBOX_URL=https://dl.dropboxusercontent.com/u/${DROPBOX_ID}/capture/${FILENAME}
weight = 9.5 # your dog weight
isCastration = True # your dog coefficient
coefficient = 1.8
if isCastration:
coefficient = 1.6
calorie = coefficient * (30 * weight + 70)
print calorie
@shikajiro
shikajiro / svg2png.groovy
Last active October 27, 2015 07:07
Android用のpng画像生成スクリプト。svg画像をmdpi, hdpi, xhdpi, xxhdpi, xxxhdpi毎のpng画像に変換する。要Inkscape
/* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
#macとRaspberryPiを有線LANで直接繋いだ時に、RaspPi側のipaddressを知るのに素敵なコマンド
sudo tcpdump | grep "192.168.2.*"
@shikajiro
shikajiro / build.gradle
Created February 16, 2015 15:09
Android新規プロジェクト時のbuild.gradleのテンプレート
//build.gradleのテンプレート
/*root*/
buildscript {
repositories {
jcenter()
mavenCentral()
mavenLocal()
maven { url 'http://download.crashlytics.com/maven' }
}
@shikajiro
shikajiro / MainActivity.java
Last active August 29, 2015 14:15
AndroidからOAuth2を使ってGoogle SpreadSheetへアクセスする方法 ref: http://qiita.com/shikajiro/items/63200af32b280be48bb5
//※ここにユーザーアカウント選択画面があると素敵だと思います。
//oauth tokenの取得
String token;
try {
token = GoogleAuthUtil.getToken(this, "shikajiro@gmail.com", "oauth2:https://spreadsheets.google.com/feeds");
Log.i("TAG", token);
} catch (UserRecoverableAuthException e) {
//最初のアクセスの場合かならずここに来る。
//ユーザーに承認を求める画面が表示される。
@shikajiro
shikajiro / build.gradle
Created December 9, 2014 08:10
Deploygateにgradleからアップロードする際に、メッセージをコンソールから指定する ref: http://qiita.com/shikajiro/items/7a4f26cb4c5fff8b2a93
deploygate {
userName = "shikajiro"
token = "hogehoge"
apks {
release {
sourceFile = file("build/outputs/apk/app-release.apk")
message = deploygateMsg
}
debug {
@shikajiro
shikajiro / file0.java
Created August 13, 2014 16:35
Androidでのテストで色々悩んだ結果robotiumになった件 ref: http://qiita.com/shikajiro@github/items/d28bf5eb4c9268f81131
public void testSayHello() {
//このclickで画面遷移すると仮定する。
onView(withId(R.id.greet_button))
.perform(click());
//遷移後の画面に"Hello Steve!"が表示されるが、このassertはOKだったりNGだったりする。
onView(withText("Hello Steve!"))
.check(matches(isDisplayed()));
}
curl --header "Authorization: key=<server key>" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"<registration id>\"],\"data\":{\"message\":\"Hello\"}}"
@shikajiro
shikajiro / AcceptActivity.java
Last active December 31, 2015 12:19
BTでデータを送信するコード
package com.example.ble;
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_ENABLE;
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
import static android.bluetooth.BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE;
import static android.bluetooth.BluetoothAdapter.getDefaultAdapter;
import java.io.IOException;
import java.io.InputStream;