To get started with Rails we need to install the gem. From the terminal type:
{% terminal %}
$ gem install rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.3.6.gem (100%)
Fetching: activesupport-3.2.8.gem (100%)
...
{% endterminal %}
# controller | |
def proc_csv | |
import = Import.find(params[:id]) | |
if import.load_csv | |
flash[:notice] = "woo" | |
redirect_to some_url | |
else | |
flash[:error] = "ohoh" | |
end | |
end |
# 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") |
#!/bin/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |
## Prepare ################################################################### | |
# Remove RVM | |
rvm implode | |
# Ensure your homebrew is working properly and up to date | |
brew doctor | |
brew update | |
## Install ################################################################### |
postgres=# \dx | |
List of installed extensions | |
Name | Version | Schema | Description | |
---------+---------+------------+------------------------------ | |
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language | |
(1 row) | |
postgres=# \dx+ | |
Objects in extension "plpgsql" | |
Object Description |
#!/bin/bash | |
DATE=`date +"%a"` | |
DVOLNAME=datalv | |
LVOLNAME=journallv | |
VOLGR=datavg | |
DVOLPATH=/dev/$VOLGR/$DVOLNAME | |
LVOLPATH=/dev/$VOLGR/$LVOLNAME | |
DSNAME=`echo ${DVOLNAME}_ss_${DATE} | tr '[A-Z]' '[a-z]'` | |
LSNAME=`echo ${LVOLNAME}_ss_${DATE} | tr '[A-Z]' '[a-z]'` |
# The main parse method is mostly borrowed from a tweet by @JEG2 | |
class StrictTsv | |
attr_reader :filepath | |
def initialize(filepath) | |
@filepath = filepath | |
end | |
def parse | |
open(filepath) do |f| | |
headers = f.gets.strip.split("\t") |
require 'socket' | |
NOT_FOUND = "HTTP/1.1 404 Not Found\nContent-Length: 9\n\nNot Found" | |
OK = "HTTP/1.1 200 OK\n" | |
socket = Socket.new(:INET, :STREAM) | |
sockaddr = Socket.sockaddr_in(11080, '127.0.0.1') | |
socket.bind(sockaddr) | |
socket.listen(5) |
To get started with Rails we need to install the gem. From the terminal type:
{% terminal %}
$ gem install rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.3.6.gem (100%)
Fetching: activesupport-3.2.8.gem (100%)
...
{% endterminal %}
<p>SQL: <%= @users.to_sql %></p> | |
<h2>Your first #{search_limit} results</h2> | |
<table> | |
<thead> | |
<th><%= sort_link @search, :id, {}, :method => action_name == 'advanced_search' ? :post : :get %></th> | |
<th><%= sort_link @search, :first_name, {}, :method => action_name == 'advanced_search' ? :post : :get %></th> | |
# ... | |
</thead> |