5.4 - 2.2 # Subtraction
4 * 72 # Multiplication
7 / 3.5 # Division
3 ** 7 # Exponentiation
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 | |
attr_accessor :first_name, :last_name, :birth_year, :car_registration | |
def initialize(first_name, last_name, birth_year, car_registration) | |
@first_name = PersonDataChecker.check_name(first_name) | |
@last_name = PersonDataChecker.check_name(last_name) | |
@birth_year = PersonDataChecker.check_birth_year(birth_year) | |
@car_registration = PersonDataChecker.check_car_registration(car_registration) | |
end | |
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
! Disable everything but the search & video player on YouTube. | |
www.youtube.com###primary > .ytd-two-column-browse-results-renderer.style-scope | |
www.youtube.com###secondary | |
www.youtube.com###guide-inner-content | |
www.youtube.com##ytd-mini-guide-renderer | |
www.youtube.com##ytd-watch-next-secondary-results-renderer |
-
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)
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 | |
## Remove all local timemachine backups | |
for i in $(tmutil listlocalsnapshotdates / | awk '{print $1}' | sed -n '1!p' | xargs echo); do tmutil deletelocalsnapshots $i; done |
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
mentors = ["Hans", "Ruedi"].shuffle | |
attendees = ["Klara", "Kevin", "Mike", "Sandro", "Sandy", "Silvan", "Lala"].shuffle | |
number_of_groups = (attendees.count / mentors.count) | |
groups = attendees.each_slice(number_of_groups).to_a | |
mentors.each_with_index do |mentor, index| | |
puts "Group #{index + 1}: #{mentor}" | |
puts "====================" | |
puts groups.shift |
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
require 'pry' | |
keys = `aws s3api list-objects --bucket master21 --query 'Contents[].{Key: Key}' --output text | grep -v 'folder'` | |
keys = keys.split("\n") | |
keys.each do |key| | |
system("aws s3api put-object-acl --acl bucket-owner-full-control --bucket master21 --key '#{key}'") | |
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
require 'open-uri' | |
require 'prawn' | |
class OrangeTree | |
def initialize | |
@height = 0 | |
@orange_count = 0 | |
@fruit = 0 | |
@age = 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
puts "Ha! Did you really think I would give away the solution that easily?" | |
puts "Try again!" |
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 OrangeTree | |
def initialize | |
@height = 0 | |
@age = 0 | |
@oranges = 0 | |
@alive = true | |
end | |
def one_year_passes | |
@alive = false if @height > 10 && rand(2) == 1 |
NewerOlder