Skip to content

Instantly share code, notes, and snippets.

View iwinux's full-sized avatar
👽

Limbo Peng iwinux

👽
View GitHub Profile
@iwinux
iwinux / gist:5578188
Last active October 11, 2023 19:49
Go's html/template with better subdirectory support.
package templates
import(
"html/template"
"io"
"os"
"strings"
"path/filepath"
)
@iwinux
iwinux / gist:1529093
Created December 28, 2011 18:38
config.assets.precompile
def compile_asset?(path)
# ignores any filename that begins with '_' (e.g. sass partials)
# all other css/js/sass/image files are processed
if File.basename(path) =~ /^[^_].*\.\w+$/
puts "Compiling: #{path}"
true
else
puts "Ignoring: #{path}"
false
end
@iwinux
iwinux / Caddyfile
Created May 26, 2021 04:07
A fucking simple Caddyfile that disables some default shit
{
admin off
auto_https off
}
http://localhost:8080 {
file_server
}
@iwinux
iwinux / nginx.conf
Created May 27, 2019 10:45
Docker 服务发现机制的简单实现
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 / sumup.py
Created August 23, 2014 05:29
中国联不通每月通话时间统计
#!/usr/bin/env python
# coding: utf-8
'''
中国联不通每月通话时间统计
用法:
1. 去 http://iservice.10010.com/ 下载通话详单(Excel 格式),导出为 CSV
2. ./sumup.py *.csv
'''
@iwinux
iwinux / fix-mp3-tags.py
Last active February 28, 2019 02:42
brute-force ID3 encoding fix
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'}
digraph {
思维导图 -> { OmniGraffle XMind dot };
OmniGraffle -> { 排版糟糕 单调 贵 };
XMind -> { 排版不错 主题好看 中文输入很麻烦 };
dot -> { 很强大 灵活 不适合现场演示 };
}
@iwinux
iwinux / barely-tweaks.js
Last active May 28, 2018 02:23
UI / UX Tweaks for BearyChat
// ==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 / jdk-deb-build.sh
Created June 15, 2014 10:55
build Oracle JDK deb package with fpm
#!/bin/bash
PACKAGE=oracle-jdk-7
PACKAGE_VIRTUAL=oracle-jdk
VERSION_MAJOR=7
VERSION_MINOR=60
VERSION="${VERSION_MAJOR}u${VERSION_MINOR}"
BUILD=b19
PKG_BASENAME="jdk-$VERSION-linux-x64.tar.gz"