Skip to content

Instantly share code, notes, and snippets.

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=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')
@dfox
dfox / route53-user-policy.json
Created January 25, 2012 16:45
An IAM policy for Amazon AWS to allow limited access to Route 53
{
"Statement":[
{
"Action":[
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Effect":"Allow",
"Resource":[
@mperham
mperham / convert.rake
Created March 15, 2012 17:44
Ruby script to update MySQL from Latin1 to UTF8 without data conversion
desc "convert a latin1 database with utf8 data into proper utf8"
task :convert_to_utf8 => :environment do
puts Time.now
dryrun = ENV['DOIT'] != '1'
conn = ActiveRecord::Base.connection
if dryrun
def conn.run_sql(sql)
puts(sql)
end
else
@quackingduck
quackingduck / config.ru
Created May 6, 2012 23:23
Rack config for a static site
# A config.ru useful for serving static sites from the "Bamboo" heroku stack.
#
# Interface:
#
# Url Path | Action
# -------- | -------------------------------------------------------------
# / | contents of: index.html OR
# | contents of: 404.html OR
# | default 404 message
# |
@sishen
sishen / Usage:
Created June 4, 2012 05:44
Dirty plugin for SpineJS.
So the model object can bind the event "change:#{field} to trigger event when the field value is changed.
By default it's off and if need this feature, the model should extend Spine.Model.Dirty.
A sample case.
class User extends Spine.Model
@extend Spine.Model.Dirty
end
@toolmantim
toolmantim / application.html.erb
Created February 16, 2013 11:26
Pre-fetching your Rails asset hostname using dns-prefetch in your application's layout file
<!DOCTYPE html>
<html>
<head>
<title>App title</title>
<% if ActionController::Base.asset_host %>
<link rel="dns-prefetch" href="//<%= ActionController::Base.asset_host %>" />
<% end %>
@freshtonic
freshtonic / description.md
Last active December 17, 2015 10:39
The Rails Asset Pipeline & Angular JS partials.

My Angular.js partials live in public/partials.

In development mode I want them served from there, in production I want to have an Angular.js module called templates which simply popuates the template cache for me.

This isn't just about performance in production: it's making sure the partials are embedded in the assets which forces the partial's lifetime to be the same as the assets with no other caching worries when we redeploy the app.

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active July 7, 2024 19:32
A badass list of frontend development resources I collected over time.
@linjunpop
linjunpop / deploy-rails-4-app-with-dokku-on-digital-ocean.md
Last active May 30, 2023 08:20
Deploy Rails 4 app with Dokku on DigitalOcean

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
@sjahandideh
sjahandideh / How to demo feature specs.md
Last active December 28, 2015 01:49
How to demo your feature specs

In order to demo your feature specs, follow these steps:

  1. Add capybara, poltergeist, launchy and selenium-webdriver to your Gemfile under test and development group.
  2. Add the attached demo helper to your spec/support.
  3. Add the capybara config to your spec_helper file.
  4. Run bundle install.
  5. Write your feature with its scenario specs.
  6. Put a demo filter on each scenario you want to demo. ( refer to the example below )
  7. Run bundle exec rspec spec.