Skip to content

Instantly share code, notes, and snippets.

View kakajika's full-sized avatar
🏠
STAY HOME

Keita Kajiwara kakajika

🏠
STAY HOME
View GitHub Profile
package zundoko;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class Zundoko {
private String z = "ズン";
private String d = "ドコ";
{
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": ["source.kt"],
"shell_cmd": "gradle -Pmain=\"${file_name}\""
}
@akio0911
akio0911 / DateExtension.swift
Last active April 11, 2018 12:39
Dateのextensionに依存性注入してみる
extension Date {
struct Extension {
let date: Date
struct Dependencies {
let calendar: Calendar
let locale: Locale
let timeZone: TimeZone
}
@hiroyuki-seto
hiroyuki-seto / ContextMenu.md
Created November 10, 2016 12:35
Android Nで変わったContextMenuまわり

Android Nで変わったContextMenuまわり

知りたかった点

  • Nでは長押しした位置にContextMenuが出るがどうやっているか
  • View#performLongClick(int,int)View#showContextMenu(int,int)が追加されている
  • View#performLongClickInternalで指の位置があるかによってshowContextMenu(int,int)showContextMenu()を呼び分け
  • NではDarkThemeにするとPopupWindowが黒背景になるが、どうにかならんのか
  • M以前はDialogだったのでテーマを書き換えられた。NはPopupかつcom.android.internal.R.attr.contextPopupMenuStyleを使っているのできびしそう?

追ってみた

@kakajika
kakajika / PathSimplifier.swift
Last active July 14, 2020 13:22
SwiftによるCGPathの曲線近似の実装(Inspired by paper.js)
// PathSimplifier.swift
import UIKit
private let TOLERANCE: CGFloat = 1e-6
private let EPSILON: CGFloat = 1e-12
extension CGPoint {
func add(p: CGPoint) -> CGPoint {
return CGPointMake(x+p.x, y+p.y)
@LouisCAD
LouisCAD / GooglePlayServices.kt
Created November 23, 2017 16:19
Allows using Google Play Services Task API in Kotlin Coroutines, plus Play Services availability check made easier.
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.Task
import splitties.init.appCtx
import kotlin.coroutines.experimental.suspendCoroutine
val googleApiAvailability = GoogleApiAvailability.getInstance()!!
inline val playServicesAvailability get() = googleApiAvailability.isGooglePlayServicesAvailable(appCtx)
@JvmName("awaitVoid")
suspend fun Task<Void>.await() = suspendCoroutine<Unit> { continuation ->
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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
/*
* Copyright 2016 Google Inc.
*
* 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
@yamacraft
yamacraft / Firebase-Admin-NodeJs.md
Last active January 4, 2023 10:28
node.jsからサービスアカウント使ってFirebaseへ接続する時のメモ

検索ワード:Firebase Auth サービスアカウント nodejs

(注意)日本語版の情報は既に少し古い

下準備

サービスアカウントの作成

  1. Firebaseコンソールサイト>歯車>権限 でGoogle APIコンソールっぽい管理画面へ。
  2. サービスアカウント>サービスアカウントを作成をクリックしてアカウントを作成
@rharter
rharter / SharedPreferenceLiveData.kt
Last active March 19, 2023 08:15
Creates LiveData objects that observe a value in SharedPreferences while they have active listeners.
import android.arch.lifecycle.LiveData
import android.content.SharedPreferences
abstract class SharedPreferenceLiveData<T>(val sharedPrefs: SharedPreferences,
val key: String,
val defValue: T) : LiveData<T>() {
private val preferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == this.key) {
value = getValueFromPreferences(key, defValue)