- Randomly mixes input gathering, error handling, and business logic
- imposes cognitive load on the reader
- no digressions
| # SQLite version 3.x | |
| # gem install sqlite3-ruby (not necessary on OS X Leopard) | |
| development: | |
| adapter: sqlite3 | |
| database: db/development.sqlite3 | |
| pool: 5 | |
| timeout: 5000 | |
| # Warning: The database defined as "test" will be erased and | |
| # re-generated from your development database when you run "rake". |
| # Struct utilities | |
| # Author:: Matt Sullivan (mailto:matt.j.sullivan@gmail.com) | |
| # Attempt to require Ruby Gems; 1.8.X gem support only | |
| begin | |
| require 'rubygems' | |
| rescue LoadError | |
| # Ruby Gems not installed | |
| end |
| # Colorizes the output of the standard library logger, depending on the logger level: | |
| # To adjust the colors, look at Logger::Colors::SCHEMA and Logger::Colors::constants | |
| require 'logger' | |
| class Logger | |
| module Colors | |
| VERSION = '1.0.0' | |
| NOTHING = '0;0' |
| require "rubygems" | |
| begin | |
| require 'sequel' | |
| rescue LoadError | |
| puts "Please run gem install sequel" | |
| exit! | |
| end | |
| DB = Sequel.connect(:adapter => 'mysql2', | |
| :host => '127.0.0.1', |
| #registrations_controller.rb | |
| class RegistrationsController < Devise::RegistrationsController | |
| def create | |
| params[:user][:password_confirmation] = params[:user][:password] | |
| super | |
| end | |
| end | |
| <!-- Inside any View ---> | |
| <%= form_for(:user, :url => "#", :html => { :id => "ajax_signup"}) do |f| %> |
| # requires BSD sed | |
| namespace :whitespace do | |
| desc 'Removes trailing whitespace' | |
| task :cleanup do | |
| sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`; | |
| do sed -i '' 's/ *$//g' "$f"; | |
| done}, {:verbose => false} | |
| puts "Task cleanup done" | |
| end |
| class Hash | |
| def to_html | |
| [ | |
| '<ul>', | |
| map { |k, v| ["<li><strong>#{k}</strong>", v.respond_to?(:to_html) ? v.to_html : "<span>#{v}</span></li>"] }, | |
| '</ul>' | |
| ].join | |
| end | |
| end |
| # 0 is too far from ` ;) | |
| set -g base-index 1 | |
| # Automatically set window title | |
| set-window-option -g automatic-rename on | |
| set-option -g set-titles on | |
| #set -g default-terminal screen-256color | |
| set -g status-keys vi | |
| set -g history-limit 10000 |
| require 'digest' | |
| # Get SHA256 Hash of a file | |
| puts Digest::SHA256.hexdigest File.read "data.dat" | |
| # Get MD5 Hash of a file | |
| puts Digest::MD5.hexdigest File.read "data.dat" | |
| # Get MD5 Hash of a string | |
| puts Digest::SHA256.hexdigest "Hello World" | |
| # Get SHA256 Hash of a string using update |