Skip to content

Instantly share code, notes, and snippets.

@iwinux
iwinux / nginx.conf
Created May 27, 2019
Docker 服务发现机制的简单实现
View nginx.conf
upstream default {
server 127.0.0.1:12345;
balancer_by_lua_block {
local balancer = require "ngx.balancer"
local ok, err = balancer.set_current_peer(
ngx.ctx.upstream_host or '127.0.0.1',
ngx.ctx.upstream_port or 12345
)
@iwinux
iwinux / fix-mp3-tags.py
Last active Feb 28, 2019
brute-force ID3 encoding fix
View fix-mp3-tags.py
from argparse import ArgumentParser
from os import path, walk
from typing import Iterable
import sys
from chardet import detect
from mutagen.id3 import Encoding, ID3, TextFrame
TARGET_FIELDS = {'TALB', 'TCOM', 'TIT2', 'TPE1', 'TPE2'}
@iwinux
iwinux / barely-tweaks.js
Last active May 28, 2018
UI / UX Tweaks for BearyChat
View barely-tweaks.js
// ==UserScript==
// @name barely-tweaks
// @namespace http://tampermonkey.net/
// @version 0.6
// @description UI / UX Tweaks for BearyChat
// @author E.T
// @match https://*.bearychat.com/*
// ==/UserScript==
/* global document, fetch */
@iwinux
iwinux / pick-works.js
Last active Mar 19, 2016
选择困难症患者专用的 Chrome 脚本,在豆瓣阅读征文大赛作品列表里随机挑一本作品
View pick-works.js
// ==UserScript==
// @name pick-works
// @namespace http://tampermonkey.net/
// @version 0.1
// @author E.T
// @match https://read.douban.com/competition/2015/works*
// @grant none
// ==/UserScript==
;(function () {
View CSS line behind title text.markdown
@iwinux
iwinux / a-warning.md
Created Mar 1, 2016 — forked from spion/a-warning.md
C++ versus V8 versus luajit versus C benchmark - (hash) tables
View a-warning.md

Warning

This benchmark has been misleading for a while. It was originally made to demonstrate how JIT compilers can do all sorts of crazy stuff to your code - especially LuaJIT - and was meant to be a starting point of discussion about what exactly LuaJIT does and how.

As a result, its not indicative of what its performance may be on more realistic data. Differences can be expected because

  1. the text will not consist of hard-coded constants
View lsi.sh
#!/bin/bash
#
# Calomel.org
# https://calomel.org/megacli_lsi_commands.html
# LSI MegaRaid CLI
# lsi.sh @ Version 0.05
#
# description: MegaCLI script to configure and monitor LSI raid cards.
# Full path to the MegaRaid CLI binary
@iwinux
iwinux / backend.conf
Last active Oct 13, 2015 — forked from caquino/backend.conf
invalidate Nginx cache via ngx-lua
View backend.conf
server {
listen 80;
server_name backend;
root /usr/share/nginx/www;
index index.html index.html;
location / {
header_filter_by_lua '
@iwinux
iwinux / mjolnir.lua
Last active Aug 29, 2015
window centering
View mjolnir.lua
local window = require "mjolnir.window"
local hotkey = require "mjolnir.hotkey"
local desiredWidth = 1024
local desiredHeight = 768
hotkey.bind({"cmd", "shift"}, "m", function()
local win = window.focusedwindow()
local screenBounds = win:screen():frame()
local destX = (screenBounds.w - desiredWidth) / 2 + screenBounds.x
@iwinux
iwinux / gist:ef756e22e288595eed6d
Last active Aug 29, 2015
mtr --report douban.com
View gist:ef756e22e288595eed6d
$ mtr -u --report douban.com
HOST: zerus Loss% Snt Last Avg Best Wrst StDev
1.|-- 115.182.xx.x 0.0% 10 0.3 0.3 0.3 0.3 0.0
2.|-- 60.195.255.109 0.0% 10 0.6 0.6 0.6 0.8 0.1
3.|-- 219.239.92.10 30.0% 10 49.4 37.8 2.2 63.4 22.2
4.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
5.|-- 10.244.1.25 90.0% 10 16.7 16.7 16.7 16.7 0.0
6.|-- ms-a-02-vlan10.dxt-idc.ne 70.0% 10 11.1 6.9 1.9 11.1 4.7
7.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0