Skip to content

Instantly share code, notes, and snippets.

View htsign's full-sized avatar
🤔

htsign htsign

🤔
View GitHub Profile
@htsign
htsign / fetchApiHeadersGetter.js
Last active October 26, 2016 10:39
get all response headers and a parsed JSON result with "Fetch API" on ES2015
(() => {
const promise = fetch("//api.github.com/users/octocat/orgs");
promise.then(res => {
const headers = res.headers;
for (let key of headers.keys()) {
console.log(`${key} : ${headers.get(key)}`);
}
return res.json(); // return JSON object, not serialized string
@htsign
htsign / convertTextToLink.user.js
Last active November 1, 2016 02:42
URLらしき文字列なのにリンク(aタグ)になっていないものを対象に、順次リンクを付与していきます。
@htsign
htsign / confortable-xpath.user.js
Last active January 14, 2024 02:30
XPathをより使いやすい形で提供します。
// ==UserScript==
// @name confortable-xpath
// @namespace https://htsign.hateblo.jp
// @description XPathをより使いやすい形で提供します。
// @match *
// @version 1.0.8
// @grant none
// @run-at document-start
// @updateURL https://gist.github.com/htsign/a36e74eee2151dc2c047e03245638f68/raw/confortable-xpath.user.js
// @downloadURL https://gist.github.com/htsign/a36e74eee2151dc2c047e03245638f68/raw/confortable-xpath.user.js
@htsign
htsign / fibonacci.n
Last active May 8, 2017 13:13
fibonacci algorism implementation of Nemerle with memoization
using Nemerle;
using System.Console;
using System.Numerics;
module Program
{
Main() : void
{
def fib(n)
{
@htsign
htsign / blink-star.user.js
Last active January 31, 2024 06:37
はてなブックマークにて、自分が付けたスターを点滅させて見分けがつくようにします。
module RegExp
open System.Text.RegularExpressions
type NamedValue = Map<string, string>
let private noneOrList = function [] -> None | xs -> Some xs
let private getValues (m : Match) = List.tail [for g in m.Groups -> g.Value]
let private getNamedValues (ns : string []) (gs : GroupCollection) = List.tail [for n in ns -> n, gs.[n].Value] |> Map.ofList
@htsign
htsign / NodeIteratorWithIterable.js
Last active August 21, 2020 16:11
NodeIterator with Iterable interface.
if (typeof NodeIterator.prototype[Symbol.iterator] !== 'function') {
Object.defineProperty(NodeIterator.prototype, Symbol.iterator, {
configurable: true,
writable: true,
*value() {
let node;
while ((node = this.nextNode()) !== null) {
yield node;
}
}
@htsign
htsign / ChartHelper.ts
Created June 24, 2017 09:18
how to get scale type of d3 (require es6-shim)
class ChartHelper {
public static checkScaleType<T, R>(scale: Scale<T, R>): ScaleType {
const f = scale.copy.toString();
switch (true) {
case f.includes("d3_scale_linear") : return "linear";
case f.includes("d3_scale_identity"): return "identity";
case f.includes("d3_scale_pow") : return "power";
case f.includes("d3_scale_log") : return "log";
case f.includes("d3_scale_quantize"): return "quantize";
case f.includes("d3_scale_quantile"): return "quantile";
@htsign
htsign / KeyBindingsLikeVS.epf
Created October 19, 2017 00:59
Key Bindings like Visual Studio for Eclipse
#Thu Oct 19 09:54:42 JST 2017
\!/=
/instance/org.eclipse.ui.workbench/org.eclipse.ui.commands=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<org.eclipse.ui.commands>\r\n<activeKeyConfiguration keyConfigurationId\="org.eclipse.cdt.ui.visualstudio"/>\r\n<keyBinding commandId\="org.eclipse.wst.jsdt.ui.edit.text.java.open.editor" contextId\="org.eclipse.wst.jsdt.ui.javascriptViewScope" keyConfigurationId\="org.eclipse.ui.defaultAcceleratorConfiguration" keySequence\="F12"/>\r\n<keyBinding contextId\="org.eclipse.jst.jsp.ui.structured.text.editor.jsp.scope" keyConfigurationId\="org.eclipse.ui.defaultAcceleratorConfiguration" keySequence\="ALT+SHIFT+R"/>\r\n<keyBinding contextId\="org.eclipse.ui.textEditorScope" keyConfigurationId\="org.eclipse.ui.defaultAcceleratorConfiguration" keySequence\="CTRL+K"/>\r\n<keyBinding contextId\="org.eclipse.ui.contexts.window" keyConfigurationId\="org.eclipse.ui.defaultAcceleratorConfiguration" keySequence\="CTRL+."/>\r\n<keyBinding contextId\="org.eclipse.debug.ui.debugging" keyCon
@htsign
htsign / MyStringUtils.java
Last active September 28, 2020 09:11
replacement method with evaluator in java
import java.math.BigDecimal;
import java.util.List;
import java.util.function.BiFunction;
import java.util.regex.Matcher;
import java.util.regex.MatchResult;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class MyStringUtils {
public static String replaceEx(