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. |
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" |
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' |
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 |
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 |
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 |
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 |
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 |
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