Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
require 'aws/s3' | |
s3 = AWS::S3.new( | |
:access_key_id => 'ACCESS_KEY', | |
:secret_access_key => 'SECRET_KEY' | |
) | |
bucket = s3.buckets['BUCKET_NAME'] | |
c = bucket.objects.count | |
puts "size #{c}" |
<style> | |
#videogroup { | |
width: 100%; | |
} | |
iframe { | |
width: 90%; | |
padding: 5%; | |
} |
@mixin gradient($from, $to) { | |
/* fallback/image non-cover color */ | |
background-color: $from; | |
/* Firefox 3.6+ */ | |
background-image: -moz-linear-gradient($from, $to); | |
/* Safari 4+, Chrome 1+ */ | |
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to)); |
Frustrating couple of hours banging my head against the GFM and Redcarpet pages before I saw Ryan's example:
renderer = Redcarpet::Render::HTML.new(hard_wrap: false, filter_html: true)
options = {
autolink: true,
no_intra_emphasis: true,
fenced_code_blocks: true,
lax_html_blocks: true,
strikethrough: true,
renderer = Redcarpet::Render::HTML.new(hard_wrap: false, filter_html: true) | |
options = { | |
autolink: true, | |
no_intra_emphasis: true, | |
fenced_code_blocks: true, | |
lax_html_blocks: true, | |
strikethrough: true, | |
superscript: true | |
} | |
Redcarpet::Markdown.new(renderer, options).render(text).html_safe |
namespace 'rails' do | |
desc 'Renames the current app' | |
task 'rename' do | |
# Get the new name | |
new_name = ENV["NEW_NAME"].capitalize || nil | |
if new_name.nil? | |
puts "\nYou must pass in a new name" | |
exit | |
end | |
#!/usr/bin/env ruby | |
require "redis" | |
redis = Redis.new | |
redis.keys("*").each do |key| | |
val = case redis.type(key) | |
when "string" | |
redis.get key | |
when "list" |
#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) |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |