Skip to content

Instantly share code, notes, and snippets.

View mikedao's full-sized avatar
🤷

Michael Dao mikedao

🤷
View GitHub Profile
2-1 Order.first.items << Item.first
2-2
2-3
before_destroy :destroy_orders
def destroy_orders
self.orders.delete_all
end
Finite State Machines
-Mythical Creatures
Extension - How would I do this without using if statements?
One Sunday morning, lying in bed - Boom Finite State Machines
-What is a Finite State Machine?
-Mathematical model used to design computer programs and logical circuits
-Real World Examples
Soda machine
Electronic turnstiles
### Keybase proof
I hereby claim:
* I am mikedao on github.
* I am mikedao (https://keybase.io/mikedao) on keybase.
* I have a public key whose fingerprint is 97F7 199D E050 F2A3 0599 81AA DDB1 3C1B A5AD 4AFD
To claim this, I am signing this object:
class Cat
def initialize
end
def to_s
return "This is a string"
end
end
@mikedao
mikedao / gist:73ade0dfdab4f841841c
Created February 10, 2015 15:41
Software Disasters Lightning Talk
Software Disasters
For us, the worst that can happen when we write bad software is our app doesn't run. Maybe our website shows an error message.
However, in the real world, it can get a lot worse.
We're looking at two real world examples today where bad software, had really big real world implications
Ariane 5
@mikedao
mikedao / gist:a4cd2344717803690091
Last active August 29, 2015 14:15
Pivot Notes
app/controllers/admin/base_controller.rb
9: Redundant: won't current_user.admin? return nil if current_user is nil?
app/controllers/admin/items_controller.rb
Use strong params here?
app/controllers/admin/orders_controller.rb
Strong params
application_controller.rb
@mikedao
mikedao / Ben.md
Created January 22, 2015 21:57
Advice from Ben

Don't load db.seeds in test runs

Add factory_girl (read the GETTING_STARTED.md file, at least the first half)

Build the data that each test needs in that test.

Use the 4-phase test plan: setup, exercise, verify, teardown

You can use two numbers in code: 1 and 0. The rest are constants.

class Phoenix
attr_reader :name, :age, :lives, :revives
def initialize(name, age=0)
@name = name
@age = age
@alive = true
@lives = 0
@revives = 0
end
@mikedao
mikedao / gist:a5e07551907172086eb7
Last active August 29, 2015 14:13
ISBN Validator

Description

ISBN's (International Standard Book Numbers) are identifiers for books. Given the correct sequence of digits, one book can be identified out of millions of others thanks to this ISBN. But when is an ISBN not just a random slurry of digits? That's for you to find out.

Rules

Given the following constraints of the ISBN number, you should write a function that can return True if a number is a valid ISBN and False otherwise. An ISBN is a ten digit code which identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. To verify an ISBN you :- obtain the sum of 10 times the first digit, 9 times the second digit, 8 times the third digit... all the way till you add 1 times the last digit. If the sum leaves no remainder when divided by 11 the code is a valid ISBN. For example : 0-7475-3269-9 is Valid because

Description

During online gaming (or any video game that requires teamwork) , there is often times that you need to speak to your teammates. Given the nature of the game, it may be inconvenient to say full sentences and it's for this reason that a lot of games have acronyms in place of sentences that are regularly said.

Example

gg : expands to 'Good Game' brb : expands to 'be right back' and so on... This is even evident on IRC's and other chat systems. However, all this abbreviated text can be confusing and intimidating for someone new to a game. They're not going to instantly know what 'gl hf all'(good luck have fun all) means. It is with this problem that you come in.