This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Go | |
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "os" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |