Skip to content

Instantly share code, notes, and snippets.

@CzBiX
CzBiX / thin-provisioning-tools.sh
Last active May 11, 2019
initramfs hook to add modules/files for LVM thin/cache LV into initrd.
View thin-provisioning-tools.sh
#!/bin/sh
# see: https://bugzilla.redhat.com/show_bug.cgi?id=921235
# http://forums.debian.net/viewtopic.php?f=5&t=119644
PREREQ="lvm2"
prereqs()
{
echo "$PREREQ"
}
@CzBiX
CzBiX / sptcc.py
Last active Dec 24, 2015
查询上海公交卡的余额和消费情况。注意数据有延时!
View sptcc.py
#!/usr/bin/env python3
#
# Usage: sptcc.py 60XXXXXXXXX
import sys
import hashlib
import json
import re
import requests
View amazon_to_cn.user.js
// ==UserScript==
// @name Amazon to CN
// @namespace CzBiX
// @include http://www.amazon.com/*
// @version 2
// @grant unsafeWindow
// ==/UserScript==
var window = unsafeWindow;
var $ = window.jQuery;
@CzBiX
CzBiX / renamer.py
Last active Sep 2, 2015
batch rename files with regex
View renamer.py
#!/usr/bin/env python3
import errno
__author__ = 'czbix'
import argparse
import os
import re
import glob
@CzBiX
CzBiX / v2ex.css
Last active Apr 1, 2017
Material design for V2EX
View v2ex.css
#Bottom {
box-shadow:0 0 4px rgba(0,0,0,0.14), 0 4px 8px rgba(0,0,0,0.28);
}
#Main .box:nth-child(-2n+4):not(.transparent) {
box-shadow:0 0 6px rgba(0,0,0,.16),0 6px 12px rgba(0,0,0,.32);
}
#Search div {
@CzBiX
CzBiX / Feedback.php
Created Feb 27, 2014
Filter spam comment in Typecho, file path: /var/Widget/Feedback.php, line 82
View Feedback.php
<?php
if(!$this->user->hasLogin()) {
/** 过滤纯英文评论 */
$pattern = '/[\x{4E00}-\x{9FA5}]/u';
if (!preg_match($pattern, $comment['text'], $match)) {
throw new Typecho_Widget_Exception(_t('You should type some Chinese word (like "你好") in your comment to pass the spam-check, thanks for your patience!<br />您的评论中必须包含汉字!<p><a style="color:#FFF; border: 1px solid;text-decoration:none;padding:0px 2px" href="javascript:void(history.back())">点此返回</a></p>'));
}
/** 过滤包含日文的评论 */
$pattern = '/[\x{3040}-\x{31FF}]/u';