Skip to content

Instantly share code, notes, and snippets.

View yasukotelin's full-sized avatar

Yasuhiro Kikura yasukotelin

View GitHub Profile
@yasukotelin
yasukotelin / CapsToCtrl.reg
Last active September 15, 2019 16:37
CapsLock -> Ctrl
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
func convStringsToInts(strings []string) []int {
result := make([]int, len(strings))
for i, v := range strings {
num, _ := strconv.Atoi(v)
result[i] = num
}
return result
}
@yasukotelin
yasukotelin / atcorder.go
Created June 14, 2020 10:38
main.go for AtCorder
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var scanner = bufio.NewScanner(os.Stdin)
@yasukotelin
yasukotelin / Event.kt
Last active July 2, 2020 06:57
Multiple observe single LiveData.
package [YOUR PACKAGE]
/*
* Copyright 2018 Google LLC
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
@MainThread
inline fun <reified VM : ViewModel> Fragment.parentViewModels(
noinline ownerProducer: () -> ViewModelStoreOwner = { requireParentFragment() },
noinline factoryProducer: (() -> ViewModelProvider.Factory)? = null
) = createViewModelLazy(VM::class, { ownerProducer().viewModelStore }, factoryProducer)
macro_rules! hashmap {
($( $key: expr => $val: expr ),*) => {{
let mut map = ::std::collections::HashMap::new();
$( map.insert($key, $val); )*
map
}}
}
@yasukotelin
yasukotelin / main.rs
Last active August 16, 2020 07:30
Rust 競技プログラミング用テンプレート
fn main() {
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
@yasukotelin
yasukotelin / ViewPagerScrollingViewBehavior.kt
Created August 19, 2020 16:34
ViewPager2 in CoordinatorLayoutでBottomのViewを固定するBehavior
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.appbar.AppBarLayout
class ViewPagerScrollingViewBehavior(context: Context?, attrs: AttributeSet?) :
AppBarLayout.ScrollingViewBehavior(context, attrs) {
override fun layoutDependsOn(
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.NestedScrollingChild
import androidx.core.view.NestedScrollingChildHelper
class NestedCoordinatorLayout : CoordinatorLayout, NestedScrollingChild {
private var mChildHelper: NestedScrollingChildHelper
@yasukotelin
yasukotelin / BottomWidgetBehavior.kt
Created August 19, 2020 16:37
CoordinatorLayoutでBottomの要素を消す挙動をするBehavior
class BottomWidgetBehavior<V : View>(context: Context, attrs: AttributeSet) :
CoordinatorLayout.Behavior<V>(context, attrs) {
override fun onStartNestedScroll(
coordinatorLayout: CoordinatorLayout,
child: V,
directTargetChild: View,
target: View,
axes: Int,
type: Int