Skip to content

Instantly share code, notes, and snippets.

View windwiny's full-sized avatar

windwiny windwiny

View GitHub Profile
@windwiny
windwiny / gist:7483a1c69e3ab683f28c
Created June 27, 2014 12:10
db2 diff db2move export load info
$load = []
File.foreach 'LOAD.out' do |line|
if line =~/^\* LOAD:\s*table(.*)$/
$load << $cc if $cc
tbs = $1.gsub /\s/,''
$cc=[tbs, -1, -1, -1, -1, -1]
elsif line =~ /Rows read:(.*)$/
$cc[1] = $1.to_i
elsif line =~ /Loaded:(.*)$/
@windwiny
windwiny / gist:9726e9827fcb7fc340aa
Last active August 29, 2015 14:02
osx make memory disk
#!/usr/bin/env ruby -w
# OSX 创建内存盘
puts '================================================================'
cmd="hdiutil attach -nomount ram://1048576"
puts ">>> #{cmd}"
new_disk=`#{cmd}`
new_disk.strip!
puts new_disk
@windwiny
windwiny / showgpt.rb
Last active August 29, 2015 14:01
show hdisk gpt part info
require 'zlib'
def show_lba0(rawdata)
puts "LBA0 ( MBR or PMBR )"
mbr = rawdata[446...512]
if mbr.size!=66 || mbr[-2..-1].unpack('CC') != [0x55, 0xaa]
puts "Not valid MRB part data"
puts
return
end
@windwiny
windwiny / gist:8313464
Created January 8, 2014 08:17
ruby proc, lambda difference
# proc, lambda difference
# Proc.new/proc --> not check parameter, return outside method
# lambda/-> --> check parameter, return just return lambda
p '------------------'
def test_1
p 'begin'
p1 = Proc.new do |x,y| p [x,y]; return end
p1.call
p 'end'
@windwiny
windwiny / gist:7924120
Created December 12, 2013 06:56
search each cylinder , find hard disk lost filesystem
def oo(cylinder, sector)
sector *= 512
aa=<<-EOS
echo "cylinder: #{cylinder}"
losetup -o #{sector} /dev/loop1 /dev/sdb3
if [ $? -eq 0 ] ; then
mount /dev/loop1 /tmp/11 2>/dev/null
if [ $? -eq 0 ] ; then
echo "offset #{sector} byte find a file system!!"
@windwiny
windwiny / gist:7855281
Created December 8, 2013 09:48
Extract VBA code to text files (for diffing)
Option Explicit
Function GetFolder(strPath As String) As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
@windwiny
windwiny / gist:7480143
Created November 15, 2013 06:43
nginx config
### included
upstream app1.com {
server 127.0.0.1:3001;
# server 127.0.0.1:3002;
# server 127.0.0.1:3003;
# server 127.0.0.1:3004;
# server 127.0.0.1:3005;
}
@windwiny
windwiny / gist:6673284
Created September 23, 2013 16:37
ruby 2.1.0 preview 1 homebrew Formula
require 'formula'
class Ruby < Formula
homepage 'http://www.ruby-lang.org/en/'
url 'http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0-preview1.tar.bz2'
sha256 '860b90d28b214393fd9d77ac2ad65b384d8249cd59b658c668cf0c7bad1db341'
option :universal
option 'with-suffix', 'Suffix commands with "20"'
@windwiny
windwiny / gist:5428930
Created April 21, 2013 08:39
ruby method method demo
class C1
def a;end
private
def e;end
end
C1.public_methods false #=> [:allocate, :new, :superclass]
c1=C1.new
@windwiny
windwiny / gist:5401448
Created April 17, 2013 02:58
Ruby get Tk Class
require 'tk'
File.open '/tmp/tk1.txt', 'w' do |f|
Object.constants.grep( /^Tk/).sort.each do |x|
n = Object.const_get x rescue x
f.puts "#{x} \t#{n.to_s} \t#{n.__id__}"
end
end
File.open '/tmp/ttk1.txt', 'w' do |f|