Skip to content

Instantly share code, notes, and snippets.

View htsign's full-sized avatar
🤔

htsign htsign

🤔
View GitHub Profile
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>();
@htsign
htsign / hatebu-for-inoreader.user.js
Last active July 1, 2024 04:24
はてブの「○○ users」を InoReader に追加する
// ==UserScript==
// @name Hatena bookmark compatibility for InoReader
// @namespace https://htsign.hateblo.jp
// @version 0.4.0
// @description add Hatebu images for InoReader
// @author htsign
// @match https://www.inoreader.com/*
// @match https://jp.inoreader.com/*
// @downloadURL https://gist.github.com/htsign/f32a273d50f0f62b7d220140c5722cad/raw/hatebu-for-inoreader.user.js
// @updateURL https://gist.github.com/htsign/f32a273d50f0f62b7d220140c5722cad/raw/hatebu-for-inoreader.user.js
@htsign
htsign / Sample.cs
Last active November 20, 2020 05:25
prints 1, abc, 5, xyz
using System;
abstract class ItemBase
{
public abstract override string ToString();
}
class IntItem : ItemBase
{
private readonly int value;
public IntItem(int value) => this.value = value;
@htsign
htsign / MyStorage.js
Created December 19, 2019 02:18
simple implementation of Storage interface
export const MyStorage = (() => {
const sym = Symbol();
return class MyStorage {
constructor() {
if (arguments[0] !== sym) {
return new Proxy(new MyStorage(sym), {
get(target, prop) {
if (prop === 'length') return target.length;
const v = Reflect.get(target, prop);
return typeof v === 'function' ? v.bind(target) : target.getItem(prop);
set easymotion
set ideajoin
set surround
set commentary
set incsearch
nnoremap [c :action GotoNextError<CR>
nnoremap ]c :action GotoPreviousError<CR>
curl https://sh.rustup.rs -sSf | sh -s -- --profile default
set -U fish_user_paths ~/.cargo/bin $fish_user_paths
rustup completions fish > ~/.config/fish/completions/rustup.fish
cargo install ripgrep
cargo install bat
cargo install exa
cargo install fd
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
@htsign
htsign / list_creation.pl
Last active July 22, 2020 14:40
SWI-Prolog Exercise
list(N, N, [N]).
list(S, E, L) :-
S < E,
succ(S, X),
list(X, E, L1),
L = [S | L1].
list(S, E, L) :-
S > E,
succ(X, S),
list(X, E, L1),
iterator chunked*[T](xs: openArray[T], size: int, yieldRest = true): seq[T] =
var
i: int
let
last = xs.high
for j in countup(0, xs.len, size + 1):
i = j
if i + size > last: break
yield xs[i .. i + size]