This file contains hidden or 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
# Option A: I'd start with this | |
class Micropost < ActiveRecord::Base | |
validate :no_profanity | |
private | |
def no_profanity | |
if user.minor? && profanity = profane_words_used_in_content | |
errors.add :content, "Profanity: '#{profanity.join(", ")}' not allowed!" | |
end | |
end |
This file contains hidden or 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 'stringio' | |
require 'timeout' | |
class Object | |
def methods_returning(expected, *args, &blk) | |
old_stdout = $> | |
$> = StringIO.new | |
methods.select do |meth| | |
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false |
I've always liked using the Page Object pattern to write concise, namespaced, and composeable capybara helpers:
When /^I register as a new user$/ do
NewUserPage.new(self).tap do |page|
page.visit!
page.form.fill
page.form.submit!
This file contains hidden or 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
# username = "my_username" | |
# pwd = "my_password" | |
# target_path = "my_target_path" | |
# saving auth cookie | |
system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \ | |
https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027} | |
(25..600).each do |i| |
This file contains hidden or 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/ruby | |
require 'net/http' | |
require 'nokogiri' | |
require 'rss' | |
require 'open-uri' | |
google_news_query = 'http://news.google.com/news/feeds?q=apologize&output=rss' | |
google_news_result_url = '' | |
wordlist = Array.new |
This file contains hidden or 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
" Pathogen | |
runtime bundle/vim-pathogen/autoload/pathogen.vim | |
call pathogen#infect() | |
call pathogen#helptags() | |
" Disable vi-compatibility | |
set nocompatible | |
" Remember more history | |
set history=1000 |
This file contains hidden or 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
set-option -g default-shell /bin/zsh | |
set -g prefix C-a | |
bind C-a send-prefix | |
unbind C-b | |
set -sg escape-time 1 | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
bind | split-window -h | |
bind - split-window -v |
This file contains hidden or 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 | |
# | |
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0333) | |
# | |
# ## Advisory | |
# | |
# https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/1h2DR63ViGo | |
# | |
# ## Caveats | |
# |
This is an example of adding Jenkins build status to a [dashing-dashboard](https://github.com/Shopify/dashing
If a job is running, the widget will have a grey background. If a job succeeded at its last run, it will have a green background. If a job failed at its last run, it will have a red background.
Requirements:
- Ruby 1.9
- dashing
NewerOlder