Skip to content

Instantly share code, notes, and snippets.

ncaq ncaq

Block or report user

Report or block ncaq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ncaq
ncaq / drop-short-yomi.ml
Created May 14, 2020
辞書ファイルから読みがなが短いものを除去
View drop-short-yomi.ml
#use "topfind"
#require "camomile"
open CamomileLibrary
let print_filter_word () =
let rec print_filter_word_sub () =
let line = read_line () in
let yomi = List.hd (String.split_on_char '\t' line) in
if 1 < UTF8.length yomi then print_endline line else ();
print_filter_word_sub () in
@ncaq
ncaq / destructive-assignment.js
Last active Apr 29, 2020
JavaScriptの参照と浅いコピー
View destructive-assignment.js
const stateA = { foo: "bar" };
const stateB = stateA;
stateB["hoge"] = "huga"; // stateAに対する破壊的変更
console.log("stateA: ", stateA); // stateAが更新されている
// コピーしたいならこうする
const correctStateA = { foo: "bar" };
const correctStateB = { ...correctStateA }; // 浅いコピー
correctStateB["hoge"] = "huga"; // correctStateAには影響が出ない
console.log("correctStateA: ", correctStateA);
@ncaq
ncaq / mathjax-screenshot.py
Last active Apr 16, 2020
MathJaxを含むローカルのHTMLファイルをpngに変換する
View mathjax-screenshot.py
#!/usr/bin/env python3
import os
import subprocess
import sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
@ncaq
ncaq / commit-message-in-style.p6
Last active Feb 10, 2020
[Gitのコミットメッセージでめっちゃタイプミスをするのでそろそろタイプミスを検出するhooksを書きました - ncaq](https://www.ncaq.net/2020/02/10/20/37/26/)
View commit-message-in-style.p6
#!/usr/bin/env raku
my IO::Path $commit-editmsg-path = IO::Path.new(@*ARGS[0]);
my IO::Path $project-root-path;
if !$commit-editmsg-path.is-absolute {
$project-root-path = IO::Path.new((run 'git', 'rev-parse', '--show-toplevel', :out).out.slurp(:close).trim);
}
my Str $commit-msg = slurp($commit-editmsg-path.absolute($project-root-path));
my Str @prefixs = [
'Merge ',
'added: ',
@ncaq
ncaq / atena-csv-from-kitamura-to-japanpost.awk
Last active Dec 25, 2019
はがきデザインキットからカメラのキタムラ向けへの変換
View atena-csv-from-kitamura-to-japanpost.awk
BEGIN {
FS = ","
OFS = ","
print "姓1,名1,敬称1,姓2,名2,敬称2,姓3,名3,敬称3,姓4,名4,敬称4,姓5,名5,敬称5,姓6,名6,敬称6,〒番号,住所1,住所2,住所3,会社名,部署,役職,御中"
}
NR > 1 {
print $1, $2, $20, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", $7, $8 $9 $10, $11, "", $12
}
@ncaq
ncaq / Root.re
Created Sep 4, 2019
Reasonによる単純todoアプリ
View Root.re
[@react.component]
let make = () => {
let (todos, setTodos) = React.useState(() => []);
let (inputCurrent, setInputCurrent) = React.useState(() => "");
<div>
<ol>
{
List.map(todo => <li> {React.string(todo)} </li>, todos)
|> Array.of_list
|> React.array
@ncaq
ncaq / .keysnail.js
Created Sep 27, 2018
今はXULアドオン消滅でもう使えないkeysnailの最終設定ファイル
View .keysnail.js
// ========================== KeySnail Init File =========================== //
// この領域は, GUI により設定ファイルを生成した際にも引き継がれます
// 特殊キー, キーバインド定義, フック, ブラックリスト以外のコードは, この中に書くようにして下さい
// ========================================================================= //
//{{%PRESERVE%
plugins.options["hok.hint_keys"] = "htnsdcrbmwvz";
plugins.options["hok.hint_base_style"] = {
"font-family": "monospace",
@ncaq
ncaq / baseballgame.css
Created Jun 11, 2018
HTMLとCSSのみ(JavaScriptなし)で作られたしょぼい野球ゲーム.2015年05月に作成
View baseballgame.css
input {
display: none;
}
label {
display: none;
}
#pitchStart {
color: #ff4500;
background-color: #7cfc00;
width: 10vw;
View hlint-use-const-mistaken.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
import Text.Blaze.Html.Renderer.Pretty (renderHtml)
import Text.Hamlet
data MyRoute = Home
render :: Render MyRoute
render Home _ = "/home"
@ncaq
ncaq / quick_sort.cpp
Created Nov 17, 2017
クイックソート(再)
View quick_sort.cpp
#include <algorithm>
#include <cassert>
#include <iostream>
#include <random>
#include <vector>
template <class RandomAccessIterator>
void quick_sort(RandomAccessIterator begin, RandomAccessIterator end) {
// 要素数0, 1の場合
if (begin == end || begin + 1 == end) {
You can’t perform that action at this time.