Skip to content

Instantly share code, notes, and snippets.

View mikedao's full-sized avatar
🤷

Michael Dao mikedao

🤷
View GitHub Profile

Codebreakers

We're going to be writing a program to do some basic text encryption through everyone's friend, the command line.

Iteration 1 - Initials

We're first going to start with an exercise to figure out how we can get code entered on the command line.

Create a file called initials.rb.

string = "Denver"
puts "#{string[0]}#{string.length - 2}#{string[-1]}"
age = 5
puts "#{('happy ' * age).capitalize}birthday!"

Input Format

You are given an integer N depicting the height of the staircase.

Output Format

Print a staircase of height N that consists of # symbols and spaces as given in Sample Output.

Sample Input

You have an array of integers, and for each index you want to find the product of every integer except the integer at that index.
Write a function get_products_of_all_ints_except_at_index() that takes an array of integers and returns an array of the products.
For example, given:
[1, 7, 3, 4]
your function would return:
Suppose we could access yesterday's stock prices as an array, where:
The indices are the time in minutes past trade opening time, which was 9:30am local time.
The values are the price in dollars of Apple stock at that time.
So if the stock cost $500 at 10:30am, stock_prices_yesterday[60] = 500.
Write an efficient function that takes stock_prices_yesterday and returns the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday.
For example:

Pig Latin Translator

You are to create a Pig Latin Translator that has a REPL that follows an interaction model similar to this.

Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an ay, or if a word begins with a vowel you just add way to the end. For example, pig becomes ig-pay, banana becomes anana-bay, and aadvark becomes aadvark-way.

> cat
@mikedao
mikedao / gist:ff0577880b3026c1d4a7
Created December 7, 2015 21:18
fitbit_instructions.markdown
* Use black tool to open battery compartment.
* Put battery in. Plus side up.
* Plug ANT+ Dongle into computer.
* Go to fitbit.com/start
* Download Mac App
* Install Fitbit Connect
* Application will update on its own.
* Sign up for account, you can use Google or Facebook.
* Enter personal data.
* Select Fitbit Zip.
### Part 1
* What does a resolving name server do?
* What information does a root name server have?
* How does the TLD Name Server know about a domain's authoritative name server?
### Part 2
* What are the components of an HTTP Request?
* Where are cookies stored in an HTTP Response?