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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
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
module Goodness | |
def great? | |
@language == 'Ruby' | |
end | |
def self.included(base) | |
base.extend ClassMethods | |
def interesting | |
'there are thousands of spoken languages around the world' |
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
# Prism shapes - naive implementation | |
counter = 1 | |
stars = 5 | |
(1..20).each do |row| | |
if counter == stars * 2 - 1 | |
counter = 1 | |
else | |
if counter > stars | |
puts '*'*(stars * 2 - counter) |
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
# Turtle shapes | |
# Not at all necessory, but just to show that you can define attr_accessor from module as well | |
module AttrLoader | |
def attr_loader(*attrs) | |
attr_accessor *attrs | |
end | |
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
#http://grosser.it/2011/08/31/splitting-1-big-csv-file-into-multiple-smaller-without-parsing-it/ | |
require 'rubygems' | |
require 'rake' | |
# split giga-csv into n smaller files | |
def self.split_csv(original, file_count) | |
header_lines = 1 | |
lines = `cat #{original} | wc -l`.to_i - header_lines | |
lines_per_file = (lines / file_count) + header_lines | |
header = `head -n #{header_lines} #{original}` |
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
# If it is Rails-3 then using attar_accessible in model: | |
def self.needs_attr_accessible? | |
Rails::VERSION::MAJOR == 3 | |
end | |
if needs_attr_accessible? | |
attr_accessible :list_of_attributes | |
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
gem install passenger | |
passenger-install-nginx-module | |
sudo -E /usr/local/bin/ruby /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.19/bin/passenger-install-nginx-module | |
vi /opt/nginx/conf/nginx.conf | |
# Add in http block: | |
# passenger_root /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.19; | |
# passenger_ruby /usr/local/bin/ruby; | |
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
# 1. Install jenkins | |
sudo zypper addrepo http://pkg.jenkins-ci.org/opensuse/ jenkins | |
sudo zypper install jenkins | |
# You would be asked something like this: | |
# Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): t | |
# Overall download size: 115.9 MiB. After the operation, additional 159.9 MiB will be used. | |
# Continue? [y/n/?] (y): y | |
# 2. Start jenkins | |
sudo /etc/init.d/jenkins start |
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 'csv' | |
class Exporter | |
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ] | |
DESTINATION_FOLDER = "tmp/" | |
def self.export_tables_to_csv(tables = DEFAULT_EXPORT_TABLES) | |
tables.each { |klass| export_table_to_csv(klass) } | |
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
Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/servername.pid) | |
OR | |
Starting MySQL.The server quit without updating PID file (/[FAILED]mysql/servername.pid). | |
sestatus | |
echo 0 > /selinux/enforce | |
sestatus |
OlderNewer