Skip to content

Instantly share code, notes, and snippets.

View okue's full-sized avatar
🍇
Hello

Okue okue

🍇
Hello
  • Tokyo, Japan
  • 17:07 (UTC +09:00)
View GitHub Profile
@okue
okue / coroutineErrorHandling.kt
Last active July 16, 2020 03:04
例外ハンドラと失敗の伝搬
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.junit.jupiter.api.Test
@okue
okue / GrpcHeadersTest.java
Last active May 17, 2020 13:51
GrpcHeadersTest.java
package com.linecorp.armeria;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.ByteString;
@okue
okue / MyRequestContextStorageProvider.kt
Last active May 13, 2020 09:38
RequestContextStorageProvider for MDC
import com.linecorp.armeria.common.RequestContext
import com.linecorp.armeria.common.RequestContextStorage
import com.linecorp.armeria.common.RequestContextStorageProvider
import io.netty.util.AttributeKey
import org.slf4j.MDC
/**
* ```
* class MyRequestContextStorageProvider : RequestContextStorageProvider {
* override fun newStorage(): RequestContextStorage {
@okue
okue / TripleLoopByCoroutine.kt
Last active July 8, 2020 07:57
Write triple-nested loop by kotlin coroutine.
import mu.KotlinLogging
import org.junit.jupiter.api.Test
import java.lang.reflect.Field
import java.lang.reflect.Modifier
import kotlin.coroutines.Continuation
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.coroutines.RestrictsSuspension
import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn
import kotlin.coroutines.resume
-module(process_child).
-export([search/1]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% API functions %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% XXX:
%% スーパバイザから下へ辿るときは, supervisor:which_children/1で取得できる
%% プロセスのリストを使う.
@okue
okue / .bash_profile
Created April 18, 2018 07:55
ls color config.
alias ls='ls --color=auto'
alias la='ls -A'
alias ll='ls -alF'
PS1="\[\033[32m\]\u\[\033[0m\]\[\033[32m\] \W\[\033[0m\] $ "
eval `dircolors $HOME/.dir_colors`
@okue
okue / example.erl
Created April 4, 2018 02:47
TypEr(Erlang) example
-module(example2).
-export([hoge0/1, foo0/0, hoge1/1, foo1/0, hoge2/1, foo2/0, hoge3/1, foo3/0, hoge4/1, foo4/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TypEr infers
% -spec hoge0('a' | number()) -> 'bad' | number().
hoge0(X) when is_number(X) -> X;
hoge0(a) -> bad.
@okue
okue / .truffle.bash
Created December 23, 2017 05:21
truffleコマンドの補完
_truffle()
{
local first="help version init compile migrate deploy build test console install publish networks watch serve exec unbox"
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]} # previous argument
case "$COMP_CWORD" in
1) COMPREPLY=( $(compgen -W "$first" -- $cur) ) ;;
*) COMPREPLY=( $(compgen -W "$(ls)" -- $cur) ) ;;
esac
}
#! /usr/bin/env python3
# coding: utf-8
import cv2
import numpy as np
class ImageManipulater:
def resize(self, filename, outfilename):
@okue
okue / config.txt
Last active October 20, 2017 17:28
Raspberry pi: Display config -> /boot/config.txt
hdmi_pixel_freq_limit=200000000
hdmi_timings=1200 0 164 8 32 1920 0 12 2 6 0 0 0 60 0 163430000 0
hdmi_drive=2
disable_overscan=1
max_framebuffer_width=1920
max_framebuffer_height=1920
display_rotate=0
framebuffer_width=1200
framebuffer_height=1920