Skip to content

Instantly share code, notes, and snippets.

View mtodd's full-sized avatar
🔐
[redacted]

Matt Todd mtodd

🔐
[redacted]
View GitHub Profile
@mtodd
mtodd / App.java
Created July 31, 2008 20:16 — forked from anonymous/App.java
undefined
import java.util.HashMap;
public class App {
private static int installWindowWidth = 500, installWindowHeight = 350;
private static int adminWindowWidth = 400, adminWindowHeight = 275;
private static String server = "168.28.247.195", port = "3306", database = "software";
private static String user = "root", password = "";
private static String axeServer = "https://168.28.245.221:6467";
private static String webServer = "http://168.28.247.195:3000";
~$ traceroute google.com
traceroute: Warning: google.com has multiple addresses; using 64.233.187.99
traceroute to google.com (64.233.187.99), 64 hops max, 40 byte packets
1 192.168.1.1 (192.168.1.1) 2.136 ms 1.434 ms 1.426 ms
2 * * *
3 ge-2-5-ur01.c1morrow.ga.atlanta.comcast.net (68.86.108.121) 11.438 ms 12.103 ms *
4 te-9-2-ur01.a4atlanta.ga.atlanta.comcast.net (68.86.106.82) 11.168 ms 11.103 ms 9.297 ms
5 te-9-4-ur01.a5atlanta.ga.atlanta.comcast.net (68.86.106.25) 9.752 ms 12.648 ms 13.381 ms
6 te-9-4-ur01.a6atlanta.ga.atlanta.comcast.net (68.86.106.21) 10.468 ms 11.096 ms 9.582 ms
7 te-8-1-ar02.b0atlanta.ga.atlanta.comcast.net (68.86.90.122) 10.394 ms 11.899 ms 12.045 ms
Tab trigger: ###
class SubdomainToPathInfo # man I'm bad with names
def initialize(app)
@app = app
end
def call(env)
@app.call(filter(env))
end

The Problem


app = Rack::Builder.new do
  use Rack::CommonLogger
  use Rack::Reloader # this is the interesting part
  use Rack::ShowExceptions
  run HelloWorld.new
end
class Rack::Logger
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
env["rack.logger"] = @logger
result = @app.call(env)
@logger.flush if @logger.respond_to?(:flush)
class LimitPostBodySize
attr_accessor :app, :max_size
def initialize(app, max_size); @app, @max_size = app, max_size; end
def call(env)
if env['rack.input'].stat.size < @max_size
@app.call(env)
else
[413, {'Content-Type' => 'text/plain'}, 'Request Entity Too Large']
end
end
@mtodd
mtodd / OUTPUT
Created September 16, 2008 22:21
test_app1$ merb -p 4000
INFO [2008-09-16 18:40:54] (5973) Merb-App-Name-5973 :: Compiling routes...
INFO [2008-09-16 18:40:54] (5973) Merb-App-Name-5973 :: Starting Merb server listening at 0.0.0.0:4000
WARN [2008-09-16 18:40:54] (5973) Merb-App-Name-5973 :: Using Mongrel adapter
INFO [2008-09-16 18:40:58] (5973) Merb-App-Name-5973 :: Started request handling: Tue Sep 16 18:40:58 -0400 2008
DEBUG [2008-09-16 18:40:58] (5973) Merb-App-Name-5973 :: Routed to: {"action"=>"index", "controller"=>"messages"}
INFO [2008-09-16 18:40:58] (5973) Merb-App-Name-5973 :: Params: {"action"=>"index", "controller"=>"messages"}
INFO [2008-09-16 18:40:58] (5973) Merb-App-Name-5973 :: {:dispatch_time=>0.004199, :before_filters_time=>2.6e-05, :action_time=>0.003258, :after_filters_time=>2.9e-05}
INFO [2008-09-16 18:40:58] (5973) Merb-App-Name-5973 ::

With Reverse Lookup

Extends Hashes with the ability to look up by key or value instead of just key.

The benefit of this construct is mostly (and usually only) beneficial when there’s
a clear deliniation between the keys and values, such as with hashes with a common
key scheme and uniquely different string values. For example, a hash of states
(both geologic and status), etc.

It is not recommended to use this library with dynamically consumed data as

= Improved Logger Proxy for Merb

An improved version of the logging proxy injector for Merb for custom and verbose logging.