Skip to content

Instantly share code, notes, and snippets.

require 'webrick'
require 'webrick/httpproxy'
require 'optparse'
require 'fileutils'
opts = {
port: 8080,
outdir: '.',
}
optparse = OptionParser.new("USAGE: #{$0} [OPTIONS]", 20)
@macks
macks / gist:29836d78bd61bd91191e
Created April 28, 2015 06:07
Selenium::WebDrvier::Chrome
@download_dir = File.join(Dir.pwd, 'download')
FileUtils.mkdir_p(@download_dir)
prefs = {
download: {
prompt_for_download: false,
default_directory: @download_dir,
}
}
Selenium::WebDriver::Chrome.driver_path = File.join(Dir.pwd, 'chromedriver')
diff -ruN bind-9.9.7-P1/lib/dns/tkey.c bind-9.9.7-P2/lib/dns/tkey.c
--- bind-9.9.7-P1/lib/dns/tkey.c 2015-06-18 07:48:03.000000000 +0900
+++ bind-9.9.7-P2/lib/dns/tkey.c 2015-07-15 08:50:22.000000000 +0900
@@ -650,6 +650,7 @@
* Try the answer section, since that's where Win2000
* puts it.
*/
+ name = NULL;
if (dns_message_findname(msg, DNS_SECTION_ANSWER, qname,
dns_rdatatype_tkey, 0, &name,
@macks
macks / gist:9951996989add729e839
Last active August 29, 2015 14:27
Tiarra IRC Proxy: Avoid warnings for Slack IRC gateway
--- a/main/IrcIO/Server.pm
+++ b/main/IrcIO/Server.pm
@@ -829,6 +829,9 @@ sub _MODE {
};
for (;$mode_char_pos < $n_params;$mode_char_pos += $mode_param_offset + 1) {
+ if (substr($msg->param($mode_char_pos), 0, 1) eq ' ') {
+ next;
+ }
$mode_param_offset = 0; # これは毎回リセットする。
@macks
macks / gist:eff94050f89d622a2382
Created March 25, 2016 20:10
letsencrypt sample
$ sudo letsencrypt certonly --staging --verbose --email [email protected] -d example.com -w /home/www/example.com/htdocs
@macks
macks / gacha.rb
Last active December 27, 2016 15:25
ガチャで複数の当たりを引く確率
def combination(n, r)
factorial(n) / factorial(r) / factorial(n - r)
end
def permutation(n, r)
factorial(n) / factorial(n - r)
end
$factorial = { 0 => 1 }
@macks
macks / cedec2017-session-scraper.rb
Created August 25, 2017 08:23
CEDEC 2017 のセッション情報を取得する
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'json'
sessions = []
%w(
http://cedec.cesa.or.jp/2017/session/schedule_0830/