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 -wKU | |
def ip_route_match(command, regex) | |
command.split("\n").select { |l| l =~ regex }.first.to_s[/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/] || '0.0.0.0' | |
end | |
c = '10.128.0.0/24 dev eth1 proto kernel scope link src 10.128.0.48 | |
127.0.0.0/8 dev lo scope link | |
default via 10.128.0.254 dev eth1' | |
# c = %x{/sbin/ip route list match #{ip}} |
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
<?php | |
// A little PHP function to get a succinct string of function backtraces. | |
function debug_backtrace_format() | |
{ | |
$bt = array_slice(debug_backtrace(), 1); // shift off the call to debug_backtrace_format() | |
return join(', ', array_map(create_function('$a', 'return $a["function"] ."() (". $a["file"] .":". $a["line"] .")";'), $bt)); | |
} | |
function test() |
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 bash | |
php -r "echo gzencode(file_get_contents('php://stdin'));" |
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 'rubygems' | |
require 'builder' # 2.1.2 | |
require 'nokogiri' # 1.2.1 | |
@testing = { :item1 => 'value1', :item2 => 'value2', :item3 => 'value3' } | |
def nokogiri | |
Nokogiri::XML::Builder.new { | |
root { | |
items { |