Skip to content

Instantly share code, notes, and snippets.

View daneko's full-sized avatar

Koichi Akatsuka daneko

View GitHub Profile
@daneko
daneko / sample.py
Created June 14, 2020 06:53
request decorator python
# coding: utf-8
from flask import Flask, request, jsonify
import dataclasses
import typing
app = Flask(__name__)
def dict_to_dataclass(k, d: dict, typechecker: typing.Callable[[str, typing.Any, typing.Any],None], parent_fields=None):
/**
* wrap sharedViewModel
* [reference](https://github.com/InsertKoinIO/koin/issues/442#issuecomment-527821213)
*/
inline fun <reified T : ViewModel> Fragment.navigationViewModel(
@IdRes navGraphId: Int,
qualifier: Qualifier? = null,
noinline parameters: ParametersDefinition? = null
): Lazy<T> = sharedViewModel(
qualifier = qualifier,
import arrow.core.*
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type
class OptionJsonAdapterFactory : JsonAdapter.Factory {
override fun create(type: Type, annotations: MutableSet<out kotlin.Annotation>, moshi: Moshi): JsonAdapter<*>? {
@daneko
daneko / after.kt
Last active March 10, 2019 13:11
migration 0.8.2 to 0.9.0 (is this correct? please tell me recommended code!)
// using 0.9.0
import arrow.Kind
import arrow.core.Either
import arrow.core.Try
import arrow.core.left
import arrow.core.right
import arrow.data.EitherT
import arrow.effects.ForIO
import arrow.effects.IO
@daneko
daneko / memo.md
Created August 27, 2017 02:02
razer blade stealth Ubuntu化記録

前提

まっさらにするんじゃなくてとりあえずDualBootな

install

  • どう見ても基本Partitionが4つあったので、Recovery PatitionをBackup
  • この辺のPrepareを実行
  • 一旦そのままUbuntuのInstallをトライ(partitionがあれだから駄目なのでは?と思ったら入った)
@daneko
daneko / memo.md
Last active May 10, 2018 05:39
Slack絵文字の一括登録とか
@daneko
daneko / FormEncodingBuilderEx.java
Created January 31, 2015 03:33
FormEncodingBuilder + set charset set media type
/*
* Copyright (C) 2014 Square, 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
@daneko
daneko / almond_cream_cake.md
Last active August 29, 2015 14:06
お菓子作りメモ

低糖質なケーキ土台

これだけでも美味しい

材料

品目
バター 120g
ラカントS 30g
@daneko
daneko / memo.md
Last active August 29, 2015 13:57
[WIP] mac 上で hadoop とか spark とか使って mapreduce するまで

spark使ってmapreduceしたい!

目標

  • どこか適当な場所にあるHDFSで持っているファイルに対してSpark使ってMapReduce

環境構築

hadoop

@daneko
daneko / test.kt
Last active December 31, 2015 08:38
たろー先生助けて!
fun hoge(i : Int) = if(i % 3 == 0 ) null else i
val sum = (1 .. 10).map(::hoge).filterNotNull().reduce{ a, b -> a + b}
println(sum)