Skip to content

Instantly share code, notes, and snippets.

@rmanalan
rmanalan / 0what.md
Created August 24, 2009 03:09 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

require 'rubygems'
require 'sinatra'
get '/' do
"Hello"
end
post "/" do
raise CustomError
end
%a{:href => "http://google.com"} Google
\.
Produces:
<a href="http://google.com">Google</a> .
^ I want that space gone!!!
@rmanalan
rmanalan / gist:161461
Created August 4, 2009 19:09
How to embed a Sinatra app inside a Rails app through a plugin (not Metal)
script/generate plugin HelloWorld
# vendor/plugins/hello_world/init.rb
Rails.configuration.gem "sinatra"
Rails.configuration.middleware.insert_before("ActionController::Failsafe", "HelloWorld")
# vendor/plugins/hello_world/lib/hello_world.rb
# your sinatra app goes here...
require 'sinatra/base'
class HelloWorld < Sinatra::Base
@rmanalan
rmanalan / Cucumber step for testing text content inside a tag
Created July 31, 2009 20:37
Cucumber step for testing text content inside a tag
# For testing text content within a tag. First param is a CSS3 selector,
# while second param is a regex
Then /^the "([^\"]*)" should have "([^\"]*)"$/ do |element,content|
response.body.should have_selector(element) do |node|
node.text.should =~ /#{content}/
end
end
Jul 9, 2009 11:23:20 PM org.apache.catalina.core.ApplicationContext log
SEVERE: unable to create shared application instance
org.jruby.rack.RackInitializationException: Please install the oracle_enhanced adapter: `gem install activerecord-oracle_enhanced-adapter` (LoadError)
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/rails-2.3.2/lib/initializer.rb:417:in `initialize_database'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/rails-2.3.2/lib/initializer.rb:141:in `process'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/rails-2.3.2/lib/initializer.rb:113:in `run'
Jul 9, 2009 11:23:20 PM org.apache.catalina.core.ApplicationContext log
SEVERE: unable to create shared application instance
org.jruby.rack.RackInitializationException: Please install the oracle_enhanced adapter: `gem install activerecord-oracle_enhanced-adapter` (LoadError)
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/rails-2.3.2/lib/initializer.rb:417:in `initialize_database'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/rails-2.3.2/lib/initializer.rb:141:in `process'
from /home/oracle/tomcat_test/webapps/ROOT/WEB-INF/gems/gems/rails-2.3.2/lib/initializer.rb:113:in `run'
//Search Connect and Aria for a single keyword, sites open in separate tabs
CmdUtils.CreateCommand({
name: "search-oracle",
author: {name: "Jake Kuramoto",
homepage: "http://theappslab.com/"},
takes: {keyword: noun_arb_text},
preview: function(pblock, directObject) {
searchText = jQuery.trim(directObject.text);
// max of 140 chars is recommended, but it really allows 160
const STATUS_MAXLEN = 140;
CmdUtils.CreateCommand({
name: "connect",
takes: {status: noun_arb_text},
// borrowed the code written by:
homepage: "http://theunfocused.net/moz/ubiquity/verbs/",
<HTML>
<HEAD><TITLE>Redirection</TITLE></HEAD>
<BODY><H1>Redirect</H1></BODY>
</HTML>