Skip to content

Instantly share code, notes, and snippets.

@h-lame
Last active April 2, 2017 19:14
Show Gist options
  • Save h-lame/caaf6d8a2c91b3cce8fea05cc6b25d7a to your computer and use it in GitHub Desktop.
Save h-lame/caaf6d8a2c91b3cce8fea05cc6b25d7a to your computer and use it in GitHub Desktop.
Tying your shoes - code snippets from slides - see: http://h-lame.com/talks/tying-your-shoes/
Shoes.app :title => 'Talon' do
background '#fff'
end
Shoes.app :title => 'Talon' do
background '#fff'
background 'talon.jpg',
:bottom => 0,
:right => -20
flow :width => '100%' do
background '#df9', :curve => 12
title 'Talon',
:stroke => '#691FFF',
:align => 'center'
end
end
stack :margin => ['10%', '15%', '10%', '0px'] do
background '#df9', :curve => 12
title "Who goes there?",
:stroke => '#691FFF',
:align => 'center'
# ... entries and buttons go here
end
flow do
stack :width => '150px' do
para 'Nom de tweet'
end
@user_box = edit_line :width => '-170px'
stack :width => '150px' do
para 'Sekrit'
end
@pass_box = edit_line :width => '-170px',
:secret => true
end
button 'That is who I am!', :width => '100%' do
do_login
end
gem 'twitter'
require 'twitter'
Shoes.setup do
gem 'twitter'
end
require 'twitter'
def do_login
user = @user_box.text
pass = @pass_box.text
@twitter =
Twitter::Base.new(user, pass)
begin
@twitter.verify_credentials
@login.hide
show_logged_in_timeline
rescue Twitter::CantConnect => e
incorrect_login
end
end
def incorrect_login
if @incorrect_login_anim.nil?
@incorrect_login_anim =
animate do |i|
@login.displace((Math.sin(i) * 6).to_i, 0)
end
end
@incorrect_login_anim.start
timer(2) do
@incorrect_login_anim.stop
@login.displace(0,0)
end
end
class Book < Shoes
url '/', :index
url '/incidents/(\d+)', :incident
def index
incident(0)
end
# More code goes here...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment