Skip to content

Instantly share code, notes, and snippets.

View htsign's full-sized avatar
🤔

htsign htsign

🤔
View GitHub Profile
// ==UserScript==
// @name YouTube Comment Username Reveals
// @description add user name for comment
// @namespace https://htsign.hateblo.jp
// @version 0.3.5
// @author htsign
// @match https://www.youtube.com/*
// @updateURL https://gist.github.com/htsign/14484659fa9224853835aeeae0cdbe10/raw/YouTube-Comment-Username-Reveals.user.js
// @downloadURL https://gist.github.com/htsign/14484659fa9224853835aeeae0cdbe10/raw/YouTube-Comment-Username-Reveals.user.js
// @grant none
@htsign
htsign / MathmaticalAlphanumericSymbols.dic
Last active April 6, 2024 09:16
Mathmatical Alphanumeric Symbols dictionary for SKK system
;; -*- mode: fundamental; coding: utf-8 -*-
;; Mathmatical Alphanumeric Symbols dictionary for SKK system
;;
;; https://www.asahi-net.or.jp/~ax2s-kmtn/ref/unicode/u1d400.html
;;
;; okuri-nasi entries
A /𝔸/
B /𝔹/
C /ℂ/
D /𝔻/
@htsign
htsign / hatebu-for-bing.user.js
Last active March 23, 2023 12:34
はてブの「○○ users」を Bing に追加する
// ==UserScript==
// @name Hatena bookmark compatibility for Bing
// @namespace https://htsign.hateblo.jp
// @version 0.0.3
// @description add Hatebu images for Bing
// @author htsign
// @match https://www.bing.com/search?*
// @downloadURL https://gist.github.com/htsign/b2c913f28e4b8646d0b30c4170e7d34c/raw/hatebu-for-bing.user.js
// @updateURL https://gist.github.com/htsign/b2c913f28e4b8646d0b30c4170e7d34c/raw/hatebu-for-bing.user.js
// @grant none
@htsign
htsign / main.ml
Last active September 9, 2023 13:16
let string_of_list ~to_string xs =
"[" ^ String.concat "; " (List.map to_string xs) ^ "]"
let string_of_opt ~to_string =
function None -> "None" | Some x -> Printf.sprintf "Some(%s)" @@ to_string x
let () =
let print_optlist theme xs =
let xs = OptionList.to_optlist xs in
let lstr = string_of_list ~to_string:(string_of_opt ~to_string:string_of_int) xs in
module List = struct
include Stdlib.List
let hd_opt xs = try Some (hd xs) with Failure _ -> None
end
let char_list_of_string string =
let rec aux acc idx =
if idx >= 0 then
(* libraries definitions *)
(* Haskell's Data.Function.on implementation in OCaml *)
module Data : sig
module Function : sig
val on : ('b -> 'b -> 'c) -> ('a -> 'b) -> ('a -> 'a -> 'c)
end
end = struct
module Function = struct
let on bf f = fun x y -> bf (f x) (f y)
@htsign
htsign / List.ml
Created March 10, 2022 17:31
OCaml `List.group_by`
module List = struct
include Stdlib.List
let group_by (projection : 'a -> 'key) (xs : 'a list) : ('key * 'a list) list =
let pairs = xs |> List.map (fun x -> projection x, x) in
let rec aux acc = function
| [] -> acc |> List.rev
| ((k, _) :: _) as xs ->
let ys, zs = xs |> List.partition (fun t -> fst t = k) in
@htsign
htsign / Pair.java
Created July 6, 2021 03:47
nicely worked on Java8
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Pair<Left, Right> {
private static final List<Pair<?, ?>> cache = new ArrayList<>();
public final Left left;
public final Right right;
private Pair(Left left, Right right) {
// required: FSharp.Control.AsyncSeq
open FSharp.Control
open System.Diagnostics
open System.Drawing
open System.Windows.Forms
let inline initCollectionWithCtor< ^a, 'b, 'c when ^a : (member Add : 'b -> 'c)> items collection =
let add xs x = (^a : (member Add : 'b -> 'c) (xs, x))
items |> List.fold (fun (xs : 'a) x -> add xs x |> ignore; xs) collection
@htsign
htsign / phantomTypeSample.ml
Last active April 13, 2021 01:03
prevent excessive sorting w/ phantom types
module MyArray : sig
type ('a, 'status) t
type regular
type sorted
val create : 'a array -> ('a, regular) t
val to_array : ('a, 'status) t -> 'a array
val sort : ?comparer:('a -> 'a -> int) -> ('a, regular) t -> ('a, sorted) t
end = struct
type ('a, 'status) t = Array of 'a array