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 / Bug.md
Created August 5, 2014 16:38 — forked from HansNewbie/Bug.md

[ ] a [ ] b

  • c
  • d

If user is careless, forgetting to put "- " before "[ ]", TODO list could get buggy.

Steps to reproduce bug:

  • on parsed MD page of list above, tick "c" to note that "c" is done.
  • Now, edit the file.
@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";
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)
@mtodd
mtodd / init.rb
Created January 22, 2009 17:32 — forked from jnewland/init.rb
#don't use sinatra/main. we don't want the kitchen sink, just pretty rack apps
require 'sinatra/base'
class SinatraRailsPlugin < Sinatra::Base
get '/foo' do
'bar'
end
#this hackeration is required for sinatra to be a nice rack citizen
# Rack Nested Params Parser Spec
Rack::Utils.parse_query("x[y][z]=10").
should.equal "x" => {"y" => {"z" => "10"}}
Rack::Utils.parse_query("x[y][z][]=10").
should.equal "x" => {"y" => {"z" => ["10"]}}
Rack::Utils.parse_query("x[y][z][]=10&x[y][z][]=5").
should.equal "x" => {"y" => {"z" => ["10", "5"]}}
Rack::Utils.parse_query("x[y][][z]=10").
should.equal "x" => {"y" => [{"z" => "10"}]}
Rack::Utils.parse_query("x[y][][z]=10&x[y][][w]=10").
class ActionController::Request # ActionController::AbstractRequest in Rails < 2.3
# Returns true if the request seems to come from a bot
def bot?
user_agent =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)\b/i
end
end
#
# Then in your controllers you can do :
#
@mtodd
mtodd / after-use
Created August 17, 2009 07:20 — forked from defunkt/after-use
#!/usr/bin/osascript
on run_command(command)
tell application "Terminal"
do script "clear" in selected tab of front window
do script command in selected tab of front window
end tell
end run_command
tell application "System Events"
my run_command("cd ~/Projects/nudge")
@mtodd
mtodd / gist:180398
Created September 3, 2009 16:49 — forked from mperham/gist:180381
Surround a heredoc with quotes and you can continue the code on the same line:
render :status => 404, :text => <<-'EOH' and return unless setup
article not found<br/>
I, as a server, have failed<br/>
https?
EOH
Quotes also give you more freedom/creativity with the terminal ID:
on run argv
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down -- open a new tab
tell application "Terminal" to do script "cd " & item 1 of argv in front window -- change directory
end run
-- in your profile
-- alias newtab='osascript ~/.applescripts/newtab.applescript `pwd`'
@mtodd
mtodd / .irbrc
Created January 8, 2010 16:45 — forked from jacqui/.irbrc
require 'rubygems'
require 'pp'
unless self.class.const_defined? "IRB_RC_HAS_LOADED"
# Log to STDOUT if in Rails
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end