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 'fileutils' | |
| require 'openssl' | |
| require 'open-uri' | |
| CACERT_URI = 'https://curl.haxx.se/ca/cacert.pem' | |
| def main | |
| if force = ARGV.include?('-f') || ARGV.include?('--force') | |
| u = FileUtils::Verbose | |
| else |
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
| def parse_yaml_with_pretty_error(str) | |
| YAML.load(str) | |
| rescue Psych::SyntaxError => e | |
| range = e.line - 5..e.line + 5 | |
| str.lines[range].zip(range) {|s, n| warn "#{n + 1}: #{s}#{%_#{' ' * (e.column - 1)}^_ if n + 1 == e.line}" } | |
| raise | |
| 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
| if (document.selection.IsEmpty) { | |
| document.selection.EndOfLine(false, mePosLogical) | |
| document.selection.StartOfLine(true, mePosLogical) | |
| } | |
| var shell = new ActiveXObject('WScript.Shell') | |
| shell.CurrentDirectory = document.Path || shell.SpecialFolders("Desktop") | |
| var exec = shell.Exec('rubyw.exe -rtimeout -e "STDERR.reopen STDOUT; $0 = STDIN.gets.rstrip; print begin; Timeout.timeout(2) { eval($_ = STDIN.read) }; rescue Exception; %_#<#{$!.class}:#{$!.message}>_ end"') | |
| exec.StdIn.WriteLine(document.FullName) |
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 'yaml' | |
| # StringForest = nil | (String, StringForest)[] | |
| # String -> StringForest | |
| def parse_indented_forest(str) | |
| str = str.gsub(/^( *)([^": \n][^":\n]*)$/, '\1"\2":') | |
| handle_includes YAML.load(str) | |
| end | |
| def handle_includes(tree) |
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
| # coding: utf-8 | |
| # | |
| # tom: JSPのタグ開閉の対応チェッカ | |
| # MIT license, @snipsnipsnip | |
| # | |
| =begin | |
| JSPの文法は普通のHTMLと違ってかなりゆるい。 |
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
| @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 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
| @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 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 '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 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 '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 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 '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' |