View gist:c5771b1d350116702ec02abac8afcd12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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")})(); |
View q.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
View file-select.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
file-select() { | |
( | |
cd "${1}" | |
path=$(ls -a | peco) | |
path=$(readlink -f "${path}") | |
if [[ -d "${path}" ]]; then | |
file-select "${path}" |
View zswap-stat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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): |
View fahdescription.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
View fahslots.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} |
View cyclic_code.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
View app.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
View merge.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
View tree.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
$ 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 |
NewerOlder