Skip to content

Instantly share code, notes, and snippets.

@shouya
shouya / coroutine.rkt
Last active Jul 13, 2021
A toy coroutine implementation (implemented premitives: spawn, join, yield, sleep, select)
View coroutine.rkt
#lang racket
;;; global states
(define task-queue '())
(define joiners '())
(define curr-task-handle 'main)
(define halt (lambda () (display "not started yet")))
;;; queue-related functions
View netcalc.hs
import qualified Data.Text as T
import Control.Monad
import Data.List (unfoldr, intercalate)
import Data.Bits (testBit)
import Data.Function ((&))
data Node = Sat -- all 1
| Unsat -- all 0
| Mixed Node Node -- mixed (left, right)
deriving (Show)
@shouya
shouya / kubectl-exp
Last active Jun 3, 2021
Kubectl explain with syntax highlighting and cache
View kubectl-exp
#!/bin/bash
KUBE_EXPLAIN_CACHE_DIR=$HOME/.kube/cache/explain
p="$1"
f="$KUBE_EXPLAIN_CACHE_DIR/$p"
if [[ -z "$p" ]]; then
echo "Usage: $0 <path>"
echo "Example: $0 deploy.spec.template.spec.volumes"
View gpt3-lojban.txt
------------ (
I will show you how to translate lojban into English.
Lojban: coi rodo
English: Hi, everyone.
Lojban: mi citka lo plise
English: I eat the apple.
Lojban: lo plise cu se cikta mi
@shouya
shouya / lo-balmle-tamca.md
Last active Sep 7, 2020
loi selsa'a bau lo jbobau
View lo-balmle-tamca.md

ni'o loi balmle tamca

i lo xadni poi tolpinta je melbi

gi'e lo se dasni poi xunre

gi'e lo panci poi slari je titla

cu se ckaji loi balmle tamca i loi tamca

View compose.org

Composition of Functors/Applicatives/Monads*

Functor

A functor is a map between categories.

fmap :: (Functor f) => (a -> b) -> f a -> f b
@shouya
shouya / keybase.md
Created Feb 13, 2020
Keybase Proof
View keybase.md

Keybase proof

I hereby claim:

  • I am shouya on github.
  • I am shou (https://keybase.io/shou) on keybase.
  • I have a public key ASCmnqGO0FcviJ7Q-dUi3MxM1lTtvAbw38gGLA-HqITCmQo

To claim this, I am signing this object:

@shouya
shouya / Lens.hs
Created Oct 21, 2019
Proof that (s -> a, s -> b -> t) is indeed isomorphic to forall f. Functor f => (a -> f b) -> (s -> f t)
View Lens.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-}
@shouya
shouya / prng.hs
Created Aug 30, 2019
quick & dirty PRNG
View prng.hs
rnd = 123:map (\x -> (1664525 * x + 1013904223) `mod` 65536) rnd
@shouya
shouya / x.ruleset
Last active Jan 15, 2019
uMatrix ruleset
View x.ruleset
! uMatrix: Ruleset recipes 1.0
! Title: Shou's Ruleset
! Maintainer: Shou Ya
! CDN
* ajax.googleapis.com script allow
* cdn.bootcss.com script allow
* cdn.ravenjs.com script allow
* cdn.sstatic.net script allow
* cdnjs.cloudflare.com script allow