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
<%= f.check_box :vote, :checked => true, :style => 'visibility: hidden' %> |
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
import urllib2 | |
import json | |
import re | |
response = urllib2.urlopen('http://api.embed.ly/v1/api/services/python') | |
services = json.loads(response.read()) | |
url = 'http://soundcloud.com/dociler/dociler-futuricity' | |
for service in services: | |
for regex in service['regex']: | |
if re.match(regex, url): | |
print "Matched %s to %s" % (url, service['displayname']) |
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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
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
!!! Strict | |
%html{:xmlns => "http://www.w3.org/1999/xhtml"} | |
%head | |
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/ | |
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/ | |
%title Your Message Subject or Title | |
:css | |
/* Based on The MailChimp Reset INLINE: Yes. */ | |
/* Client-specific Styles */ | |
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */ |
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
<html> | |
<head> | |
<link href="//netdna.bootstrapcdn.com/bootswatch/3.0.0/flatly/bootstrap.min.css" rel="stylesheet"> | |
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet"> | |
</head> | |
<body> | |
<span class="alert alert-danger">Glyphicon example</span> | |
<hr> | |
<div class="the-icons"> | |
<span class="glyphicon glyphicon-glass"></span> |
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
# Each loop (non-assignment practice) | |
[1] pry(main)> a = ["red", "blue", "green"] | |
=> ["red", "blue", "green"] | |
[2] pry(main)> a.each do |color| | |
[2] pry(main)* p "The color is #{color}" | |
[2] pry(main)* end | |
"The color is red" | |
"The color is blue" | |
"The color is green" |
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
#Inheritance | |
class Shape | |
attr_accessor :color | |
def initialize(color = nil) | |
@color = color || "Red" | |
end | |
def can_fit?(shapeInstance) | |
if self.area >= shapeInstance.area |
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
# application_helper.rb | |
def bookmark_thumbnail(metadata) | |
image_tag(metadata[:thumbnail_url] || "thumb.png", width: "260") | |
end | |
# migration | |
add_column :bookmarks, :metadata, :text | |
# bookmark model | |
after_save :get_embedly_data |
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
## Inheritance ## | |
class Shape | |
attr_accessor :color | |
def initialize(color = nil) | |
@color = color || 'Red' | |
end | |
def larger_than?(shape) |
OlderNewer