This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test/unit' | |
| class TwoColorBall | |
| attr_reader :content | |
| attr_reader :time_list | |
| def initialize(content) | |
| @content = content | |
| @time_list = [] | |
| end | |
| def times(find_arr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 同步静态文件到 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 压缩文件 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) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Test | |
| def initialize() | |
| end | |
| end | |
| class TestSub1 < Test | |
| def initialize(name, age) | |
| super | |
| end | |
| end | |
| class TestSub2 < Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # observer pattern | |
| module ObserverPattern | |
| def initialize | |
| @observers = [] | |
| end | |
| def add_observer(observer) | |
| @observers << observer | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # observer pattern | |
| require 'observer' | |
| class Observer | |
| include Observable | |
| attr_reader :name | |
| def initialize(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' 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)) |