Skip to content

Instantly share code, notes, and snippets.

View yaraki's full-sized avatar
🏠
Working from home

Yuichi Araki yaraki

🏠
Working from home
  • Google, Inc.
  • Tokyo
View GitHub Profile
@yaraki
yaraki / mrex.py
Created December 21, 2013 16:59
Simplest MonkeyRunner script that keeps on tapping the specified position every second
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
while 1:
device.touch(540, 1560, MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1.0)
@yaraki
yaraki / pi.lisp
Created January 22, 2014 14:08
Ramanujan's formulas of pi in Common Lisp
(defun fact (n)
(let ((r 1))
(loop
for i from 2 to n
do (setf r (* i r))
finally (return r))))
(defun calc-pi-1 (max)
(/ 1
(* (/ (* 2 (sqrt 2.0d0)) (expt 99 2))
@yaraki
yaraki / simplefind.c
Created July 3, 2014 13:26
Lists up all the subdirectories in the current directory recursively.
#include <stdio.h>
#include <string.h>
#include <dirent.h>
void list(const char *path)
{
DIR *dir;
struct dirent *entry;
char entry_path[PATH_MAX];
char *entry_name = entry_path;
@yaraki
yaraki / CheckerView.java
Created February 20, 2017 07:06
Android View that shows a dummy checkered pattern
/*
* Copyright (C) 2017 The Android Open Source Project
*
* 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
@yaraki
yaraki / gc.c
Created September 14, 2017 12:44
Simple GC
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef enum _Type Type;
enum _Type {
TYPE_INT,
TYPE_PAIR,
};
@yaraki
yaraki / main_activity.xml
Last active June 25, 2018 05:51
Place an icon at the end of a "wrap_content" text view
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
@yaraki
yaraki / fluent.kt
Created July 11, 2018 13:07
Fluent testing for Kotlin in Japanese
package io.github.yaraki.superfluent
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.greaterThan
import org.junit.Test
class Sample {
@yaraki
yaraki / CreateLiveData.kt
Created July 9, 2018 06:44
LiveData + Kotlin Coroutines
package io.github.yaraki.coroutineex
import android.arch.lifecycle.LiveData
import android.content.Context
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.channels.SendChannel
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
@yaraki
yaraki / MainViewModel.kt
Created September 28, 2018 07:24
FPS as LiveData (with coroutine)
/*
* Copyright (C) 2018 The Android Open Source Project
*
* 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
@yaraki
yaraki / FirestoreLiveData.kt
Created May 20, 2019 07:53
Firebase Query as LiveData
/**
* Copyright 2019 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
package com.example.firestore
import android.util.Log
import androidx.lifecycle.LiveData
import com.google.firebase.firestore.*