Skip to content

Instantly share code, notes, and snippets.

@wangye
wangye / ComputeAge.vbs
Created February 26, 2012 12:04
Compute Age in many ways
Option Explicit
' ***************************************************
' *
' * Description: 计算年龄
' * Author: wangye <pcn88 at hotmail dot com>
' * Website: http://wangye.org
' *
' * Paramters:
' * ByVal datetime 出生日期或者要比较的日期1
@wangye
wangye / GetOpenFileName.vbs
Created February 28, 2012 14:53
Compatible with most Windows platforms, VBScript/VBS open file dialog
'
' Description: VBScript/VBS open file dialog
' Compatible with most Windows platforms
' Author: wangye <pcn88 at hotmail dot com>
' Website: http://wangye.org
'
' dir is the initial directory; if no directory is
' specified "Desktop" is used.
' filter is the file type filter; format "File type description|*.ext"
'
@wangye
wangye / msoWord_SplitPages.vbs
Created March 2, 2012 07:22
VBScript/VBS/VBA split single word document to multi-documents by pages
'
' Description: VBScript/VBS/VBA
' split single word document
' to multi-documents by pages
' Author: wangye <pcn88 at hotmail dot com>
' Website: http://wangye.org
' Copyright by author
'
Const PrevPage = 0
Const NextPage = 1
@wangye
wangye / backup-example.sh
Created March 5, 2012 04:53
Bash shell for backup WordPress and MySQL database
#!/bin/bash
# Author: wangye
# For more information please visit:
# http://wangye.org/
# 请在使用本脚本前做好测试工作,脚本功能仅供参考,
# 对于可能的潜在问题造成损失,本人不承担责任。
MYSQL_USERNAME="mysql-username"
MYSQL_PASSWORD="mysql-password"
@wangye
wangye / b24.c
Created March 7, 2012 02:29
Base24 encode and decode
/*
Author: wangye
http://wangye.org/
*/
static const char sel[] = {
'B','C','D','F','G',
'H','J','K','M','P',
'Q','R','T','V','W',
'X','Y','2','3','4',
'6','7','8','9', '\0'};
@wangye
wangye / Base24.cs
Created March 7, 2012 02:31
Base24 encode and decode C#
//
// Description: Base24 encode and decode
// Author: wangye <pcn88 at hotmail dot com>
// Website: http://wangye.org
//
public static class Base24
{
private static string sel = "BCDFGHJKMPQRTVWXY2346789";
public static string Encode(string Text)
@wangye
wangye / CBase64.vbs
Created March 7, 2012 02:34
VBScript Base64 encode and decode
'
' Description: Base64 encode and decode
' Author: wangye <pcn88 at hotmail dot com>
' Website: http://wangye.org
'
Class CBase64
Private objXmlDom
Private objXmlNode
' GetObjectParam() 这个函数实现参考了开源项目PJBlog
@wangye
wangye / B64HEX.vbs
Created March 7, 2012 02:36
Base64 to Hex or Hex to Base64 encode and decode
' Base64 to Hex or Hex to Base64 encode and decode
' Website: http://wangye.org
' Base64转16进制
Function B64ToHex(ByVal strContent)
Dim i,strReturned, b64pad, _
b64map, chTemp, intLocate, k , slop
strReturned = "" : k = 0
b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZ" &_
"abcdefghijklmnopqrstuvwxyz0123456789+/"
b64pad="="
@wangye
wangye / ReflectionHash.cs
Created March 7, 2012 02:38
C# Reflection MD5/SHA1 Hash
//
// Description: C# Reflection MD5/SHA1 Hash
// Author: wangye <pcn88 at hotmail dot com>
// Website: http://wangye.org
// For more information please visit:
// http://wangye.org/blog/archives/134/
//
using System;
using System.Text;
using System.Security.Cryptography;
@wangye
wangye / CheckFileName.vbs
Created March 7, 2012 02:41
VBScript Check File Name
' Check File Name
Function IsAcceptableFileName(fileName)
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = False
objRegExp.Pattern = _
"^(?!^(PRN|AUX|CLOCK\$|CONFIG\$|" & _
"NUL|CON|COM\d|LPT\d|\..*)" & _
"(\..+)?$)[^\x00-\x1f\\?*:\"";|/]+$"
IsAcceptableFileName = objRegExp.Test(fileName)