Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
snipsnipsnip / perm.rb
Last active September 4, 2019 11:20
perm.rb: explodes ARGV as a TSV (permutate 'foo bar baz' 'quu qux' yields 6 lines)
# frozen_string_literal: true
# permutate.rb: MIT license. @snipsnipsnip
require 'csv'
require 'optparse'
require 'shellwords'
def main(argv=ARGV)
filter = nil
rest = nil
need_header = false
@snipsnipsnip
snipsnipsnip / SomeMFCControl.cs
Last active May 19, 2018 10:51
MFCの部品をWindows.Forms.Formに埋め込む ref: https://qiita.com/snipsnipsnip/items/19045907ae96121e8310
public class GuestControl : Control
{
/// <summary>アタッチしたMFCのCWnd</summary>
private IntPtr CWnd { get; }
[DllImport("attach")]
private static extern IntPtr attach(IntPtr hwnd);
[DllImport("attach")]
private static extern void detach(IntPtr hwnd);
@snipsnipsnip
snipsnipsnip / file5.txt
Last active May 14, 2020 10:34
git rebase --interactive でコミットの見分けがつかない問題の対策 ref: https://qiita.com/snipsnipsnip/items/8e4244b4fff2a5a2bc32
$ git reset --hard E # git reset --hard origin/devel でも可
$ git cherry-pick -n D A
$ git commit -m "DとA"
$ git cherry-pick B
$ git cherry-pick C
@snipsnipsnip
snipsnipsnip / file0.txt
Created December 14, 2017 14:50
「クラスを抽出」というリファクタリングがあるとしたらどういうものだろうか ref: https://qiita.com/snipsnipsnip/items/3a8d018d683d2c54ea15
interface R {
$(D1)
$(V1)
}
@snipsnipsnip
snipsnipsnip / 設定
Created June 8, 2017 13:13
htpasswd/htdigestファイルのままJenkinsのBasic認証をやめる ref: http://qiita.com/snipsnipsnip/items/6ee0d8cf8219fad2e696
/usr/bin/ruby -rwebrick/httpauth/htdigest -e 'D = WEBrick::HTTPAuth::Htdigest.new(ARGV[0]); D.get_passwd(ARGV[1], ENV["U"], false) == D.make_passwd(ARGV[1], ENV["U"], ENV["P"]) or abort' /var/www/.htdigest realm
@snipsnipsnip
snipsnipsnip / pdf2png.rb
Last active March 5, 2017 11:52
pdf2png: runs 'mutool extract' and renumbers
#!/usr/bin/ruby
# * coding: utf-8 *
class PDFExtract
def self.main
ARGV.each {|a| new.extract a }
end
def extract(pdf)
images = parse_info(`mutool info #{pdf}`)
@snipsnipsnip
snipsnipsnip / pingport.rb
Last active January 31, 2017 12:09
pingport.rb
#!/usr/bin/env ruby
# coding: utf-8
require 'socket'
ARGV.size == 2 or abort "usage: #$0 hostname port"
host, port = ARGV
sec = 1
@snipsnipsnip
snipsnipsnip / dummy_ssl_server.rb
Created May 5, 2016 10:27
dummy_ssl_server.rb
require 'socket'
require 'openssl'
def wrap(server)
key = OpenSSL::PKey::RSA.generate(2048)
cert = OpenSSL::X509::Certificate.new
cert.issuer = cert.subject = OpenSSL::X509::Name.new([['CN', 'localhost']])
cert.public_key = key.public_key
cert.not_before = Time.now
cert.not_after = cert.not_before + 60 * 60
@snipsnipsnip
snipsnipsnip / dll.rb
Last active March 19, 2016 03:07
dll.rb: dumpbin/undname wrapper
require 'tempfile'
class DLL
include Enumerable
attr_reader :path
def initialize(path)
@path = path
end
@snipsnipsnip
snipsnipsnip / hosts.txt
Created March 5, 2016 12:44
add these lines to hosts to remove skype ads
127.0.0.1 *.2mdn.net
127.0.0.1 *.adnxs.com
127.0.0.1 *.adtech.de
127.0.0.1 *.atdmt.com
127.0.0.1 *.flashtalking.com
127.0.0.1 *.msads.net
127.0.0.1 *.msecn.net
127.0.0.1 *.msn.com
127.0.0.1 *.serving-sys.com
127.0.0.1 *.doubleclick.net