- If there's any kind of visual change onscreen, from scrolling to animations, the device is going to put up a new picture, or frame, onto the screen for the user to see.
- Most devices today refresh their screen 60 times a second, which we measure in hertsz.
- So to much that we need to have 60 frames to put up. Most of the time we'll refer to this as 60 frames a second, or fps.
- People are expecially good at noticing when we miss one of these frames.
- If the browser is taking too long to make a frame, it will get missed out. The frame rate will drop and users will see stuttering. If it is really bad, then the whole screen can lock up, which is the worst.
This file contains 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
# Find the maximum | |
# def maximum(arr) | |
# arr.max | |
# end | |
def maximum(arr) | |
return nil if arr.empty? | |
max = - 1.0/0 #returns negative infinity |
This file contains 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
def fizzbuzz_output(number) | |
result = "" | |
result << "Fizz" if number % 3 == 0 | |
result << "Buzz" if number % 5 == 0 | |
result = number if result.empty? | |
result | |
end | |
def fizzbuzz(a,b) | |
a.upto(b) do |number| |
This file contains 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
# must be baller and either furnished or rent cheaper than 2100 | |
def rent?(furnished, rent, baller) | |
result = baller && (furnished || rent < 2100) | |
puts "Furnished: #{furnished}. Rent: #{rent}. Baller: #{baller}. Rent? #{result}" | |
end | |
### | |
# Add your "test" ("driver") code below in order to "test drive" (run) your method above... | |
# The test code will call the method with different permutations of options and output the result each time. | |
# This way, you will be able to run the renter.rb file from the CLI and look at the output of your "tests" to validate if the method works. |
This file contains 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
# Save this file to your computer so you can run it | |
# via the command line (Terminal) like so: | |
# $ ruby shakil_the_dog.rb | |
# | |
# Your method should wait for user input, which corresponds | |
# to you saying something to your dog (named Shakil). | |
# You'll probably want to write other methods, but this | |
# encapsulates the core dog logic |
This file contains 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
# Implemented bubble sort & radix sort | |
# Included benchmarking module & benchmarked both methods | |
# Included manual benchmarking for radix_sort | |
# Sort the array from lowest to highest | |
def bubble_sort(arr) | |
return arr if arr.size <= 1 # already sorted | |
swapped = true | |
while swapped do | |
swapped = false |
This file contains 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
def fb(s, f) | |
s.upto(f) { |x| | |
puts e(x) | |
} | |
end | |
def e(y) | |
if div_3?(y) && div_5?(y) | |
"FizzBuzz" | |
elsif div_5?(y) |
This file contains 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
list = {'yvr' => 'Vancouver', 'yba' => 'Banff', 'yyz' => 'Toronto', 'yxx' => 'Abbotsford', 'ybw' => 'Calgary'} | |
# Why is it returning nil instead of first element of the list above | |
p list['yvr'] |
This file contains 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
states = { | |
OR: 'Oregon', | |
FL: 'Florida', | |
CA: 'California', | |
NY: 'New York', | |
MI: 'Michigan' | |
} |
This file contains 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
import React from "react"; | |
import { render } from "react-dom"; | |
const ParentComponent = React.createClass({ | |
getDefaultProps: function() { | |
console.log("ParentComponent - getDefaultProps"); | |
}, | |
getInitialState: function() { | |
console.log("ParentComponent - getInitialState"); | |
return { text: "" }; |
OlderNewer