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
package regexp; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class RoedyNumberMatch { | |
private static final String[] P_FIXES = { "", "foo", "bar ", "20" }; | |
private static final Pattern PAT = Pattern |
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/ruby -w | |
if ENV['DEBUG'] | |
def debug(message) | |
$stderr.puts message | |
end | |
else | |
def debug(message) | |
# nop | |
end |
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/ruby -w | |
module Foo | |
module Foo4Class | |
def reset_instance_count | |
@instance_count = 0 | |
end | |
def new(*a, &b) | |
super.tap { @instance_count += 1 } |
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/ruby -w | |
Entry = Struct.new :id, :instance do | |
def self.parse(line) | |
if /ID=\s*'([^']*)'\s+INSTANCE=\s*'([^']*)'/ =~ line | |
new $1, $2 | |
else | |
raise "Cannot parse: %p" % line | |
end | |
end |
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/ruby | |
require 'benchmark' | |
def sin radians | |
h = Hash.new(Math.sin(radians)) | |
h[0.0] = 0 | |
h[90.0] = 1 | |
h[180.0] = 0 | |
h[270.0] = -1 |
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
Shorewall 4.5.17.1 per-IP Accounting at fw1 - Sun Jun 9 18:38:05 EST | |
2013 | |
Showing table: cowboys | |
IP: 192.168.200.1 SRC packets: 4196607 bytes: 292644635 DST packets: 7224498 bytes: 762829278 | |
IP: 192.168.200.2 SRC packets: 77289 bytes: 4799573 DST packets: 324472 bytes: 481821874 | |
IP: 192.168.200.3 SRC packets: 122875 bytes: 14531084 DST packets: 145748 bytes: 170332152 | |
IP: 192.168.200.4 SRC packets: 142254 bytes: 18836983 DST packets: 106100 bytes: 26420351 | |
IP: 192.168.200.5 SRC packets: 3424090 bytes: 181079976 DST packets: 6948051 bytes: 1798270528 | |
IP: 192.168.200.6 SRC packets: 2758 bytes: 234311 DST packets: 12875 bytes: 18882957 |
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
Rehearsal ------------------------------------------------------------------ | |
interpol 0.218000 0.000000 0.218000 ( 0.218013) | |
plus 0.156000 0.000000 0.156000 ( 0.158009) | |
append 0.390000 0.000000 0.390000 ( 0.386022) | |
const interpol 0.203000 0.000000 0.203000 ( 0.193011) | |
const plus 0.218000 0.000000 0.218000 ( 0.231013) | |
const append 0.203000 0.000000 0.203000 ( 0.196011) | |
--------------------------------------------------------- total: 1.388000sec | |
user system total real |
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
# Fancy benchmark... | |
# is respond_to? so faster than include? | |
require 'benchmark' | |
n = 10_000_000 | |
mock_methods = ('a'..'z').to_a | |
class Mock | |
end |
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
# Fancy benchmark... | |
# is respond_to? so faster than include? | |
require 'benchmark' | |
n = 10_000_000 | |
mock_methods = ('a'..'z').to_a | |
class Mock | |
end |
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/ruby | |
class Matrix | |
def initialize(row_headers, col_headers) | |
@row_headers = row_headers | |
@col_headers = col_headers | |
end | |
def [](row, col) |