Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / DivideUUIDBy16bit.kt
Last active Sep 17, 2019
UUIDを16ビットで分割
View DivideUUIDBy16bit.kt
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 Apr 9, 2019
時間以内に2回タップしたら起きるプログラム on Activity with CoroutineScope
View CoroutineScopeActivity.kt
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 Apr 25, 2018
get day of week in month
View dayOfWeekInMonth.dart
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 Apr 24, 2018 — forked from wshaddix/gist:8797934
Gets the week number for a given date
View gist:a91cd8e840ca60e5f0b67ad9c408ec1b
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;
View flutter_navigator_sample.dart
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 Jan 14, 2019
adb shell dumpsys activity service GcmService
View adb shell dumpsys activity service GcmService - 0. reboot
$ 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 Jun 12, 2017
How to set elevation to RecyclerView?
View fragment_list.xml
<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">
View MonkeyTest
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 Nov 20, 2015
[Android] 9-Patch Validation
View 9patchvalidation.sh
# ----------------------------------------------------------------
# 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 Jan 26, 2016
get database from your debug app.
View getDatabase.sh
# 実機に接続
$ 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