Skip to content

Instantly share code, notes, and snippets.

Avatar

Kotet kotet

View GitHub Profile
@kotet
kotet / ddsk.d
Created Aug 3, 2022
ドドスコード
View ddsk.d
import std;
// enum seed = __TIME__.reduce!((a, b) => a * 9 + b);
enum seed = 8;
enum r = Mt19937(seed);
static foreach (s; generate_ddsk_sequence(r))
{
pragma(msg, s);
}
@kotet
kotet / gist:c5771b1d350116702ec02abac8afcd12
Created Feb 8, 2021
AtCoderのコンテストトップページで発動するとGoogle Calenderの予定を作って開くブックマークレット
View gist:c5771b1d350116702ec02abac8afcd12
(function(){var a=function(c){return c.getUTCFullYear()+(""+(101+c.getUTCMonth())).slice(1,3)+(""+(100+c.getUTCDate())).slice(1,3)+"T"+(""+(100+c.getUTCHours())).slice(1,3)+(""+(100+c.getUTCMinutes())).slice(1,3)+"00Z"},b=encodeURI,d=document.querySelector("#contest-nav-tabs > div > small.contest-duration"),e=b(a(new Date(d.querySelector("a:nth-child(1) > time").innerText)));a=b(a(new Date(d.querySelector("a:nth-child(2) > time").innerText)));d=b(document.title);var f=b(location.href);b=b(document.querySelector("#main-container > div.row > div:nth-child(2) > p").innerText);window.open("https://www.google.com/calendar/render?action=TEMPLATE&text="+d+"&details="+b+"&location="+f+"&dates="+e+"%2F"+a,"_blank")})();
@kotet
kotet / q.sh
Created Jan 28, 2021
コマンドキュー
View q.sh
#!/usr/bin/env bash
# https://betterdev.blog/minimal-safe-bash-script-template/
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [command]
EOF
exit
@kotet
kotet / file-select.sh
Last active Oct 20, 2020
ディレクトリをたどってファイルのパスを得るツール
View file-select.sh
#!/bin/bash
file-select() {
(
cd "${1}"
path=$(ls -a | peco)
path=$(readlink -f "${path}")
if [[ -d "${path}" ]]; then
file-select "${path}"
@kotet
kotet / zswap-stat
Created Apr 30, 2020
Zswapの情報を若干見やすく表示するやつ
View zswap-stat
#!/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 Apr 8, 2020
Folding@homeのproject descriptionを端末から見るやつ
View fahdescription.sh
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 Apr 8, 2020
端末上で Folding@home のスロットの細かい情報を見るやつ
View fahslots.sh
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 Dec 22, 2019
巡回符号わかるマン
View cyclic_code.d
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 Nov 1, 2019
線形符号
View app.d
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 Jul 19, 2019
非再帰マージソート
View merge.c
#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;