Skip to content

Instantly share code, notes, and snippets.

View ruxandrafed's full-sized avatar
🎯
Focusing

Ruxandra Fediuc ruxandrafed

🎯
Focusing
View GitHub Profile
@ruxandrafed
ruxandrafed / max.rb
Last active September 1, 2015 19:15 — forked from davidvandusen/max.rb
# Find the maximum
# def maximum(arr)
# arr.max
# end
def maximum(arr)
return nil if arr.empty?
max = - 1.0/0 #returns negative infinity
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|
@ruxandrafed
ruxandrafed / renter.rb
Last active September 2, 2015 01:07 — forked from davidvandusen/renter.rb
# 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.
# 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
@ruxandrafed
ruxandrafed / sort.rb
Last active September 2, 2015 00:51 — forked from davidvandusen/sort.rb
# 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
@ruxandrafed
ruxandrafed / fizzbuzz_messy.rb
Last active September 2, 2015 05:50 — forked from kvirani/fizzbuzz_messy.rb
W1D2 Homework Exercise - Ruby - Messy Fizzbuzz
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)
@ruxandrafed
ruxandrafed / debug01.rb
Last active September 7, 2015 19:01 — forked from rafd/debug01.rb
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']
states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
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: "" };
@ruxandrafed
ruxandrafed / new_gist_file.md
Created July 24, 2017 04:25 — forked from kkas/new_gist_file.md
Browser Rendering Optimization Course Note (for myself)

Browser Rendering Optimization

Critical Rendering Path

Frames

  • 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.

Milliseconds Per Frame