Last active
April 2, 2017 19:14
-
-
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/
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
Shoes.app do | |
end |
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
Shoes.app :title => 'Talon' do | |
background '#fff' | |
end |
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
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 |
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
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 |
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
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 |
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
gem 'twitter' | |
require 'twitter' |
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
Shoes.setup do | |
gem 'twitter' | |
end | |
require 'twitter' |
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
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 |
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
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 |
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
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