Skip to content

Instantly share code, notes, and snippets.

View htsign's full-sized avatar
🤔

htsign htsign

🤔
View GitHub Profile
@htsign
htsign / StdIn.go
Last active April 23, 2021 14:35
get stdin lines
// Go
package main
import (
"bufio"
"fmt"
"os"
)
// ==UserScript==
// @name Key media control for niconico
// @namespace https://htsign.hateblo.jp
// @version 0.9.6
// @description ニコニコ動画本体側でいろいろ便利になった結果、今は音量を表示させる機能と次の動画を自動再生させない機能のみ
// @author htsign
// @match https://www.nicovideo.jp/watch/*
// @match https://live.nicovideo.jp/watch/*
// @updateURL https://gist.github.com/htsign/014c9b053f5eb62791fc04570ce79dcc/raw/MediaControlNiconico.user.js
// @downloadURL https://gist.github.com/htsign/014c9b053f5eb62791fc04570ce79dcc/raw/MediaControlNiconico.user.js
@htsign
htsign / ExceptionWrapper.java
Last active August 22, 2023 07:00
Lambda expression implementation with wrapping Checked exception for Java
public class ExceptionWrapper {
@SuppressWarnings("unchecked")
public static <T, E extends Exception> T exec(ThrowableSupplier<T, E> func, Function<E, T> orElse) {
try {
return func.getThrowable();
}
catch (WrapperException e) {
Throwable cause = e.getCause();
if (cause instanceof Exception) {
return orElse.apply((E) cause);
@htsign
htsign / ScancodeMap.reg
Created December 2, 2020 01:43
無変換キーを左Shiftに、変換キーを右Shiftに置き換える
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,2a,00,7b,00,36,00,79,00,00,00,00,00
@htsign
htsign / monad.ml
Created August 30, 2020 16:39
OCamlではモナドを一般化できない…?
module Monad = struct
module type MonadType = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val return : 'a -> 'a t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val flatmap : ('a -> 'b t) -> 'a t -> 'b t
end
module type MonadType2 = sig
@htsign
htsign / list.ml
Last active December 31, 2020 09:17
include Stdlib.List
let scan f ?init xs =
let scan' xs =
let rec aux acc xs =
match acc, xs with
| _, [] -> acc
| [], x :: xs -> aux [x] xs
| x :: _, y :: ys -> aux (f x y :: acc) ys
in
@htsign
htsign / seq.ml
Last active May 12, 2022 03:22
Stdlib.Seq extension / 正直 Core とか Batteries とか使えば終わる話ではある
include Stdlib.Seq
let cons x xs = fun () -> Cons (x, xs)
let rev xs =
let rec aux acc ys =
match ys () with
| Nil -> acc
| Cons (y, ys) -> aux (cons y acc) ys
in
module Option = struct
let bind (f : 'a -> 'b option) : 'a option -> 'b option = function None -> None | Some x -> f x
let map (f : 'a -> 'b) : 'a option -> 'b option = function None -> None | Some x -> Some (f x)
end
module Stream = struct
include Stream
let map (f : 'a -> 'b) (strm : 'a Stream.t) : 'b Stream.t =
Stream.from (fun _ ->
// ==UserScript==
// @name Auto change settings for Wandbox
// @namespace https://htsign.hateblo.jp
// @version 0.3.3
// @description save settings for each languages
// @author htsign
// @include https://wandbox.org/*
// @downloadURL https://gist.github.com/htsign/d06bc205c00b843aba52d18ebfb3310d/raw/settings-for-wandbox.user.js
// @updateURL https://gist.github.com/htsign/d06bc205c00b843aba52d18ebfb3310d/raw/settings-for-wandbox.user.js
// @grant none
@htsign
htsign / Option.cs
Last active July 21, 2021 13:58
simple C# Option(Maybe) MonadLike implementation
public static class Option
{
public static Option<T> Create<T>(T? value) => value != null ? new Some<T>(value) : Option<T>.None;
public static None<dynamic> None { get; } = new None<dynamic>();
}
public abstract class Option<T> : IEquatable<Option<T>>
{
public static Option<T> None { get; } = new None<T>();