Skip to content

Instantly share code, notes, and snippets.

View private-yusuke's full-sized avatar
💤

private-yusuke

💤
View GitHub Profile
@private-yusuke
private-yusuke / natural_number.py
Created July 17, 2018 22:28
Generates a desired natural number defined by axiomatic set theory
import os, sys
n = int(input())
if n < 0:
print("invalid")
sys.exit()
A = {}
A[0] = "∅"
A[1] = "{{{}}}".format(A[0])
for i in range(2, n+1):
int main(string[] args) {
import std.net.curl, std.parallelism, std.conv, std.stdio, std.range;
auto URL = "http://nyanpass.com/add.php";
if(args.length <= 1) {
writeln("Usage: nyanpass <count>");
return 1;
}
ulong count;
try {
@private-yusuke
private-yusuke / mine.cpp
Created May 25, 2018 13:54
無くしたら困るので
/*
* このC++ソースは下記の環境での実行を確認しています。
* Linux arch-note 4.14.13-1-ARCH #1 SMP PREEMPT Wed Jan 10 11:14:50 UTC 2018 x86_64 GNU/Linux
*
* コンパイル時コマンド: g++ mine.cpp
* コンパイラ: バージョン 7.2.1 20171224 (GCC)
*
*
* Darwin MacBook-Air.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64
* コンパイル時コマンド: g++ -std=c++11 mine.cpp
@private-yusuke
private-yusuke / mkd.fish
Last active April 5, 2020 11:17
頑なに"rgcc"なのは"rg++"とタイプするのが面倒だからです。
function mkd
if not set -q argv[1]
echo "mkd: No file selected."
return 1
end
touch $argv[1]
open $argv[1]
end
rgcc() {
if [ ! -e $1 ]; then
echo "rgcc: No file selected."
return;
fi
tmpdir=$(mktemp -d -t rgcc)
tmpfilename=$RANDOM
gcc $1 -lc++ -o "$tmpdir/$tmpfilename"
if [ $? -gt 0 ]; then
return;
@private-yusuke
private-yusuke / mathdict.txt
Created May 13, 2018 06:52
Google日本語入力で使えそうな数学関連の辞書です。
_0 ₀ 名詞
_1 ₁ 名詞
_2 ₂ 名詞
_3 ₃ 名詞
_4 ₄ 名詞
_5 ₅ 名詞
_6 ₆ 名詞
_7 ₇ 名詞
_8 ₈ 名詞
_9 ₉ 名詞
@private-yusuke
private-yusuke / kotoeri_to_google.py
Created May 13, 2018 06:42
ことえりの辞書をGoogle日本語入力用に変換するPythonスクリプト
from xml.etree import ElementTree
from sys import argv, exit
import os.path
if len(argv) <= 2:
print("Too few arguments: <command> <path> <output>")
print("BE CAREFUL NOT TO OVERWRITE YOUR IMPORTANT DATA.")
print("This script writes the output even if there's already a file named <output>.")
exit(1)
@private-yusuke
private-yusuke / unionfind.d
Created May 13, 2018 05:50
Union Find木のD言語の実装
class UnionFind(T) {
T[] arr;
this(ulong n) {
arr.length = n+1;
arr[] = -1;
}
T root(T x) {
return arr[x] < 0 ? x : root(arr[x]);
}
bool same(T x, T y) {
@private-yusuke
private-yusuke / prime_check.d
Created May 6, 2018 06:02
わからん(N=55, 10n+1の形の素数列を入力すると1m14sかかった)
void main() {
auto N = ri;
auto a = readAs!(int[]);
generate_prime_list(55555);
SortedRange!(int[]) pl = prime_list.sort;
if(a.sort.uniq.array.length != a.length || a.length != N) {
"WA".writeln;
return;
}
foreach(i; a) {
@private-yusuke
private-yusuke / deepcopy.d
Last active May 13, 2018 05:52
Since there was no implementation (that I could find) for deep copy in D, I wrote this.
T[] deepcopy(T)(T[] a) {
import std.traits : isArray;
static if(isArray!T) {
T[] res;
foreach(i; a) {
res ~= deepcopy(i);
}
return res;
} else {
return a.dup;