Skip to content

Instantly share code, notes, and snippets.

View kotet's full-sized avatar

Kotet kotet

View GitHub Profile
@kotet
kotet / zswap-stat
Created April 30, 2020 09:34
Zswapの情報を若干見やすく表示するやつ
#!/usr/bin/python3
import os
if os.getuid() != 0:
print("error: you cannot perform this operation unless you are root.")
exit(1)
def read(path):
@kotet
kotet / fahdescription.sh
Created April 8, 2020 12:31
Folding@homeのproject descriptionを端末から見るやつ
fahdescription() {
curl -s -G https://api.foldingathome.org/project/$1 | jq -r .cause
echo
html2text --ignore-links <(curl -s -G https://api.foldingathome.org/project/$1 | jq -r .mdescription)
}
@kotet
kotet / fahslots.sh
Created April 8, 2020 12:13
端末上で Folding@home のスロットの細かい情報を見るやつ
fahslots() {
local FAH_SID=`curl -s http://localhost:7396/js/main.js | head -n1 | awk -F\' '{print $2}'`
watch -t curl -s "http://localhost:7396/api/slots?sid=$FAH_SID"
}
@kotet
kotet / cyclic_code.d
Last active December 22, 2019 10:48
巡回符号わかるマン
import std;
void main(string[] args)
{
if (args.length < 3)
{
writeln("Usage: rdmd cyclic_code.d <符号長> <生成多項式>");
writeln("example: rdmd cyclic_code.d 7 1011");
return;
}
@kotet
kotet / app.d
Created November 1, 2019 07:02
線形符号
import std.stdio : writefln, writef;
import std.format : format;
import std.conv : to;
void main(string[] args)
{
long L = args[1].to!long();
auto fmt = format!"%%0%db"(L);
outer: foreach (c_bitmask; 1 .. (1 << (1 << L)))
@kotet
kotet / merge.c
Created July 19, 2019 06:35
非再帰マージソート
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
typedef struct stack_element
{
int64_t *ptr;
size_t length;
int8_t state;
@kotet
kotet / tree.d
Last active May 30, 2019 10:28
半永続(partially persistent)2分探索木 https://www.youtube.com/watch?v=T0yzrZL1py0
/*
$ rdmd tree.d
insert/print [i,p]: i
value: 2
2 inserted. current version: 1
insert/print [i,p]: i
value: 6
6 inserted. current version: 2
insert/print [i,p]: i
value: 3
@kotet
kotet / test.bf
Created January 5, 2019 04:43
Stack and Heap in Brainfuck
stack and heap in brainfuck
result: 7 5 0 3 1 7
b1 == 5
b2 == 7
stack == [3 7]
>> allocate 2
>+++ push 3
push 5
>+
@kotet
kotet / skskprime1.d
Created December 9, 2018 10:33
シクシク素数列 Advent Calendar 2018
#!/usr/bin/rdmd
// 自然数を返す無限レンジ。
// map等の関数を使うためにはinputrangeである必要があり、
// inputrangeの条件を満たすためには
// front,popFront,emptyという3つの関数を実装する必要がある
struct NaturalNumber
{
long n = 1;
@kotet
kotet / main.js
Created November 20, 2018 05:30
論理式を変形するやつ
"use strict";
let variable_names = [];
function tokenize(s) {
function isNextToken(s, i, t) {
for (let j = 0; j < t.length; j++) {
if (s.substr(i, t[j].length) == t[j]) {
return j;