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 / naive-edge-offset.py
Last active December 13, 2021 07:49
Offset a loop of edges. Probably only works in the simple case where the loop is convex and the internal ordering of the vertices is "nice".
# Offset a loop of edges. Probably only works in the simple case where the loop
# is convex and the internal ordering of the vertices is "nice".
#
# Usage:
#
# 1. In edit mode, select a loop of vertices. The vertices should be roughly on
# the same plane.
# 2. Scroll to the bottom of this file, and change the offset distance in the
# offset function call. The distance can be negative.
# 3. Press "Run Script".
U2FsdGVkX19lCY21RfgdarDUXJV0P/qEiS6vue8m4cI6Jz026MbNECmACkzxafMZxyp9CKCATo7ZcIrb0kYomndSKqkHNVIXrNLqoRiiQ7/bFJIYkpx4cBurodWPx0jJbfWkk/uJs3vFNU7Ig6cdJjX0767FAhLaRiOUf/skzskR3jMmaTW1Ja9GDRSQIEoD8VO1xqaInVdOoAfvuAm2qVczGLPFvAdWTUrIyqNJuM5VPgfz8YRsY2/RAqdCidaEws1elz17ClLjNs6PIVURReysp7aABIY49hMO5G6CyU5P3B4IjJUrjCuUgr6fb0w2wW0LKI5s3hbnHbTgMCqqN6DHX4pJ1JWinm9JEDzcuPNxe7K3iZr/YqDpQhyFGbFkLHJgvyOAkkwjSn7QZrVY9md5gX0FcynAqIMm29fwAdJtPJFTchnvvqFdTl+PKLojzVYwYrDYd5toSIsJUrrd6S/3J/CBPTXxAbMkISINKrI0zGhp4zVEHSp1rR5ziYYtHHivcQIOp1GmpTt08e+g7cBwwPmIonlmHq6LpGkjERPdaZUAuptTWUiWOZub8R9+XiV4ILdCgzua1csvBpgcn/dtgv/S3OMsWp9jqdX3iKpDmpQsO9MhTGgIlTd8NsTlMgnOGb1Hxa78xkge1iqCC0M3lA8QBUmP/eCYHxoQd+BvRfE/ww5NQmr86m8A8+aQUjy0MA8/rRTm1kOs/wP8E5/xP8e7fzNdsrPjuz27lcte9mg/4em+wliNdVZDfCGuMx5I7EysyN/sfr5sU5lFbmgAMB18r+nc48HcVYkJRjfGYF6dUqpoE1e6W7nXaul53eMLrO2yYuOd+GJ/inWn6+7j4ku90s8Lw/CDZ4t/zdlB74OqO7Cz6dTlA4PmOs5SBrExLBtDK9IZpKboQWSLbtRlyrCiZHHxl1tTPvUCZm0HgODox87BxRpT/qYWrvjlF4wn/5RRW+npHnzZf+cuXi3bVofLrqeBPxJgzUsA4szkytsW7rIcr9PRSAlVSGs3
@MetroWind
MetroWind / bare.log
Created June 12, 2021 00:20
LMS play logs
-- 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 February 7, 2022 07:14
File system watcher for Linux. Currently it doesn’t watch for new directories, but it could be easily added.
#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 October 15, 2020 23:53
配置管理系统的脑洞

配置管理系统

为嘛

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

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

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

@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 / nas.org
Last active June 27, 2020 03:36
Private cloud storage
@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 / 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 / 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)