Skip to content

Instantly share code, notes, and snippets.

View windwiny's full-sized avatar

windwiny windwiny

View GitHub Profile
@windwiny
windwiny / gist:5010865
Created February 22, 2013 05:09
ruby program wrap. write log on before and after run ori_porg
#!/usr/bin/env ruby
# ruby program wrap.
# mv /usr/bin/aaa /usr/bin/aaa_ori
# cp ./pg_wrap.rb /usr/bin/aaa
RED="\033[0;31m"
GREEN="\033[0;32m"
BLUE="\033[0;33m"
@windwiny
windwiny / gist:5010908
Created February 22, 2013 05:18
change source file and reload module on python pg is running. like ruby open class and monkey patch.
#-*- coding:utf-8 -*-
def install():
reloadmodtxt = """
'''
-----------------------------------------------------------------------------
Reload module, and auto change all wrap class's instance.__class__.__bases__
1. On everyone module
1) create wrap Class, in __init__/<or other> call incInstance(self)
@windwiny
windwiny / gist:5026939
Last active December 14, 2015 04:18
brew install ruby 2.0
require 'formula'
class Ruby < Formula
homepage 'http://www.ruby-lang.org/en/'
url 'http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2'
sha256 'c680d392ccc4901c32067576f5b474ee186def2fcd3fcbfa485739168093295f'
head 'http://svn.ruby-lang.org/repos/ruby/trunk/'
env :std
@windwiny
windwiny / gist:5075292
Created March 3, 2013 08:15
# show brew install program info. # independence missing ..
#!/usr/bin/env ruby
# show brew install program info.
# independence missing ..
pgs = %x{brew list}.split
deps = []
depss = []
pgs.each do |pg|
d = %x{brew deps --1 #{pg}}.split
deps << d
@windwiny
windwiny / gist:5386127
Created April 15, 2013 06:32
.emacs.d/init.el
;; emacs configuration
(column-number-mode)
;; 所有的备份文件转移到~/backups目录下
(setq backup-directory-alist (quote (("." . "/tmp"))))
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "/tmp")))
@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|
@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: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: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: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