- 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
const privateMethod = Symbol('privateMethod'); | |
export default class Service { | |
constructor () { | |
this.say = "Hello"; | |
} | |
[privateMethod] () { | |
console.log(this.say); | |
} |
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
// This is an example of how to fetch external data in response to updated props, | |
// If you are using an async mechanism that does not support cancellation (e.g. a Promise). | |
class ExampleComponent extends React.Component { | |
_currentId = null; | |
state = { | |
externalData: null | |
}; |
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
function partial(fn /*, rest args */){ | |
return fn.bind.apply(fn, Array.apply(null, arguments).slice(1)); | |
} | |
const Logger = { | |
log(level, dateFormat, msg) { | |
console.log(level, dateFormat, msg); | |
} | |
}; |
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
function partial(fn /*, rest args */){ | |
const newArgs = Array.apply(null, arguments).slice(1); | |
return function(){ | |
const fnArgs = newArgs.concat(Array.apply(null, arguments)); | |
fn.apply(null, fnArgs); | |
} | |
} | |
const Logger = { | |
log(level, dateFormat, msg) { |
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: "" }; |
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
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
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
# 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 |
NewerOlder