Skip to content

Instantly share code, notes, and snippets.

require 'sinatra'
app_file = File.join(File.dirname(__FILE__), *%w[.. .. reports.rb])
require app_file
# Force the application name because polyglot breaks the auto-detection logic.
Sinatra::Application.app_file = app_file
require 'spec/expectations'
set :environment, :test
~/misc/projects/github/spree/sandbox$ rails g spree:install
/home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/mysql2-0.2.4/lib/mysql2/client.rb:36:in `connect': can't convert Fixnum into String (TypeError)
from /home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/mysql2-0.2.4/lib/mysql2/client.rb:36:in `initialize'
from /home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/mysql2-0.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:14:in `new'
from /home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/mysql2-0.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:14:in `mysql2_connection'
from /home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `new_connection'
from /home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:238:in `checkout_new_connection'
from /home/oren/.rvm/gems/ruby-1.9.2-p0@spree/gems/activerecord-3.0.0/lib/active_record/connection_adapt
app/model/event.rb
class MediaDatabase::Event < External
establish_connection :media_development
end
external.rb - not sure where it should be
class External < ActiveRecord::Base
def email_to_friend
errors = []
@name = params['email-to-friend']['name']
if @name == ''
errors << "Name is missing"
end
[2010-09-28 21:58:31] make
eval.c: In function ‘ruby_cleanup’:
eval.c:139: warning: passing argument 1 of ‘ruby_init_stack’ discards qualifiers from pointer target type
./include/ruby/ruby.h:1001: note: expected ‘VALUE *’ but argument is of type ‘volatile VALUE *’
io.c: In function ‘argf_next_argv’:
io.c:6241: warning: ignoring return value of ‘fchown’, declared with attribute warn_unused_result
process.c: In function ‘rb_fork’:
process.c:2322: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result
process.c: In function ‘proc_daemon’:
process.c:4239: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
module ProjectReader
extend self # keep extract_keys 'module private'
# finds keys in .erb files from a given directory
def find_keys(path)
repo_name = File.basename(path)
if !File.directory?(path)
raise "The directory #{repo_name} does not exist in #{File.dirname(path)}"
end
main.rb
---------------------------------------------
get '/' do
raise "explode!"
end
mailexceptions.rb
---------------------------------------------
def call(env)
status, headers, body =
view :
<%= render "missing_content" %>
_missing_content.html.erb :
<% if @missing_content %>
<h2> The following keys has no content on environment :</h2>
<% @missing_content.each do |language| %>
//working
$('.retweet-button').html('<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>');
//not working
var fbshare = $.getScript('http://widgets.fbshare.me/files/fbshare.js', function() {
$('.facebook-button').html(fbshare);
});
def import_contacts(data, params)
if data['token'] and !data['token'].blank?
token = data['token']
imported = Cache.get("imported_#{current_user.uid}_#{data['token']}")
return nil unless imported
else
service_name = data['service']
hash = validate(data) do
required(:service, :login, :password)
test("Service can't be blank", :service) do |val|