Skip to content

Instantly share code, notes, and snippets.

@kylege
kylege / sqlsplit.go
Created April 3, 2026 07:16
Split SQL string into multiple sub-statements, based on Golang.
package sqlsplit
import (
"strings"
"unicode/utf8"
)
type SplitConfig struct {
Dialect string
StripSemicolon bool
@kylege
kylege / README.md
Last active April 3, 2026 07:12
TML: Testing Markup Language

tml 标记语言

tml 全称 Testing Markup Language,是用于存储单元测试中变量的文本文件。格式简单

结构体定义

目前仅支持以下几种字段数据类型

  • int
  • string
@kylege
kylege / image_info.py
Created November 3, 2014 03:06
Get image content_type and width、height from remote url
#coding=utf-8
import struct, StringIO
import urllib2
"""Wrap a file handle to allow seeks back to the beginning
Sometimes data coming from a socket or other input file handle isn't
what it was supposed to be. For example, suppose you are reading from
a buggy server which is supposed to return an XML stream but can also
return an unformatted error message. (This often happens because the
@kylege
kylege / expect_func.sh
Created October 10, 2014 07:54
自动化运维工具:expect功能函数
#!/bin/bash
function make_tmp_file()
{
local name=${1:-"rand"}
local magic=`date +%s`
echo "/tmp/__${magic}__${name}"
}
function make_rand_file()
@kylege
kylege / find_duplicate_img.py
Created October 8, 2014 09:26
从目录中找出与目标图片相似的图片
#encoding=utf-8
#!/usr/bin/python
import os, sys
import operator
import math
img_path = sys.argv[1]
img_dir = sys.argv[2]
dest_imgs = []
@kylege
kylege / 自动加jpg后缀.cmd
Created September 18, 2014 01:20
windows右键发送到“自动加jpg后缀.bat”重命名文件后缀为jpg
echo off
:LOOP
set index=%1
if %index%! == ! goto END
rem
echo %index%
ren %index% *.jpg
shift
@kylege
kylege / mysql_myisam2innodb.sh
Created March 13, 2014 01:35
MySQL批量将MyISAM转换为InnoDB脚本
#!/bin/bash
 
user=root
password=rootpassword
database=testdb
 
tables=$(echo "show tables" | mysql -u$user -p$password $database)
 
for table in $tables;
do
@kylege
kylege / image-shadow.sh
Created October 2, 2013 02:50
给图片加上阴影的shell脚本
#!/bin/bash
# run image-shadow myimage.png to add a shadow to the image
# or run image-shadow myimage.png 6x6 to add a shadow and 6 pixel border
image-shadow () {
out=${1%.*}-shadow.${1#*.}
in=$1
echo "Converted file : $out"
if [ ! -z $2 ] ; then
convert $in -frame $2 $out
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Monkey Patch for tornado
"""
import cProfile as profile
from tornado.options import options
from tornado.web import HTTPError