Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / DivideUUIDBy16bit.kt
Last active September 17, 2019 03:09
UUIDを16ビットで分割
import kotlinx.coroutines.*
import java.time.LocalDateTime
import java.util.UUID
import java.math.*;
/**
* UUIDを16ビット分割
*/
fun main(args : Array<String>) {
@granoeste
granoeste / CoroutineScopeActivity.kt
Created April 9, 2019 05:37
時間以内に2回タップしたら起きるプログラム on Activity with CoroutineScope
class CoroutineScopeActivity : AppCompatActivity(), CoroutineScope {
lateinit var job: Job
override val coroutineContext: CoroutineContext
get() = Dispatchers.Main + job
private var goBackToSleepJob: Job? = null
private var count: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@granoeste
granoeste / dayOfWeekInMonth.dart
Created April 25, 2018 02:39
get day of week in month
class DateUtils {
static DateTime dayOfWeekInMonth(int year, int month, int times, int weekday) {
// 指定年月の1日の日付
var dt = new DateTime(year, month, 1);
// 指定週の日 (1週目->1,2週目->8,3週目->15,4週目->22,4週目->29)
var day = (times - 1) * 7 + 1;
// 指定年月の1日の曜日と指定曜日の差
var offset = weekday - dt.weekday;
// 日を補正
if (offset < 0) {
@granoeste
granoeste / gist:a91cd8e840ca60e5f0b67ad9c408ec1b
Last active April 24, 2018 08:03 — forked from wshaddix/gist:8797934
Gets the week number for a given date
main () {
// get today's date
var now = new DateTime.now();
// set it to feb 10th for testing
//now = now.add(new Duration(days:7));
int today = now.weekday;
@granoeste
granoeste / flutter_navigator_sample.dart
Created April 19, 2018 00:57
Flutter Navigator Sample
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: 'Navigation with Routes',
routes: <String, WidgetBuilder>{
'/': (_) => new Splash(),
'/login': (_) => new Login(),
@granoeste
granoeste / adb shell dumpsys activity service GcmService - 0. reboot
Last active January 14, 2019 10:23
adb shell dumpsys activity service GcmService
$ adb shell dumpsys activity service GcmService
SERVICE com.google.android.gms/.gcm.GcmService 8ad9305 pid=2768
Client:
DeviceID: 4549450728827696292
connected=mtalk.google.com/108.177.125.188,port=5228
streamId=2/1,connects=1,connectAttempts=0,failedLogins=0,lastConnectionDurationS=0,lastConnectionErrorCode=0,packets=2/1,bytes=181/341
connectTime=00:00/00:00
Heartbeat: alarm(28:49 initial: 1740s)
=== Adaptive Heartbeat ===
Enabled FallFast? true
@granoeste
granoeste / fragment_list.xml
Created June 12, 2017 01:52
How to set elevation to RecyclerView?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipToPadding="false"
android:gravity="center"
android:padding="32dp">
adb shell monkey -p package -v --pct-trackball 0 --pct-syskeys 0 --throttle 300 10000
[Monkey - UI / アプリケーション エクササイザ - ソフトウェア技術ドキュメントを勝手に翻訳](http://www.techdoctranslator.com/android/developing/tools/monkey)
android - Change screen orientations during monkey run - Stack Overflow http://stackoverflow.com/questions/12872917/change-screen-orientations-during-monkey-run
@granoeste
granoeste / 9patchvalidation.sh
Created November 20, 2015 06:49
[Android] 9-Patch Validation
# ----------------------------------------------------------------
# Verifies the 9patch using aapt command
# ----------------------------------------------------------------
$ aapt
...
aapt c[runch] [-v] -S resource-sources ... -C output-folder ...
Do PNG preprocessing on one or several resource folders
and store the results in the output folder.
aapt s[ingleCrunch] [-v] -i input-file -o outputfile
@granoeste
granoeste / getDatabase.sh
Last active January 26, 2016 07:14
get database from your debug app.
# 実機に接続
$ adb shell
# コピー先の空ファイルを作成
$ touch /data/local/tmp/mydatabase.db
# アプリにrun-as
$ run-as [package]
$ cd databases
# ファイルコピー
$ dd if=mydatabase.db of=/data/local/tmp/mydatabase.db
# run-as からexit