Skip to content

Instantly share code, notes, and snippets.

@hatashiro
hatashiro / copy_bin.sh
Created January 18, 2022 09:01
Copy Mozc binaries after build
#!/usr/bin/env bash
# Please run after `bazel build package --config oss_linux -c opt`.
LIB_MOZC=/usr/lib/mozc
LIB_IBUS_MOZC=/usr/lib/ibus-mozc
SHARE_IBUS_COMPONENT=/usr/share/ibus/component
SHARE_IBUS_MOZC=/usr/share/ibus-mozc
BIN=/usr/bin
@hatashiro
hatashiro / gym_virtual_display_example.ipynb
Last active January 10, 2021 06:02
Rendering OpenAI gym in Google Colab with virtual displays
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hatashiro
hatashiro / stack_and_queue.js
Last active February 19, 2019 03:20
Stack and queue implementations in JavaScript
const print = str => document.write(str + '<br>');
const ITER_COUNT = 10000;
let t0, t1;
let stack, queue;
print("====== STACK ======");
class ArrayStack {
@hatashiro
hatashiro / condTypes.ts
Last active February 13, 2018 07:49
Type-level natural number addition using Conditional Types in TypeScript 2.8
type Nat = 0 | { succ: Nat };
type Succ<T extends Nat> = { succ: T };
type N0 = 0;
type N1 = Succ<N0>;
type N2 = Succ<N1>;
type N3 = Succ<N2>;
type N4 = Succ<N3>;
type N5 = Succ<N4>;
@hatashiro
hatashiro / keybase.md
Created September 27, 2017 14:57
keybase.md

Keybase proof

I hereby claim:

  • I am utatti on github.
  • I am noraesae (https://keybase.io/noraesae) on keybase.
  • I have a public key whose fingerprint is 27FE 8C5B 561E BE81 819F 61E8 80B6 67B4 6658 E8E9

To claim this, I am signing this object:

@hatashiro
hatashiro / lens.ts
Last active April 16, 2018 02:05
TypeScript Lens implementation with object property proxy
/*
* TypeScript Lens implementation with object property proxy
*
* ref:
*
* - Haskell Lens (https://hackage.haskell.org/package/lens)
* - Type-safe Lens by @mitaki28 (https://gist.github.com/mitaki28/ad39a69ab4fa73c99a822c0c3abc99dd)
*
*/
@hatashiro
hatashiro / nazo.ts
Created August 1, 2017 17:01
nazo.ts
class A { }
class B extends A { }
class C<T> { }
function test<T extends A>(t: () => T): (ctx: C<T>) => void {
return (ctx: C<T>) => {
};
}
@hatashiro
hatashiro / s_k_lt_k_proof.idr
Last active May 2, 2017 06:08
A proof of '∀ k ∈ Z: 1 + k > k' in Idris
module Main
%hide (>)
data (>) : (a : Nat) -> (b : Nat) -> Type where
ZeroCase : 1 + a > 0
OtherCase : a > b -> 1 + a > 1 + b
s_k_lt_k_proof : {k : Nat} -> 1 + k > k
s_k_lt_k_proof {k=Z} = ZeroCase
@hatashiro
hatashiro / pfsmfv.md
Last active May 1, 2017 05:06
Pure functional state management for Vuex
  • Make state immutable (in PS everything is immutable so 0 overhead for this)
  • No getters, no mutations: Lens, or something similar, may work here
    • get :: forall state a. (state -> a) -> ActionT state () a
    • commit :: forall state. (state -> state) -> ActionT state () Unit
  • actions :: forall state eff. ActionT state (Aff eff) Unit?
data AppState = AppState { counter :: Int }

type Action eff = ActionT AppState (Aff eff) Unit
@hatashiro
hatashiro / rl.md
Last active May 15, 2017 11:29
Reading list