Archive

Posts Tagged ‘ruby’

twitterに位置情報を埋め込む

December 3rd, 2009 No comments

先日、twitterが正式に位置情報に対応しましたが、自分も試してみました
rubyのtwitterというgemでやってみました

# access_token, access_token_secretはあらかじめ準備しているものとします
twitter_oauth = Twitter::OAuth.new(CONSUMER_KEY, SECRET_KEY)
twitter_oauth.authorize_from_access(
access_token, access_token_secret)
@twitter = Twitter::Base.new(twitter_oauth)
@twitter.update('hoge', {:lat => latitude, :long => longtitude})

こんな感じでoptionを渡してやるだけです
twitter_gemのドキュメントにはoptionがin_reply_to_status_idしか書いてないのですが、ちゃんと投稿してくれます
ちなみに埋め込んだ座標をtweetdeckで表示するとこんな感じ

NY maps overlay on tweetdeck

NY maps overlay on tweetdeck

Rackでsessionをclearする

November 12th, 2009 No comments

session.clear

でsession[:hoge]みたいなのは全部消えるようだ
これだけで本当にsessionが初期化されているのかイマイチ自身が無い;

Tags: ,

rubyのTwitter::Base.new().verify_credentialsのメソッド?一覧

November 11th, 2009 No comments

verify_credentialsメソッドは認証したユーザについての情報を返す
Mashとかいうhashっぽいので定義されていて、何故かメソッドのごとく” . “でアクセス出来る
例)Twitter::Base.new(oauth).verify_credentials.screen_name

created_at
description
favorited
favourites_count
followers_count
following
friends_count
geo_enabled
href
id
in_reply_to_screen_name
in_reply_to_status_id
in_reply_to_user_id
location
name
notifications
profile_background_color
profile_background_image_url
profile_background_tile
profile_image_url
profile_link_color
profile_sidebar_border_color
profile_sidebar_fill_color
profile_text_color
protected
rel
screen_name
source
status
statuses_count
text
time_zone
truncated
url
utc_offset
verified
Tags: ,

rubyのTwitter::Base.newで得られるメソッド一覧

November 11th, 2009 No comments

使い方は気合いで

require 'twitter' # ver 0.7.0

==
===
=~
__id__
__send__
b64encode
blank?
block
class
client
clone
dclone
decode64
decode_b
delete
direct_message_create
direct_message_destroy
direct_messages
direct_messages_sent
disable_notifications
display
dup
enable_notifications
encode64
enum_for
eql?
equal?
extend
favorite_create
favorite_destroy
favorites
follower_ids
followers
freeze
friend_ids
friends
friends_timeline
friendship_create
friendship_destroy
friendship_exists?
frozen?
get
hash
help
id
inspect
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
is_list_member?
kind_of?
list
list_add_member
list_create
list_delete
list_members
list_remove_member
list_subscribe
list_subscribers
list_timeline
list_unsubscribe
list_update
lists
memberships
method
methods
nil?
object_id
post
private_methods
protected_methods
public_methods
put
rate_limit_status
replies
respond_to?
send
singleton_methods
status
status_destroy
taguri
taguri=
taint
tainted?
tap
to_a
to_enum
to_json
to_s
to_yaml
to_yaml_properties
to_yaml_style
type
unblock
untaint
update
update_delivery_device
update_profile
update_profile_colors
user
user_timeline
verify_credentials

以上

Tags: ,

Ubuntu9.10でruby環境構築

November 6th, 2009 No comments

9.10がリリースされたので入れ直したら色々忘れてたのでメモ

$ sudo aptitude install ruby ruby-dev libsqlite3-dev swig
$ sudo gem install sinatra sequel sqlite3-ruby

sinatra可愛いよsinatra

Tags: ,