Skip to content

Instantly share code, notes, and snippets.

Avatar
🐱
Setting status…

Metro Wind MetroWind

🐱
Setting status…
View GitHub Profile
View bare.log
-- Journal begins at Thu 2019-06-20 13:29:14 PDT, ends at Fri 2021-06-11 17:12:34 PDT. --
Jun 11 17:10:27 perdido systemd[1]: docker.lms.service: Deactivated successfully.
Jun 11 17:10:27 perdido systemd[1]: Stopped LMS container.
Jun 11 17:10:27 perdido systemd[1]: Starting LMS container...
Jun 11 17:10:27 perdido docker[8632]: Error: No such container: lms
Jun 11 17:10:27 perdido docker[8638]: Error: No such container: lms
Jun 11 17:10:27 perdido systemd[1]: Started LMS container.
Jun 11 17:10:29 perdido docker[8644]: ARG = lms
Jun 11 17:10:29 perdido docker[8644]: ARG = --config=/var/lms/wt_config.xml
Jun 11 17:10:29 perdido docker[8644]: ARG = --docroot=/usr/share/lms/docroot/;/music/resources,/music/css,/music/images,/music/js,/music/favicon.ico
@MetroWind
MetroWind / everything.cpp
Last active Apr 2, 2021
File system watcher for Linux. Currently it doesn’t watch for new directories, but it could be easily added.
View everything.cpp
#include <system_error>
#include <iostream>
#include <filesystem>
#include <unordered_map>
#include <array>
#include <string>
#include <unistd.h>
#include <sys/types.h>
#include <sys/inotify.h>
@MetroWind
MetroWind / conf.adoc
Last active Oct 15, 2020
配置管理系统的脑洞
View conf.adoc

配置管理系统

为嘛

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

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

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

View flask.ahk
IsEnabled := false
FlaskIdx := 2
#IfWinActive Path of Exile
`::
IsEnabled := !IsEnabled
if (IsEnabled)
{
SetTimer, TimerFlask, 1500
@MetroWind
MetroWind / nas.org
Last active Jun 27, 2020
Private cloud storage
View nas.org
@MetroWind
MetroWind / ms.adoc
Last active Jun 5, 2020
Interactive matrix processing system
View ms.adoc

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 / factorial.cc
Last active Feb 21, 2020
Calculate factorial of big number
View factorial.cc
// 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 / props_to_sort_lambda.py
Created Jan 10, 2020
A function that returns a function that sorts according to a list of keys
View props_to_sort_lambda.py
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 / circle.rs
Created Jan 8, 2020
Draw a circle with Rust
View circle.rs
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 / mw96.json
Last active Jul 26, 2020
Keymap for my XD96 build
View mw96.json
{
"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",