View Twitter_in_Javascript.js
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
/* | |
Javascript interface to Twitter search API. | |
Call it like | |
Twitter.search({q:'"is down'", | |
callback:function(data){ | |
doSomethingAwesome(data) | |
} | |
}) | |
You can also use any of the other options like lang, since_id, etc. |
View gets_pass.rb
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
#way to stop echoing to console while getting a password | |
#and to do it w/o pulling in another library | |
#ref: http://www.ruby-forum.com/topic/107442#243864 | |
# http://stackoverflow.com/questions/133719/how-to-read-a-password-in-ruby | |
def gets_pass | |
begin | |
system "stty -echo" | |
password = gets.chomp | |
ensure | |
system "stty echo" |
View time_test.rb
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
#fun with jruby dates | |
# | |
#perhaps related to | |
# http://jira.codehaus.org/browse/JRUBY-2541 | |
# | |
require 'date' | |
puts Time.now.to_s, DateTime.now.to_s | |
begin | |
require 'java' |
View fun_with_dm_associations.rb
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 'datamapper' | |
DataMapper::Logger.new(STDOUT, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class A | |
include DataMapper::Resource | |
property :id,Serial | |
has n, :bs | |
end |
View jruby_dm_prop_order_importance.rb
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
# Either datamapper or data objects has some weird behavior on jruby. | |
# When an empty text field comes before an integer field in a select, | |
# the integer field is clobbered. | |
require 'yaml' | |
require 'rubygems' | |
require 'dm-core' | |
class A |
View config.ru
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 'openid_provider_sinatra' | |
use Rack::Auth::Basic do |username,password| | |
'secret' == password | |
end | |
run OpenIDProvider.new nil, :store=>OpenID::Store::Filesystem.new(Dir.pwd + '/openid-store'), | |
:user=>Proc.new {|env| | |
login=env['REMOTE_USER'] | |
return nil unless login |
View openid_provider.rb
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 'openid_provider_sinatra' | |
use Rack::Auth::Basic do |username,password| | |
'secret' == password | |
end | |
run OpenIDProvider.new nil, :store=>OpenID::Store::Filesystem.new(Dir.pwd + '/openid-store'), | |
:user=>Proc.new {|env| | |
login=env['REMOTE_USER'] | |
return nil unless login |
View openid_id_app_through_env.rb
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 'openid_provider_sinatra' | |
use Rack::Auth::Basic do |username,password| | |
'secret' == password | |
end | |
class InjectUser | |
def initialize app | |
@app=app | |
end |
View openid_provider_single_user.rb
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 'openid_provider_sinatra' | |
IDENTITY = OpenStruct.new :login=>'Alice',:password=>'secret',:url=>"http://id.example.com/#{login}" | |
use Rack::Auth::Basic do |username,password| | |
IDENTITY.password == password && IDENTITY.login == username | |
end | |
run OpenIDProvider.new do |provider| | |
provider.identity IDENTITY |
OlderNewer