- Randomly mixes input gathering, error handling, and business logic
- imposes cognitive load on the reader
- no digressions
Rails Date Formats – strftime | |
StrFTime Format Codes for Ruby on Rails | |
Year | |
%Y year with century 2007 | |
%y year without century 07 | |
%C century number (year divided by 100) 20 | |
Month | |
%B full month name January |
<source> | |
type tail | |
path path_to_file1 | |
pos_file path_to_pos_file1 | |
tag app.file1 | |
format /^(?<ip>[^ ]+) [^ ]+ [^ ]+ \[(?<time>[^\]]+)\] "(?<method>\S+) /(?<country>[A-Z0-9]{0,3})_(?<domain>[^/]+)/(?<module>[^/]+)/(?<controller>[^/]+)/(?<action>[^/]+)/(?<record>\S*)" (?<code>\d+) (?<res_time>\d+) "(?<referer>[^\"]*)" "(?<old_device>[^_\" ]*)_(?<device>[^_\" ]*)_(?<browser>[^_\" ]*) ?(?<guid>[^\"]*)" "(?<vuid>\d*) ?(?<option>[^\"]*)"$/ | |
time_format %d/%b/%Y:%H:%M:%S %z | |
rotate_wait = 5s | |
</source> |
first: brew install highlight | |
second: add to your .zshrc (or .bashrc) | |
function hlr { | |
filename=`echo $1 | cut -d . -f 1` | |
highlight --syntax ruby -k Menlo -K 20 -O rtf -s edit-xcode $1 > $filename.rtf | |
} | |
third: it will generate a .rtf file. just open and copy the highlighted code and add to your Keynote talk. |
diff -U 0 -r rails-3.1.0.beta1/.gitignore rails-3.1.1/.gitignore | |
--- rails-3.1.0.beta1/.gitignore 2011-10-07 11:56:15.000000000 -0400 | |
+++ rails-3.1.1/.gitignore 2011-10-07 12:59:12.000000000 -0400 | |
@@ -4,0 +5 @@ | |
+.sass-cache/ |
require 'editor.rb' | |
ed = Editor.new('testcollab/rails-test') | |
if ed.update_file('README.txt', 'my message', 'my new content') | |
ed.set_author('Scott', '[email protected]') | |
ed.update_file('README.2.txt', 'my message', 'my new content') | |
end |
require 'mechanize' | |
@username = '[email protected]' | |
@password = 'hi2u' | |
@download_path = File.expand_path 'downloads' | |
@wget_cookie = File.expand_path(File.dirname(__FILE__)) + '/wget-cookies.txt' | |
unless File.directory? @download_path | |
puts "@{download_path} doesn't exist!" | |
exit |
#!/usr/bin/env ruby | |
# == Synopsis | |
# This is a sample description of the application. | |
# Blah blah blah. | |
# | |
# == Examples | |
# This command does blah blah blah. | |
# ruby_cl_skeleton foo.txt | |
# |
class AuthenticationsController < ApplicationController | |
before_filter :authenticate_user!, :only => :destroy | |
def create | |
omniauth = request.env['omniauth.auth'] | |
authentication = Authentication.find_by_provider_and_uid(omniauth["provider"], omniauth["uid"]) | |
if current_user | |
if authentication && authentication.try(:user) != current_user | |
flash[:error] = I18n.t("This %{provider} account is already connected to another account in our service", :provider => authentication.provider) | |
elsif authentication.nil? |
require 'spec_helper' | |
describe Users::OauthCallbacksController, "handle facebook authentication callback" do | |
describe "#annonymous user" do | |
context "when facebook email doesn't exist in the system" do | |
before(:each) do | |
stub_env_for_omniauth | |
get :facebook |