Skip to content

Instantly share code, notes, and snippets.

View chenzx's full-sized avatar
🎯
Focusing

Chen Zhixiang chenzx

🎯
Focusing
  • Shanghai, China
View GitHub Profile
@chenzx
chenzx / wordsStat.vbs
Created January 7, 2013 09:28
VBScript to automate Word to do chinese words statistics, not very robust.
Dim objWord ' As Word.Application
Dim objDoc ' As Word.Document
Dim fso, fResult
Dim objShell
strResultFilePath = "c:/wordsStat.txt"
'On Error Goto CleanObjs: 'WScript不支持goto label语法?
On Error Resume Next
@chenzx
chenzx / img_batch_convert.rb
Created January 7, 2013 09:36
Use ImageMagicK's convert.exe to batch convert image files
def do_batch_convert(from_reldir, to_reldir)
Dir.new(from_reldir).entries.each { |subpath|
from_path = File.join(from_reldir, subpath)
to_path = File.join(to_reldir, subpath)
if File.file?(from_path) and /\.(jpg|png)$/.match(from_path.downcase) then
if not File.exist?(to_reldir) then
Dir.mkdir(to_reldir)
end
puts "convert from #{from_path} to #{to_path}"
@chenzx
chenzx / img_batch_convert.py
Created January 7, 2013 09:37
Use ImageMagicK's convert.exe to batch convert image files
#!/usr/bin/env python
# encoding: utf-8
#
import os
import os.path
import sys
import time
def do_convert(from_path, to_dir, to_filename):
to_path = os.path.join(to_dir, to_filename)
@chenzx
chenzx / batch_rename.rb
Created January 7, 2013 09:39
Batch rename files
# Recursive scan a dir, & perform each-file rename operation:
def batch_files_from_dir(basepath)
sub_dirs = Array.new
Dir.new(basepath).entries.each { |subpath|
path = File.join(basepath, subpath)
if File.file?(path) then
if /0000[0-9]{3}$/.match(path) then
puts "#{path}"
new_path = path.gsub(/0000[0-9]{3}$/, '')
@chenzx
chenzx / rgba_blend.rb
Created January 7, 2013 09:41
A script to do alpha-Blending of 2 RGBA values
def comp(_A, _R, _G, _B)
_A<<24 | _R<<16 | _G<<8 | _B;
end
def decomp( num )
_A = (num >> 24) & 0xFF;
_R = (num >> 16) & 0xFF;
_G = (num >> 8) & 0xFF;
_B = (num >> 0) & 0xFF;
[_A,_R,_G,_B]
<body>
<style>
#c{
position: absolute;
left: 1200px;
top: 100px;
width: 80px;
height: 25px;
color: blue;
border: 2px solid red;
#!/usr/bin/python
# -*- coding: GBK -*-
#-----------------------------------------------------------
#TCP 数据服务器,当客户端连接上时,不断写入数据
# 用于测试TCP连接吞吐量
import os,sys,time
from socket import socket, AF_INET, AF_INET6, SOCK_STREAM
#-----------------------------------------------------------
#常量定义:
PROGRAM = 'TCP Data Server'
@chenzx
chenzx / vcproj2SConstruct.rb
Last active December 13, 2015 23:29
A simple ruby script to convert vcproj to SConstruct
require 'pathname'
require 'rexml/document'
include REXML
BUILD_CONFIG = 'Debug' # to switch between different config;
vcproj_filename = ARGV.shift
vcproj_filename = Pathname.new(vcproj_filename).cleanpath
vcproj_libname = vcproj_filename.sub(/\.vcproj/, '')
#!/usr/bin/env ruby
# encoding: utf-8
#
#Usage: ruby findCppFilePathCaseConflicts.rb <hFilePathLists.txt> <sourceFilePathLists.txt>
#首先,加载全部.h头文件的清单:
hFilePaths = []
File.open(ARGV[0]).each { |line|
hFilePaths.push(line)
}
#!/usr/bin/env ruby
# encoding: utf-8
#
#Usage: ruby findAndCorrectFilePathCaseConflicts.rb <hFilePathLists.txt> <sourceFilePathLists.txt>
#首先,加载全部.h头文件的清单:
hFilePaths = []
File.open(ARGV[0]).each { |line|
hFilePaths.push(line)
}