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 'spec_helper' | |
describe Person do | |
# NOTE: build, create and attributes_for are FactoryGirl methods | |
# You should include this line in spec_helper to make them available | |
# without FactoryGirl. (prefix): | |
# --- | |
# Rspec.configure do |config| | |
# ... |
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
# spec/controllers/contacts_controller_spec.rb | |
require 'spec_helper' | |
describe MyController do | |
describe "#action" do | |
context "access restriction" do | |
it "requires authentication" do | |
# expect(repsonse).to redirect_to(login_path) | |
end | |
it 'requires authorization' do |
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
brew update | |
brew versions FORMULA | |
cd `brew --prefix` | |
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
brew install FORMULA | |
brew switch FORMULA VERSION | |
git checkout -- Library/Formula/FORMULA.rb # reset formula | |
## Example: Using Subversion 1.6.17 | |
# |
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
# -*- encoding : utf-8 -*- | |
module StringExtensions | |
def sanitize(options = {}) | |
Sanitize.clean(self, options) | |
end | |
def downcase_with_accent_support | |
self. | |
downcase. | |
tr("À", "à"). |
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
# init a bare repository (on a server) | |
mkdir repos/path.git | |
cd repos/path.git | |
git init --bare | |
# then, on a workstation | |
mkdir LOCAL_REPOS_PATH | |
cd LOCAL_REPOS_PATH | |
git init | |
touch .gitkeep | |
git add . |
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
# environment variables: http://www.postgresql.org/docs/9.2/static/libpq-envars.html | |
# PGUSER - default username | |
# PGDATABASE - default database name | |
# PGDATA - default database cluster directory | |
# initializing a cluster | |
initdb --encoding=UTF-8 --locale=pt_BR.UTF-8 [--pgdata=$PGHOME/data] [--username=superuser] | |
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
# iso to utf-8 | |
iconv -f iso-8859-1 -t utf-8 INPUT_FILE > OUTPUT_FILE | |
# mac to utf-8 (OS X Office Excel exports CSV with this encoding) | |
iconv -f mac -t utf-8 INPUT_FILE > OUTPUT_FILE | |
# converting .DAT files in a directory from ISO-8859-1 to UTF-8 | |
find input/dir -iname "*.dat" -type f -exec bash -c 'iconv -f iso-8859-1 -t utf-8 "{}" > output/dir/"{}"' \; |
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
# Synchronize directories with rsync and ssh: | |
# -r recursive | |
# -c skip based on checksum, not mod-time & size | |
# -h output numbers in a human-readable format | |
# -a archive mode | |
# -v verbose mode | |
# -e define shell used as transport | |
# -P same as --partial --progress: keeps partial transfered files if interrupted AND shows progress | |
# --delete to delete extraneous files on dest dir | |
rsync -rav -e "ssh -l $_USERNAME" --delete $_SOURCE_DIR $_DEST_DIR |
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
# listing chain rules | |
iptables --list CHAIN --line-numbers | |
# deleting a rule | |
iptables --delete CHAIN LINE_NUMBER | |
# inserting a rule in a predefined position (i.e. 3) | |
iptables -I INPUT 2 -p tcp --dport 80 -j ACCEPT | |
# appending rule to chain |
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 'oci8' | |
require 'iconv' | |
################################################################################ | |
class OracleReader | |
################################################################################ | |
def initialize(server, username, password) | |
# Open the connection. | |
@connection = OCI8.new(username, password, server) |
OlderNewer