This file contains hidden or 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
class Account | |
attr_reader :name, :balance | |
def initialize(name, balance=100) | |
@name = name | |
@balance = balance | |
end | |
def display_balance(pin_number) | |
puts pin_number == pin ? "Balance: $#{@balance}." : pin_error | |
end |
This file contains hidden or 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
class Person | |
def initialize(name, age) | |
@name = name | |
@age = age | |
end | |
public # This method can be called from outside the class. | |
def about_me | |
puts "I'm #{@name} and I'm #{@age} years old!" |
This file contains hidden or 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
class Machine | |
@@users = {} | |
def initialize(username, password) | |
@username = username | |
@password = password | |
@@users[username] = password | |
@files = {} | |
end | |
This file contains hidden or 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
$VERBOSE = nil # We'll explain this at the end of the lesson. | |
require 'prime' # This is a module. We'll cover these soon! | |
def first_n_primes(n) | |
unless n.is_a? Integer | |
return "n must be an integer." | |
end | |
if n <= 0 |
This file contains hidden or 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
movies = { | |
Memento: 3, | |
Primer: 4, | |
Ishtar: 1 | |
} | |
puts "What would you like to do?" | |
puts "-- Type 'add' to add a movie." | |
puts "-- Type 'update' to update a movie." | |
puts "-- Type 'display' to display all movies." |
This file contains hidden or 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
#!/usr/bin/env bash | |
ssh -t [email protected] ' | |
source ~/.bash_login && cd ~/happycasts && \ | |
git pull && \ | |
bundle exec rake db:migrate RAILS_ENV=production; \ | |
bundle && bundle exec rake assets:precompile &&\ | |
touch tmp/restart.txt | |
' |
This file contains hidden or 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
#!/usr/bin/env bash | |
ssh -t [email protected] ' | |
source ~/.bash_login && cd ~/happycasts && \ | |
git pull && \ | |
bundle exec rake db:migrate RAILS_ENV=production; \ | |
bundle && bundle exec rake assets:precompile &&\ | |
touch tmp/restart.txt | |
' |
This file contains hidden or 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
################################# | |
# | |
# 本清单基于 ubuntu 12.04, | |
# 下个 ubuntu 的 LTS | |
# 发出来后,会相应更新这里的内容。我的目标是按步执行可以零错误完成安装。 | |
# 注意,本文件只是一个清单,不是一个可以安全执行的脚本 | |
# | |
################################# | |
# create a linode,login as root, and create a common user for all the tasks |
This file contains hidden or 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
#!/bin/bash | |
PS1="`whoami`@`hostname`:"'[$PWD]' | |
history | |
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` | |
if [ "$USER_IP" = "" ] | |
then | |
USER_IP=`hostname` | |
fi | |
if [ ! -d /tmp/history ] |
This file contains hidden or 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
#!/bin/sh | |
ssh -t haoqicat.com " | |
. .profile | |
cd /home/peter/apps/onestep/ | |
git pull | |
bundle | |
rake db:migrate RAILS_ENV=production | |
rake assets:precompile | |
sudo apachectl graceful |