Skip to content

Instantly share code, notes, and snippets.

@marc-an-be
marc-an-be / gist:3295747
Created August 8, 2012 15:10
Sinatra jQuery Mobile App Chunk 5
__END__
@@ layout
!!! 5
%html{:lang => 'en'}
%head
%meta{:charset => 'utf-8'}
%meta{:name => 'viewport', :content => 'width=device-width, initial-scale=1'}
%meta{:name => 'format-detection', :content => 'telephone=no'}
%title PillTracker
@marc-an-be
marc-an-be / gist:3295318
Created August 8, 2012 14:09
Sinatra jQuery Mobile App Chunk 4
get '/' do
@events = Event.all(:order => :time.desc)
haml :index
end
get '/new/?' do
haml :new
end
post '/new/?' do
@marc-an-be
marc-an-be / gist:3295312
Created August 8, 2012 14:08
Sinatra jQuery Mobile App Chunk 3
DataMapper::setup(:default,"sqlite3:pilltracker.db")
DataMapper.finalize.auto_upgrade!
@marc-an-be
marc-an-be / gist:3295307
Created August 8, 2012 14:07
Sinatra jQuery Mobile App Chunk 2
class Event
include DataMapper::Resource
property :id, Serial
property :time, DateTime
property :type, String
property :description, String
end
@marc-an-be
marc-an-be / gist:3295296
Created August 8, 2012 14:05
Sinatra jQuery Mobile App Chunk 1
#!/usr/bin/env ruby
%w(sinatra sqlite3 dm-sqlite-adapter data_mapper haml time).each{|g| require g}
@marc-an-be
marc-an-be / test_server.rb
Created February 2, 2012 12:48
Sample TCP Test-Server for a Ruboto Article
require 'socket'
server = TCPServer.new('',1234)
loop do
socket = server.accept
while line = socket.gets
puts line
end
end
@marc-an-be
marc-an-be / quick_start_activity.rb
Created February 2, 2012 12:47
Sample Activity for a Ruboto Article
require 'ruboto/activity'
require 'ruboto/widget'
require 'ruboto/util/toast'
require 'socket'
ruboto_import_widgets :Button, :LinearLayout, :EditText
$activity.start_ruboto_activity "$sample_activity" do
setTitle 'Funky TestApp'