This file contains 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
@ruby^ | |
-Ebinary:binary^ | |
-e "args = STDIN.readlines.map(&:strip)"^ | |
-e "abort 'empty args' if args.empty?"^ | |
-e "cmd = ARGV.empty? ? ['type'] : ARGV"^ | |
-e "ai = cmd.any? {|c| c.include?('{}') }"^ | |
-e "cmds = ai ? args.map {|a| cmd.map {|z| z.gsub(/\{\}/, a).gsub(/@@/, '{}') } } : [cmd + args]"^ | |
-e "cmds.each {|c| warn 'backtick: ' + c.join(' '); system(*c) || exit($?.to_i) }"^ | |
-- %* |
This file contains 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
@ruby -x "%~f0" %* & exit /b | |
#!ruby | |
pid = Integer(ARGV[0]).to_s | |
while `tasklist.exe /FI "PID eq #{pid}"`.include?(pid) | |
sleep 1 | |
end |
This file contains 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 'digest' | |
class IOHasher | |
def initialize(digest=Digest::MD5.new, buf='\0' * 4096) | |
@digest = digest | |
@buf = buf | |
@chunk_size = buf.size | |
end | |
def hash_of(io) |
This file contains 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 'benchmark' | |
require 'digest' | |
require 'openssl' | |
lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.' * 1000 | |
n = 10000 | |
Benchmark.bmbm do |b| | |
b.report('digest') { n.times { Digest::SHA1.digest(lorem) } } | |
b.report('openssl') { n.times { OpenSSL::Digest::SHA1.new.digest(lorem) } } |
This file contains 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 'socket' | |
require 'openssl' | |
abort "usage: #$0 userid password {'*'|''|subdomain} example.com" if ARGV.size != 4 | |
UserID, Password, Subdomain, Domain = ARGV | |
OnamaePubkey = '224ad8a1d3af62ad5638091d485d7d9bf400e5d106ed0d5bdb1d96bb0ee6d2a5' | |
DDNSServer = 'ddnsclient.onamae.com' |
This file contains 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 'strscan' | |
=begin | |
http://parametron.blogspot.jp/search/label/Christopher%20Strachey%E3%81%AEGPM | |
program = token* | |
token = argexpansion | macrocall | literal | constant | |
literal = [^$;<>,]+ | |
argexpansion = ~ \d+ |
This file contains 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
// | |
// 引数で渡された Windows 実行形式ファイルの Machine タイプを判別する | |
// http://dsas.blog.klab.org/archives/51752824.html | |
// | |
#if !defined(UNICODE) | |
#define UNICODE | |
#define _UNICODE | |
#endif | |
#include <windows.h> |
This file contains 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 Node | |
attr_accessor :value, :left, :right | |
def initialize(val) | |
@value = val # ノードが保持する値 | |
@left = nil # 左側のノード | |
@right = nil # 右側のノード | |
end | |
end | |
# 描画に必要な情報を計算 |
This file contains 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
@echo %~s1 |
This file contains 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
@if "%PROCESSOR_ARCHITECTURE%%PROCESSOR_ARCHITEW6432%" EQU "x86" ( | |
@echo truly x86 | |
) else ( | |
@echo x64 | |
) |