Skip to content

Instantly share code, notes, and snippets.

require 'test/unit'
class TwoColorBall
attr_reader :content
attr_reader :time_list
def initialize(content)
@content = content
@time_list = []
end
def times(find_arr)
@alvin2ye
alvin2ye / 同步静态文件到 S3
Created November 16, 2009 02:01
同步静态文件到 S3 #
# 同步静态文件到 S3
# source http://blog.eberly.org/2006/10/09/how-automate-your-backup-to-amazon-s3-using-s3sync/
wget http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz
tar xvzf s3sync.tar.gz
rm s3sync.tar.gz
mkdir certs
cd certs
wget http://mirbsd.mirsolutions.de/cvs.cgi/~checkout~/src/etc/ssl.certs.shar
sh ssl.certs.shar
@alvin2ye
alvin2ye / gist:235789
Created November 16, 2009 06:24
# 压缩文件 rubyzip
# 压缩文件 rubyzip
require 'rubygems'
gem 'rubyzip'
require 'zip/zipfilesystem'
require 'zip/zip'
Zip::ZipFile.open(file_name + ".zip", Zip::ZipFile::CREATE) { |zipfile|
zipfile.add(File.basename(file_name), file_name)
}
regsvr32 xvto.ocx
regsvr32 viewer\AutoVueX.ocx
regsvr32 viewer\AvCompareX.ocx
regsvr32 viewer\AVMrkpX.ocx
regsvr32 viewer\AvPrintX.ocx
regsvr32 viewer\csiplugin.ocx
regsvr32 viewer\smartvue.ocx
@alvin2ye
alvin2ye / vb6 运行一个今天并返回值
Created November 17, 2009 03:33
vb6 运行一个今天并返回值
Option Explicit
Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long
Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO)
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long
Private
#
# The GoF State pattern
#
# Here is Maurice Codik's implementation.
# I only added an "if __FILE__ == $0", tweaked the layout, and fixed
# a typo.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Copyright (C) 2006 Maurice Codik - [email protected]
class Test
def initialize()
end
end
class TestSub1 < Test
def initialize(name, age)
super
end
end
class TestSub2 < Test
# observer pattern
module ObserverPattern
def initialize
@observers = []
end
def add_observer(observer)
@observers << observer
end
# observer pattern
require 'observer'
class Observer
include Observable
attr_reader :name
def initialize(name)
@alvin2ye
alvin2ye / read_text_file.bas
Created November 19, 2009 06:48
vb ReadTextFile
' vb ReadTextFile
Public Function ReadTextFile(sFilePath As String) As String
On Error Resume Next
Dim handle As Integer
If LenB(Dir$(sFilePath)) > 0 Then
handle = FreeFile
Open sFilePath For Binary As #handle
ReadTextFile = Space$(LOF(handle))