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
1) What is a hash function? | |
A hash function is a function that takes a password string and "hashes" it, or encodes it, using an algorithm meant to hide the original password. | |
2) What is a one-way hash? | |
One way hashes are hashed strings that are almost impossible to reverse. | |
3) What is the problem with storing passwords as plain text? | |
Plain text passwords can be comprised by hackers. Typically if a hacker can get their hands on one user's password they will be able to access multiple accounts because users tend to reuse passwords. | |
4) How does HTTP Basic Authorization work? |
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
1) What is Knex used for? | |
Knex is used to make SQL queries using JS. | |
2) How do you connect to a Postgres Database using Knex? | |
const knex = require('knex')({ | |
client: 'pg', | |
connection: { | |
user: 'username', | |
password: 'password', | |
database: 'database' |
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
1) | |
create table if not exists TABLENAME ( | |
id serial primary key, | |
//add additional columns | |
2) | |
insert into TABLENAME (COLUMN1NAME, COLUMN2NAME) | |
values ('VALUEFORCOLUMN1', 'VALUEFORCOLUMN2); | |
3) |
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
app.get('/test', function (req, res) { | |
res.send('Now viewing the test page') | |
}) |
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
function getDataFromApi(callback) { | |
var settings = { | |
url: "https://api.github.com/gists/public", | |
dataType: 'json', | |
type: 'GET', | |
success: callback | |
}; | |
$.ajax(settings); | |
} |
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
function mergeDataStreams(stream1, stream2) { | |
var results = {}; | |
for (var i=0; i < stream1.length; i++) { | |
results[stream1[i].id] = stream1[i]; | |
} | |
for (var key in results) { | |
var otherData = stream2.find( | |
function(item) { return item.id === key; }); | |
for (var _key in otherData) { |
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
function createMyObject() { | |
return { | |
foo: 'bar', | |
answerToUniverse: 42, | |
'olly olly': 'oxen free', | |
sayHello: function() { | |
return 'hello'; | |
} | |
}; | |
} |
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
What is scope? Your explanation should include the idea of global vs. local scope. | |
Scope is a term used to classify parts of your code that have access to a variable. If the scope of the variable is local, any code inside the function can access the variable. Any code outside the function cannot. If the scope of a variabel is global, it means that the variable can be accessed from anywhere. | |
Why are global variables avoided? | |
Global variables can be bad for a variety of reasons- they make it difficult to work collaboratively, they can lead to bugs in your code that are difficult to untangle, you can run into concurrency issues, you may confuse global and local variable names, and so on. | |
Explain JavaScript's strict mode | |
JS's strict mode disables the use of global variables, forcing the user to define all variables locally. | |
What are side effects, and what is a pure function? |
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
function max(numbers) { | |
var currentMax = numbers[0]; | |
for (var i=0; i <= numbers.length; i++) { | |
if (numbers[i] > currentMax) { | |
currentMax = numbers[i]; | |
} | |
} | |
return currentMax; | |
} |
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
function main() { | |
try { | |
doAllTheThings(); | |
} | |
catch(e) { | |
console.error(e); | |
reportError(e); | |
} | |
} |