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 / 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']
def count_letters(str)
letters = Hash.new{0}
str = str.gsub(/\s+/, "") #removes spaces
str.each_char { |c| letters[c] += 1 }
puts letters.inspect
end
puts "What's your string?"
user_input = gets.chomp
states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
@states = Hash.new { |h, k| h[k][1] = []}
@states = {
OR: ['Oregon', ['Portland', 'Jacksonville']],
FL: ['Florida', ['Miami']],
CA: ['California', ['San Jose', 'San Francisco', 'Monterrey']],
NY: ['New York', ['New York City', 'Long Island']],
MI: ['Michigan', ['Detroit']]
}
# Determine whether a string contains a SIN (Social Insurance Number).
# A SIN is 9 digits and we are assuming that they must have dashes in them
def has_sin?(string)
my_match = /\b\d\d\d\-\d\d\d\-\d\d\d\b/.match(string)
my_match == nil ? false : true
end
puts "has_sin? returns true if it has what looks like a SIN"
puts has_sin?("please don't share this: 234-604-142") == true
SELECT p.isbn FROM editions AS e
INNER JOIN publishers as p ON e.publisher_id=p.id
WHERE p.name = 'Random House'
@ruxandrafed
ruxandrafed / arrayOfLight (JS exercise)
Last active October 5, 2015 17:52
arrayOfLight (JS exercise)
function arrayOfLight(no) {
array = [];
for (i=0; i<=no; i++) {
array.push(i);
};
return array;
};
no = prompt('Give me a number:');

CSS Specificity

Use the information in this article to answer the following two questions. http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/

Question 1

How do you think the word "cascading" in "Cascading Style Sheets" relates to specificity?

Answer: Because more than one stylesheet rule could apply to a particular piece of HTML, there has to be a known way of determining which specific stylesheet rule applies to which piece of HTML. The CSS specification describes a priority scheme to determine which style rules apply if more than one rule matches against a particular element. In this so-called cascade, priorities (or weights) are calculated and assigned to rules, so that the results are predictable.

Question 2

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