daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jul 17th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'sequel'
  4. require 'haml'
  5.  
  6. con = Sequel.connect('postgres://dmw:dmw@localhost:5433/domowoi_development')
  7. enable :inline_template
  8.  
  9. get '/h' do
  10.   'hello'
  11. end
  12.  
  13. get '/hh' do
  14.   haml :index
  15. end
  16.  
  17. get '/n' do
  18.     s = ''
  19.     for i in 1..1000
  20.       s << "#{i}" << "\n"
  21.     end
  22.     s
  23. end
  24.  
  25. get '/nh' do
  26.     haml :numbers
  27. end
  28.  
  29. # users has about 40 rows in a table
  30. get '/s' do
  31.   '<pre>'+
  32.   con[:users].all.map do |u|
  33.     "#{u[:id]}\t#{u[:login]}\t#{u[:first_name]}\t#{u[:ser_name]}"
  34.   end.join("\n") +
  35.   '</pre>'
  36. end
  37.  
  38. get '/sh' do
  39.   @users = con[:users].all
  40.   haml :sequel
  41. end
  42.  
  43. class User < Sequel::Model
  44. end
  45.  
  46. get '/m' do
  47.   '<pre>'+
  48.   User.all.map do |u|
  49.     [u.id, u.login, u.first_name, u.ser_name].join("\t")
  50.   end.join("\n") +
  51.   '</pre>'
  52. end
  53.  
  54. get '/mh' do
  55.   @users = User.all
  56.   haml :model
  57. end
  58.  
  59. before do
  60.   content_type 'text/html', :charset => 'utf-8'
  61. end
  62.  
  63. __END__
  64. @@ layout
  65. %html
  66.   %body
  67.     = yield
  68.  
  69. @@ index
  70. %h1 Hello
  71.  
  72. @@ numbers
  73. - for i in 1..1000
  74.   = i
  75.  
  76. @@ sequel
  77. %pre
  78.   - @users.each do |u|
  79.     = "#{u[:id]}\t#{u[:login]}\t#{u[:first_name]}\t#{u[:ser_name]}"
  80.  
  81. @@ model
  82. %pre
  83.   - @users.each do |u|
  84.     = [u.id, u.login, u.first_name, u.ser_name].join("\t")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top