Skip to content

Instantly share code, notes, and snippets.

View ncaq's full-sized avatar
🏠
Working from home

ncaq

🏠
Working from home
View GitHub Profile
@ncaq
ncaq / commit-message-in-style.p6
Last active February 10, 2020 16:54
[Gitのコミットメッセージでめっちゃタイプミスをするのでそろそろタイプミスを検出するhooksを書きました - ncaq](https://www.ncaq.net/2020/02/10/20/37/26/)
#!/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 December 25, 2019 06:39
はがきデザインキットからカメラのキタムラ向けへの変換
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 September 4, 2019 03:13
Reasonによる単純todoアプリ
[@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 September 27, 2018 06:26
今はXULアドオン消滅でもう使えないkeysnailの最終設定ファイル
// ========================== 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 June 11, 2018 14:26
HTMLとCSSのみ(JavaScriptなし)で作られたしょぼい野球ゲーム.2015年05月に作成
input {
display: none;
}
label {
display: none;
}
#pitchStart {
color: #ff4500;
background-color: #7cfc00;
width: 10vw;
{-# 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 November 17, 2017 10:05
クイックソート(再)
#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) {
@ncaq
ncaq / fizzbuzz_buffer.rs
Created October 3, 2017 10:02
[FizzBuzz を無駄にベンチマークしてみた By Nim、golang、Rust、Crystal、その他 - 強まっていこう]: http://wolfbash.hateblo.jp/entry/2017/07/25/232027 を見て高速化させてみました
fn main() {
let mut s = String::new();
for i in 1..600000 {
if i % 3 == 0 && i % 5 == 0 {
s += "FizzBuzz\n";
} else if i % 3 == 0 {
s += "Fizz\n";
} else if i % 5 == 0 {
s += "Buzz\n";
} else {
@ncaq
ncaq / OverloadedRecordFieldsExample.hs
Created September 11, 2017 11:19
OverloadedRecordFieldsのサンプル
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE TypeFamilies #-}
module OverloadedRecordFieldsExample where
@ncaq
ncaq / PropForm.hs
Created August 19, 2017 14:59
途中まで書いた論理式処理系
import Control.Monad.Trans.Reader
import qualified Data.Map as M
import Data.Maybe
import Text.ParserCombinators.Parsec
data PropForm = PropFormSymbol String | PropNot PropForm | PropFormImplies PropForm PropForm
deriving (Show, Read)
readPropForm :: String -> Either ParseError PropForm
readPropForm = parse parsePropForm "propForm"