Skip to content

Instantly share code, notes, and snippets.

@iBaozi
iBaozi / firewall.sh
Created December 10, 2013 01:03 — forked from x1a0/firewall.sh
#! /bin/bash
# Set the default policies to allow everything while we set up new rules.
# Prevents cutting yourself off when running from remote SSH.
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Flush any existing rules, leaving just the defaults
iptables -F
#coding=utf-8
__author__ = 'baozi'
import random
import time
start = time.clock()
prefix = '2'
length = 16
num = 1000000
@iBaozi
iBaozi / auto-index.css
Last active January 8, 2016 02:29
文章自动生成索引 auto generate index
.content a{ text-decoration: underline; color:#222;}
a:hover{color:#000;}
strong{color:#000;}
#post-content h1 { font-size: 20px;}
#post-content h1 { font-size: 18px;}
.bz_custom,.bz_custom_h{margin: 15px 0;padding: 8px;font-weight: bold;color: #000;}
#post-content h1,#post-content h2,#post-content h3{margin: 15px 0;padding: 8px;font-weight: bold;color: #000;}
#post-content h1,h1.bz_custom,h1.bz_custom_h{background-color: #666;}
@iBaozi
iBaozi / template.js
Last active December 7, 2015 02:16
js javascript 模板
// 模板
var floorTpl = '<div class="others" data-id="{id}">' +
'<span class="nick">{nick}</span>' +
'<span class="date">{datelineStr}</span>' +
'<div class="ctt">' +
'{content}' +
'<a href="javascript:void(0)"> [回复]</a>' +
'</div>' +
'</div>';
{"DZA": {"0": {"AAE": {"n": "\u5b89\u7eb3\u5df4"}, "BAT": {"n": "\u5df4\u7279\u7eb3"}, "ATE": {"n": "\u827e\u56e0\u00b7\u8482\u59c6\u5c1a\u7279"}, "MIL": {"n": "\u5bc6\u62c9"}, "GUE": {"n": "\u76d6\u5c14\u9a6c"}, "BEC": {"n": "\u8d1d\u6c99\u5c14"}, "BOR": {"n": "\u5e03\u5c14\u5409\u00b7\u5e03\u963f\u96f7\u91cc\u5409"}, "TIP": {"n": "\u8482\u5df4\u624e"}, "BOU": {"n": "\u5e03\u8fc8\u5fb7\u65af"}, "TIS": {"n": "\u8482\u65af\u59c6\u897f\u52d2\u7279"}, "TIN": {"n": "\u5ef7\u675c\u592b"}, "NAA": {"n": "\u7eb3\u963f\u9a6c"}, "BIS": {"n": "\u6bd4\u65af\u514b\u62c9"}, "GHA": {"n": "\u76d6\u5c14\u8fbe\u8036"}, "REL": {"n": "\u8d6b\u5229\u8d5e"}, "BOA": {"n": "\u5e03\u4f9d\u62c9"}, "ILL": {"n": "\u4f0a\u5229\u9f50"}, "SKI": {"n": "\u65af\u57fa\u514b\u8fbe"}, "TIA": {"n": "\u63d0\u4e9a\u96f7\u7279"}, "SAI": {"n": "\u8d5b\u4f0a\u8fbe"}, "SET": {"n": "\u585e\u8482\u592b"}, "TEB": {"n": "\u7279\u8d1d\u8428"}, "SAH": {"n": "\u82cf\u514b\u00b7\u963f\u8d6b\u62c9\u65af"}, "SBA": {"n": "\u897f\u8fea\u8d1d\u52d2\u963f\u8d1d\u65a
/**
* @param {number[]} nums
* @return {number}
*/
function find(nums, v) {
for (var j in nums) {
if (v == nums[j]) {
return true
}
__author__ = 'baozi'
import Image,glob,os,colorsys
img_file = '1.jpg'
img_file_new = 'douwa_new.png'
direct = 'h'
z = 1
__author__ = 'baozi'
import Image
img_file = '1.jpg'
proportion = 0.3
@iBaozi
iBaozi / ReadMe.md
Last active June 27, 2021 03:36
redis 查看指定key 占用大小。用复制,查看增量方法,注意不要用于过大的key

#步骤(How to use it)

  1. 保存脚本到(Save script as ) redis_size.lua
  2. 注册脚本 (Load script)
    redis-cli -h 192.168.1.1 -p 6371 script load "$(cat redis_size.lua)"
  3. 调用(Call it)
    evalsha 78331e1d4741cad34084d357e19ce6dbca8e202e 0 test_key // 注意与上步返回的一致
@iBaozi
iBaozi / vzfree.c
Created October 28, 2015 05:14
openvz 内存
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
struct resource_t {
char name[32];
long long held;
long long maxheld;
long long barrier;