Skip to content

Instantly share code, notes, and snippets.

View MetroWind's full-sized avatar
🐱
Setting status…

Metro Wind MetroWind

🐱
Setting status…
View GitHub Profile
@MetroWind
MetroWind / list-games.py
Created September 30, 2019 22:03
Scrap the game list JSON from Steam profile page.
#!/usr/bin/env python3
import sys, os
import json
import time
from tqdm import tqdm
import requests
import lxml.html
@MetroWind
MetroWind / cover.asy
Created November 4, 2019 04:08
Cover for statistical mechanics
unitsize(2mm);
srand(101);
real Width = 100.0;
real Height = 133.04;
real ColorOffset = 0.3;
path BBox = (0,0)--(Width, 0)--(Width, Height)--(0, Height)--cycle;
path BAR = scale(0.1*Width, 0.7*Width) * shift(-0.5, -0.5) * unitsquare;
@MetroWind
MetroWind / mw96.json
Last active July 26, 2020 23:05
Keymap for my XD96 build
{
"version": 1,
"notes": "My awesome keymap",
"documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
"keyboard": "xd96",
"keymap": "mw96",
"layout": "LAYOUT_96_ansi",
"layers": [
[
"KC_ESC",
@MetroWind
MetroWind / circle.rs
Created January 8, 2020 03:23
Draw a circle with Rust
extern crate sdl2;
use std::path::Path;
use std::time::Duration;
use sdl2::render::Canvas;
use sdl2::video::Window;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::{Point, Rect};
@MetroWind
MetroWind / props_to_sort_lambda.py
Created January 10, 2020 02:54
A function that returns a function that sorts according to a list of keys
def props_to_sort_lambda(*props):
"""Return a function that sorts according to property list `props`.
The sort is supposed to apply on a list of dictionaries with the same set of
keys. Argument `props` is a list of keys for the dicts.
Example:
xs = [{"aaa": 1, "bbb": 2, ...}, {"aaa": 2, "bbb": 3, ...}, ...]
sorted_xs = props_to_sort_lambda("-aaa", "bbb")(xs)
@MetroWind
MetroWind / factorial.cc
Last active February 21, 2020 19:20
Calculate factorial of big number
// Compile:
//
// - Linux: g++ -O2 -pthread factorial.cc
// - Mac: clang++ -O2 -std=c++11 factorial.cc
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <sstream>
@MetroWind
MetroWind / ms.adoc
Last active June 5, 2020 22:35
Interactive matrix processing system

Interactive matrix processing system

The goal of this project is to construct a functional interactive matrix processing system with confidence, using test-driven methodology.

Preparation

Get familiar with unit testing

@MetroWind
MetroWind / nas.org
Last active June 27, 2020 03:36
Private cloud storage
@MetroWind
MetroWind / flask.ahk
Created August 16, 2020 06:46
PoE auto flask
IsEnabled := false
FlaskIdx := 2
#IfWinActive Path of Exile
`::
IsEnabled := !IsEnabled
if (IsEnabled)
{
SetTimer, TimerFlask, 1500
@MetroWind
MetroWind / conf.adoc
Last active October 15, 2020 23:53
配置管理系统的脑洞

配置管理系统

为嘛

我有四台常用的电脑:工作用 Mac,工作用大便,私用 Mac,私用 Gentoo,这四台电脑的主要配置都差不多,只在少数地方不同。

以 Git 为例,这四台电脑上都有相同的 ~/.gitignore,相同的 ~/.gitconfig。不同之处是有一台电脑上设置了默认开启 gpg-sign,另外几台电脑上设置好了 GPG,但是 Git 不默认添加签名。

另一个例子是 Xmonad/Xorg,显然在两台 Mac 上是没有 Xmonad 的,这时原则上上不需要安装配置(但是配置了也无所谓)。在大便上,进入图形界面的时候会调用 ~/.xinitrc,里面有我的输入法设置和壁纸设置,而在 Gentoo 上,这些设置在 ~/.xprofile 里。