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
=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') |
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 'rubygems' | |
require 'yaml' | |
# A demonstration of YAML anchors, references and handling of nested values | |
# For more info, see: | |
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/ | |
stooges = YAML::load( File.read('stooges.yml') ) | |
# => { | |
# "default" => { |
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
# Allow open-uri to follow unsafe redirects (i.e. https to http). | |
# Relevant issue: | |
# http://redmine.ruby-lang.org/issues/3719 | |
# Source here: | |
# https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb | |
module OpenURI | |
class <<self | |
alias_method :open_uri_original, :open_uri | |
alias_method :redirectable_cautious?, :redirectable? |
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
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php | |
// good javascript | |
(function ($) { | |
'use strict'; | |
$(function () { | |
$('[placeholder]') | |
.focus(function () { | |
var input = $(this); | |
if (input.val() === input.attr('placeholder')) { |
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> | |
* </head> | |
* <body> | |
* <canvas id="demo" height="400" width="400" style="background:#000;"></div> | |
* </body> | |
* </html> | |
* | |
*/ |
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 "rake" | |
shared_context "rake" do | |
let(:rake) { Rake::Application.new } | |
let(:task_name) { self.class.top_level_description } | |
let(:task_path) { "lib/tasks/#{task_name.split(":").first}" } | |
subject { rake[task_name] } | |
def loaded_files_excluding_current_rake_file | |
$".reject {|file| file == Rails.root.join("#{task_path}.rake").to_s } |
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
# app/controllers/sessions_controller.rb | |
class SessionsController < ApplicationController | |
# ... | |
def create | |
user = User.authenticate(params[:username], params[:password]) | |
if user | |
session[:user_id] = user.id |
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
# app/models/user.rb | |
class User < ActiveRecord::Base | |
validates :zip_code, presence: true, zip_code: true | |
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
#!/usr/bin/env ruby | |
require 'net/sftp' | |
@host = 'localhost' | |
@user = 'username' | |
@password = 'password' | |
@remote_dir = '/source/path/goes/here' | |
@remote_file_name = 'test-data.txt' | |
@tmp_dir = '/destination/path/goes/here' |
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
# PostgreSQL configuration tuning to improve tests performance of database interactions. | |
# Look for more detailed description in follow articles: | |
# - http://rhaas.blogspot.com/2010/06/postgresql-as-in-memory-only-database_24.html | |
# | |
# ATTENTION: | |
# Before appling those settings ensure that you have no important data in your cluster, because those settings | |
# could cause problems on your production database in case of appliance. | |
# | |
# Ensure follow settings have given values. |
OlderNewer