Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rubygems'
require 'erubis'
require 'erubis/tiny'
require 'erb'
@date = Time.now
str = "<%%= Time::at( <%= @date.to_i %> ) %>"
require 'rubygems'
require 'twitter'
def get_friends(twit, page = 1)
r = twit.friends(:page => page)
(r.size == 100) ? r.concat(get_friends(twit, page + 1)) : r
end
UID = 'your_twitter_id'
PASSWORD = 'your_twitter_password'
require 'rubygems'
require 'sinatra'
require 'oauth'
require 'twitter'
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
require 'rubygems'
require 'sinatra'
require 'appengine-apis/datastore'
# Make sure our template can use <%=h
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
#!/usr/bin/env ruby
require 'pstore'
require 'pp'
file = ARGV[0]
db = PStore.new(file)
db.transaction(true) do
pp db
end
@machu
machu / appengine-pstore.rb
Created September 18, 2009 17:30
appengine-pstore.rb - A PStore compatible interface using the Datastore.
# = AppEngine::PStore --
#
# A PStore compatible interface using the Datastore.
# This module is based on pstore.rb written by matz.
#
require 'pstore'
require 'digest/md5'
require 'rubygems'
require 'appengine-apis/datastore'
require 'rubygems'
require 'benchmark'
require 'memcache'
require 'pstore'
def benchmark(cache)
count = 10000
key_size = 1000
Benchmark.bm do |bm|
bm.report("#{cache.class.to_s}#put") do
Index: index.fcgi
===================================================================
--- index.fcgi (revision 3594)
+++ index.fcgi (working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/env ruby
+#!/usr/local/bin/ruby
# -*- coding: utf-8; -*-
#
# index.fcgi $Revision: 1.35 $
diff --git a/core/tdiary/dispatcher.rb b/core/tdiary/dispatcher.rb
index be54430..974a982 100644
--- a/core/tdiary/dispatcher.rb
+++ b/core/tdiary/dispatcher.rb
@@ -204,11 +204,11 @@ module TDiary
@target = TARGET[target]
end
- def dispatch_cgi( cgi = CGI.new, stdout = STDOUT, stderr = STDERR )
+ def dispatch_cgi( cgi = CGI.new, stdout = nil, stderr = nil )
require 'thread'
module Safe
def safe( level = 4 )
result = nil
if $SAFE < level then
Thread.start {
$SAFE = level
result = yield
}.join
else