This file contains 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
#!/usr/bin/env ruby | |
=begin | |
ruby win32ole common functions | |
OLE excel object: Application, Workbook, Worksheet, Range, Cells , ... | |
Demo howto find them, get/set value/style | |
used other ruby script import it: | |
require 'rbexcelbase' # copy this to C:\ruby2\lib\ruby\2.3.0\rbexcelbase.rb or |
This file contains 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
#!/usr/bin/env ruby | |
=begin | |
Use ruby/win32ole on excel application, replace VBA | |
=end | |
require 'pry' | |
require 'tk' | |
if Gem.win_platform? | |
require 'win32ole' |
This file contains 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
#!/usr/bin/env ruby | |
require 'pp' | |
require 'optparse' | |
options = {:can_skip_newerbundle=>true} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: gem-ext-compile-v2.rb [options]" | |
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| | |
options[:verbose] = v |
This file contains 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
#!/bin/sh | |
## create pid file , avoid script running multiple times | |
### every script gen a unique UUID | |
UUID=ACD35429D76148978480EA945653D112 | |
pid_file=/tmp/${UUID}.pid | |
if [[ -f $pid_file ]]; then | |
lpid=$(head -1 $pid_file) | |
if [[ ! -z $lpid ]]; then |
This file contains 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
/* | |
* fork.c | |
* Experimental fork() on Windows. Requires NT 6 subsystem or | |
* newer. | |
* | |
* Copyright (c) 2012 William Pitcock <[email protected]> | |
* | |
* Permission to use, copy, modify, and/or distribute this software for any | |
* purpose with or without fee is hereby granted, provided that the above | |
* copyright notice and this permission notice appear in all copies. |
This file contains 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
class String | |
# like python expandtabs | |
def expandtabs tabsize=8 | |
self.gsub(/[^\r\n]*/) do |line| | |
next line if line == '' | |
ss = line.split("\t", -1) | |
next line if ss.size == 1 | |
sa = [] | |
lasts = ss.pop |
This file contains 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
with timeout of 3600 seconds | |
tell application "Finder" | |
set sel to (get selection) | |
if not sel = {} then --selected file/dir | |
repeat with f in sel | |
set _cwd to POSIX path of (folder of f as alias) | |
exit repeat --first item path | |
end repeat | |
else --not select |
This file contains 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 'net/ssh' | |
host = "the.host" | |
user = "joe" | |
su_user = "bob" | |
password = "password" | |
su_password = "password" | |
commands = ['export PS1="\n[$?] [\t] $PS1----\n"', "cd /", "pwd", "ls -l", "exit"] | |
finished = ("%08x" * 8) % Array.new(8) { rand(0xFFFFFFFF) } |
This file contains 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
=begin | |
fdisk -l output sector to CHS | |
=end | |
def sect2chs sec | |
sec = sec.to_i | |
return "" if sec == 0 |
This file contains 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
---- | |
Linux 基于策略的路由(Linux Policy Routing) | |
Linux 有传统的基于数据包目的地址的路由算法,和新的基于策略的路由算法 | |
新算法优点:支持多个路由表,支持按数据报属性(源地址、目的地址、协议、端口、数据包大小、内容等)选择不同路由表 | |
# 查看规则命令,后面可跟其它参数,默认为 show(list) 显示全部 | |
ip rule |
NewerOlder