See: AutoAwesome
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
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"; |
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 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) |
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
#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 |
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
# 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"). |
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 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 : | |
# |
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/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") |
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
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: |
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
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`' |
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 '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 |
OlderNewer