- Open the Terminal app
- Install rbenv using homebrew with
brew install rbenv
- Install ruby-build using homebrew with
brew install ruby-build
- Copy and paste following code into your terminal window:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
and hit return. - Copy and paste following code into your terminal window:
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
and hit return. - Close your terminal window and open a new one.
require 'date' | |
require 'active_support/all' | |
# Calcucaltes the age from a provided birthdate | |
# | |
# Returns - Age as Integer | |
def get_age(birthdate) | |
today = Date.today | |
birthdate = Date.parse(birthdate) | |
years = (today.year - birthdate.year) |
puts "Please enter a number between 0 and 100" | |
random_number = rand(0..100) | |
guess = gets.chomp.to_i | |
loop do | |
puts "Please enter a positive number" if guess < 0 | |
puts "Please enter a number below 100" if guess > 100 | |
puts "Your number is too low. Try again" if guess < random_number | |
puts "Your number is too high. Try again" if guess > random_number |
# 1. Read pdf | |
# 2. Filter data from pdf | |
# 3. Do the actual rename | |
require 'pdf-reader' | |
require 'date' | |
pdf = ARGV.first | |
# Read pdf and get name |
class Car | |
attr_accessor :model, :wheels, :brand | |
def initialize(model, wheels, brand) | |
@model = model | |
@wheels = wheels | |
@brand = brand | |
end | |
def start_engine |
count = 0 | |
loop do | |
unless count == 100001 | |
puts count | |
count += 1 | |
else | |
break | |
end | |
end |
require 'minitest/autorun' | |
require 'pry' | |
require 'mail' | |
require 'nokogiri' | |
class MailParser | |
class << self | |
def parse_email(email_path) | |
mail = Mail.read(email_path) | |
html_body = mail.parts.last.body.raw_source |
At the next Pantalk (21.2.2017 at X) Jasmine Torfi and Rodrigo Haenggi will be talking about the Rails Girls community in Switzerland.
Rails Girls Switzerland is a non-profit association with the aim to give tools and a community for women to understand technology and to build their ideas. We do this by organizing events that provide a great experience on building things and by making technology more approachable.
-
We aren’t always good at guessing where responsibilities should go. Coding is where our design guesses are tested. Being prepared to be flexible about making design changes during coding results in programs that get better and better over time.
-
If you’re programming along, doing nicely, and all of a sudden your program gets balky, makes things hard for you, it’s talking. It’s telling you there is something important missing.
-
Some of the biggest improvements come from figuring out how to eliminate:
- Duplicate code (even little bits of it)
require 'sinatra' | |
require 'json' | |
require 'namey' | |
require 'curb' | |
get '/catit' do | |
content_type :html | |
if params['image'] == 'true' | |
curl = Curl::Easy.http_get 'http://thecatapi.com/api/images/get?format=src&type=jpg' do |curl| |