Skip to content

Instantly share code, notes, and snippets.

weakest(X, [X]).
weakest(X, [_ | Ys]) :-
weakest(X, Ys).
strongest(X, [X | _]).
% X が Y より弱い
weaker(X, Y, [Y | Ys]) :-
member(X, Ys).
@yoh2
yoh2 / sample.template
Created August 18, 2016 17:31
AWS ES2 インスタンスと Route 53 のプライベートホストゾーンを作成し、割り当てられたローカルアドレスの名前解決ができるようにするサンプル。ルーティングやセキュリティ周リgdgdで動かないので注意。
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"zonesampleinternal": {
"Type": "AWS::Route53::HostedZone",
"Properties": {
"Name": {
"Fn::Join": [
"",
[
@yoh2
yoh2 / uim-1.7.3-usr-share-skk-dvorakjp.patch
Created August 2, 2016 16:24
uim SKK に DvorakJP を追加する私的パッチ。EUC-JPに変換して使うこと。
diff -urN uim.orig/japanese-dvorakjp.scm uim/japanese-dvorakjp.scm
--- uim.orig/japanese-dvorakjp.scm 1970-01-01 09:00:00.000000000 +0900
+++ uim/japanese-dvorakjp.scm 2012-05-24 22:34:43.260281019 +0900
@@ -0,0 +1,399 @@
+(define ja-dvorakjp-rule-basic
+ '(
+ ((("c" "a"). ())("か" "カ" "カ"))
+ ((("c" "i"). ())("き" "キ" "キ"))
+ ((("c" "u"). ())("く" "ク" "ク"))
+ ((("c" "e"). ())("け" "ケ" "ケ"))
# traceroute 192.30.252.122
traceroute to 192.30.252.122 (192.30.252.122), 30 hops max, 60 byte packets
1 v157-7-204-2.z1d5.static.cnode.jp (157.7.204.2) 1.341 ms 1.306 ms 1.250 ms
2 157.7.42.33 (157.7.42.33) 5.847 ms 5.830 ms 5.783 ms
3 unused-133-130-013-017.interq.or.jp (133.130.13.17) 2.065 ms 2.025 ms 1.950 ms
4 133.130.12.42 (133.130.12.42) 2.478 ms 133.130.12.33 (133.130.12.33) 1.909 ms 133.130.12.42 (133.130.12.42) 2.429 ms
5 ae-25.r00.tokyjp05.jp.bb.gin.ntt.net (61.120.146.181) 2.406 ms xe-0-0-0-5.r00.tokyjp01.jp.bb.gin.ntt.net (61.120.146.77) 2.480 ms ae-25.r00.tokyjp05.jp.bb.gin.ntt.net (61.120.146.181) 2.305 ms
6 ae-8.r31.tokyjp05.jp.bb.gin.ntt.net (129.250.3.190) 2.209 ms ae-6.r31.tokyjp05.jp.bb.gin.ntt.net (129.250.7.86) 1.848 ms 1.821 ms
7 ae-4.r23.lsanca07.us.bb.gin.ntt.net (129.250.3.193) 109.785 ms 110.428 ms 110.297 ms
8 ae-6.r22.asbnva02.us.bb.gin.ntt.net (129.250.3.188) 177.816 ms 177.761 ms 178.234 ms
@yoh2
yoh2 / japanese-dvorakjp.scm
Last active April 8, 2020 01:59
uim-skk と DvorakJP を組み合わせて使う ref: http://qiita.com/yoh2/items/66d70e33e47d6fb68d2f
(define ja-dvorakjp-rule-basic
'(
((("c" "a"). ())("か" "カ" "カ"))
((("c" "i"). ())("き" "キ" "キ"))
((("c" "u"). ())("く" "ク" "ク"))
((("c" "e"). ())("け" "ケ" "ケ"))
((("c" "o"). ())("こ" "コ" "コ"))
((("c" "y"). ("y" "k"))("" "" ""))
((("c" "n"). ("y" "k"))("" "" ""))
@yoh2
yoh2 / file1.txt
Last active January 22, 2016 19:48
-pthread を忘れると std::thread で例外が発生する仕組み ref: http://qiita.com/yoh2/items/97821d3d1dbe3e024d4f
$ g++ -Wall -std=c++11 sample.cpp -o sample1 # ← sample1 は -pthread 付けない
$ g++ -Wall -std=c++11 -pthread sample.cpp -o sample2 # ← sample2 は -pthread 付ける
$ ./sample1
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
中止
$ ./sample2
Hello!
@yoh2
yoh2 / 40_custom
Created November 8, 2015 08:49
UEFIから起動するWindowを起動するためのGRUB2設定。root=(...)はEFI用パーティションを指定。
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows" --class windows --class os {
set root=(hd0,2)
chainloader '/EFI/Microsoft/Boot/bootmgfw.efi'
}
@yoh2
yoh2 / nyancat
Created October 6, 2015 17:01
xinetd config file for nyancat
service telnet
{
socket_type = stream
protocol = tcp
wait = no
user = games
server = /usr/games/bin/nyancat
server_args = -t
only_from = 0.0.0.0/0 ::/0
flags = IPv6
@yoh2
yoh2 / takahashi_num_1_18.c
Last active August 29, 2015 14:19
1〜18桁の高橋の数 (http://masami.d2.r-cms.jp/blog_detail/blog_id=3&id=6) を求める。力技の割には意外と速い。
// 1桁〜18桁までの高橋の数を求める。
// 高橋の数 : http://masami.d2.r-cms.jp/blog_detail/blog_id=3&id=6
#include <stdio.h>
#include <stdbool.h>
// 高橋の数を格納する型。
typedef long long num_t;
#define PRId_num_t "lld"
// 自然数から各桁を構成する数字を数える。
@yoh2
yoh2 / bf.hs
Created December 13, 2013 19:02
でもってHaskellでBF。先日のbf.plより速くなると思う……がその分やや長い。
import System.IO
import System.Environment
import Data.Word
import qualified Data.ByteString as B
-- Utilities
applyFst :: (a -> c) -> (a, b) -> (c, b)
applyFst f (x, y) = (f x, y)