Created
February 1, 2016 02:48
-
-
Save MrIee/267d1e3b86f377c6eb26 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
How would I execute some code each element in a collection? | |
Loop in JS | |
each loop in Ruby | |
Convention over configuration: | |
Also know as coding by convention | |
decrease the number of decisions a developer has to make | |
Common in Ruby on Rails | |
Example - if there is a table called “sales” the database is also called “sales” | |
Rails naming conventions: | |
snake_case for local variables and instances methods | |
@sign for instance variables(“Hatted”) | |
CONSTANTS in capitals | |
$sign in front of global variables | |
camelCase for class and module names | |
? predicate method, ! destructive method | |
When should load be used in Ruby as apposed to require? | |
You use load to execute code, and you use require to import libraries. | |
What are the looping structures in Ruby? | |
.each | |
for | |
while | |
until | |
Why use validation? | |
Validations are used to ensure that only valid data is saved into your database. | |
Callbacks are methods that get called at certain moments of an object's life cycle. With callbacks it is possible to write code that will run whenever an Active Record object is created, saved, updated, deleted, validated, or loaded from the database. | |
Observers are similar to callbacks, but with important differences. Whereas callbacks can pollute a model with code that isn't directly related to its purpose, observers allow you to add the same functionality without changing the code of the model. | |
What are helpers in Rails? | |
Used to extract complex logic out of the view so that you can organize your code better. Main two benefits are: | |
Extract some complexity out of the view | |
Make view logic easier to test | |
A lot of these are already provided by Ruby | |
How might your prevent name conflicts in Javascript? | |
You would best limit the scope to the appropriate files and the global scope. | |
Use namespacing and global Identifiers | |
Closures | |
How would you model a coffee shop in Rails? | |
shop, staff, coffee, customers, suppliers | |
staff belongs shop | |
shop has many coffees | |
shop has many suppliers | |
shop has many customers | |
customer has many coffees through shop | |
Why is it better to serve site assets for multiple domains? | |
The purpose is to multiple connections between the server and the browser | |
Most browsers allow a minimum of two simultaneous connections from a single host and modern browsers can take up to 60 | |
large sites move their static content to CDN (content delivery network) which have geographically diverse servers | |
What is FOUC? How do you avoid FOUC? | |
FOUC stands for a Flash of Unstyled Content. FOUC describes the instance when a website appears loaded without any styling. This occurs when the web browser renders a page before all of the information is retrieved. | |
The main method for prevention of FOUC is to hide all or part of a website until all of the css and javascript are loaded | |
What is the difference between classes and IDs in CSS? | |
Classes apply their styling to every html element that has been assigned with that class. Classes are prefixed with dots | |
IDs only apply their styling to the first element that has been assigned with that ID. IDs are prefixed with hashes. | |
What’s the difference between the variable: null, undefined and undeclared? | |
null variables exist and have null assigned to them | |
undefined: Something is undefined when it hasn’t been defined yet. If you call a variable or function without having actually created it yet the parser will give you a not defined error. | |
undeclared: A variable is undeclared when it does not use the var keyword. It gets created on the global object (that is, the window), it then operates in a different space as the declared variables. | |
undeclared variables don’t even exist | |
undefined variables exist, but don’t have anything assigned to them | |
null variables exist and have null assigned to them | |
What's a typical use case for anonymous functions? | |
Pass them as arguments in other functions, a.k.a callbacks | |
E.g. setInterval(callback, time) | |
Ajax requests | |
Closures | |
What does * { box-sizing: border-box; } do? What are its advantages? | |
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout. | |
The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content. | |
Important: When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add the padding, borders and margins. | |
IE8 and earlier versions of IE, included padding and border in the width property. | |
To fix this problem, add a to the HTML page. | |
The box-sizing CSS property is used to alter the default CSS box model used to calculate widths and heights of elements. It is possible to use this property to emulate the behavior of browsers that do not correctly support the CSS box model specification. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment