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
$ (sudo) gem install dm-core dm-migrations |
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 "dm-core" | |
require "dm-migrations" | |
# Configure DataMapper | |
DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://database.db") | |
# model Article | |
class Article | |
include DataMapper::Resource | |
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
$ (sudo) gem install ruby_pagination_logic |
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
# @app.rb | |
[...] | |
require "ruby_pagination_logic" | |
get '/page/:page' do |page| | |
@page = page.to_i | |
limit = 5 | |
offset = RPL::paginate @page, limit | |
@post = Post.all :limit => limit, :offset => offset, :order => 'date' |
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
import urllib, json | |
url = "http://%s.jaiku.com/contacts/feed/json" % username | |
params = {'user': username, 'personal_key': api_key} | |
result = urllib.urlopen(url, urllib.urlencode(params)).read() | |
data = json.loads(result) | |
title = data['title'] # Jaiku | Overview | |
# print timeline | |
for presence in data['stream']: |
NewerOlder