Skip to content

Instantly share code, notes, and snippets.

@camlspotter
camlspotter / bsky_lexicon.ml
Created July 12, 2023 02:34
BlueSky Lexicon type defs in OCaml
type unknown
type blob
type cid_link
type 'a nullable = 'a option
type actor_adultContentPref = {
enabled: bool }
@camlspotter
camlspotter / bluesky.sh
Created July 4, 2023 02:39
Access BlueSky
# You need
#
# - curl
# - jq
# Your handle, ex xxxx.bsky.social or your custom handle like dailambda.jp.
# No '@' mark.
HANDLE=hogehoge.bsky.social
# Your App password: Settings > App password > Add App password
(* a + b (mod m) *)
let addmod a b m =
assert (0 <= a && 0 <= b);
let a = a mod m in
let b = b mod m in
if a < m - b then
(* Case A: a + b < m *)
a + b
else
(* Case B: a + b >= m
@camlspotter
camlspotter / lablgtk_resize.ml
Created June 29, 2022 02:31
Small program to detect window resize
let () =
ignore @@ GMain.Main.init ();
let window = GWindow.window ~width:100 ~height:100 () in
ignore @@ window#event#connect#configure ~callback:(fun ev ->
let open GdkEvent.Configure in
prerr_endline (Printf.sprintf "Configure %dx%d+%d+%d"
(width ev)
(height ev)
(x ev)
(y ev));
@camlspotter
camlspotter / haha.md
Last active July 4, 2018 09:44
OCaml zippy tutorial in Japanese
hahaha
(** Generation of typerep methods for tag-checking *)
(* XXX simply moved to sig.ml ? *)
open Typerep_lib.Std
module Sig = struct
open Sig
type res = [%import: Sig.res]
and ftypekind = [%import: Sig.ftypekind]
match x with
| OpeExp (e1, op, e2) ->
begin match op with
| Plus -> ...
| Minus -> ...
end
| Root (e1, e2) -> ...
module Id = struct
let name = "pa_fun_fields"
let version = "1.0"
end
open Camlp4
module Make (Syntax : Sig.Camlp4Syntax) = struct
include Syntax
open Spotlib.Spot
open GapiUtils.Infix
open GapiLens.Infix
open GapiLens.StateInfix
open GapiMonad.SessionM
module OAuth2 = GapiOAuth2
module Conv = GapiConversation
module Service = GapiService
@camlspotter
camlspotter / gist:5629762
Last active December 17, 2015 15:09
適当に重み付けして高得点から並べてみました。うーん。納得できるのもあるし、えってのもある。 えええ俺だけ行った事の無い、わひろ閉店?ああ、住所が違うから移転前のか。焦った。 Yong Huat は… Joo Chiat と East coast の交差点にあるきちゃないホッケンミーの店だがそんな美味いのか? Puteri Mas はドリアンパフの店。納得の高得点。 Coriander は洋風の店、つい最近出来た Geylang Lor 29 は有名なホッケンミー Katsuya はトンカツの店なんだけど…日本人としてはどうもねえ Easter & Northern Dumpling は納得。ただこないだビールをハルビンからカールスバーグに変えた。残念すぎ Joo Chiat Prawn…
[ { "score": 300, "name": "(Closed) Wahiro",
"address": "112 East Coast Road",
"geo": [ 1.30501126709, 103.905173164 ] },
{ "score": 300, "name": "Yong Huat", "address": "125/127 East Coast Road",
"geo": [ 1.306044, 103.904794 ] },
{ "score": 300, "name": "Puteri Mas (Joo Chiat)",
"address": "475A Joo Chiat Road", "geo": [ 1.3063423, 103.904712 ] },
{ "score": 297, "name": "Coriander", "address": "220 East Coast Road",
"geo": [ 1.3073885145, 103.907421243 ] },
{ "score": 294, "name": "Geylang Lor 29 Fried Hokkien Mee",