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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"html/template" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"net/url" |
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
<div> | |
<h1>A Sinatra app to access Google+</h1> | |
<p>I'm sorry but the "The Sinatra app to access Google+" Web Service is not accessible from the folder you typed in.</p> | |
<p>The correct URL is: <a href="http://sinatragplus.heroku.com/">http://sinatragplus.heroku.com/</a></p> | |
<p><a href="/">Back</a></p> | |
</div> | |
<div id="footer"> | |
<p><b>A Fun Sinatra App for Google+ by RubyLearning 20 Sept. 2011</b>.</p> | |
</div> |
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
# myapp3_1.rb | |
require 'sinatra' | |
set :display_string, 'Welcome from RubyLearning again!' | |
before do | |
@msg = 'Awesome!' | |
end | |
get '/' do | |
settings.display_string + " " + @msg |
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 'ruboto/widget' | |
require 'ruboto/util/toast' | |
ruboto_import_widgets :Button, :LinearLayout, :TextView | |
# http://xkcd.com/378/ | |
class QuickStartActivity | |
def onCreate(bundle) | |
super |
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 Hiya | |
def self.hiya | |
"Hiya all!" | |
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 Display < MotorCycle | |
def dispAttr | |
'Color of MotorCycle is ' + @color | |
'Make of MotorCycle is ' + @make | |
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 MotorCycle | |
def initialize(make, color) | |
# Instance variables | |
@make = make | |
@color = color | |
end | |
def startEngine | |
if (@engineState) | |
'Engine is already Running' | |
else |
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
** Creating Sinatra Extensions ** | |
Let us say that our app requires us to send both GET and POST requests to a particular URL such that the same block of code handles both verbs. It makes sense to define an extension that can handle our requirement, as we don’t want to define two routes with identical code. | |
Here is our code: | |
# post_get.rb | |
require 'sinatra/base' | |
module Sinatra | |
module PostGet |
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
Free online courses at RubyLearning: | |
a. Ruby Metaprogramming 8th batch - | |
http://rubylearning.com/blog/2013/02/08/a-free-ruby-metaprogramming-course-learn-to-think-in-ruby/ | |
b. Sinatra 101 10th batch - | |
http://rubylearning.com/blog/2013/01/25/a-free-online-course-sinatra-101/ | |
c. Programming the Web with Ruby 3rd batch - | |
http://rubylearning.org/classes/ |
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
# Here are some ways by which you can define an anonymous class | |
# 1 | |
class Rubyist | |
def self.who | |
"Geek" | |
end | |
end | |
# 2 |
NewerOlder