Skip to content

Instantly share code, notes, and snippets.

View ruxandrafed's full-sized avatar
🎯
Focusing

Ruxandra Fediuc ruxandrafed

🎯
Focusing
View GitHub Profile
const privateMethod = Symbol('privateMethod');
export default class Service {
constructor () {
this.say = "Hello";
}
[privateMethod] () {
console.log(this.say);
}
// 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
};
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);
}
};
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) {
@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

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: "" };
states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
@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']
@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 / 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