Skip to content

Instantly share code, notes, and snippets.

View paigen11's full-sized avatar

Paige Niedringhaus paigen11

View GitHub Profile
@paigen11
paigen11 / mysql-sequelize-connections.js
Created September 4, 2018 20:42
Quick config for setting up a MySQL database using Sequelize ORM in one file. Then this can be imported into route files or the server.js file directly
import Sequelize from 'sequelize';
import UserModel from './models/user';
const sequelize = new Sequelize('<table name>', '<db username>', '<db password>', {
host: '<host - could be localhost or service name for docker-compose service>',
dialect: 'mysql <or whichever SQL dialect you choose>',
});
const User = UserModel(sequelize, Sequelize);
@paigen11
paigen11 / pull_request_template.md
Last active June 8, 2019 21:26
An example of a pull request template, as used by Github to automatically provide formatted PRs.

Tracker ID: #ADD LINK TO PIVOTAL STORY

Unit tests completed?: (Y/N)

PR Branch #ADD LINK TO PR BRANCH

Code Coverage & Build Info

@paigen11
paigen11 / basic-string.js
Created September 14, 2019 15:01
Basic String
const string1 = 'this is a string in single quotes';
const string2 = "this is a string in double quotes";
@paigen11
paigen11 / back-ticks.js
Last active September 14, 2019 23:13
Template literal back-ticks basic example
/* your basic JavaScript strings, but with back-ticks.
notice the lack of escape characters needed for things
like single quotes, double quotes, and apostrophes
when back-ticks are employed */
const fooString = `A string called 'fooString'`;
const barString = `Another string named "barString"`;
const bazString = `Without fooString and barString, you can't have bazString, right?`;
@paigen11
paigen11 / expression-placeholder.js
Last active September 14, 2019 23:26
Template expression placeholder example
function authorize(user, action) {
if (!user.hasPermission(action)) {
throw new Error(
`User ${user.name} is not allowed to ${action}.`
);
}
}
const person = {
name: "Sean"
@paigen11
paigen11 / og-multi-line-string.js
Last active September 14, 2019 23:42
Multi-line string examples using traditional strings versus template literal back-ticks
console.log("To make a multi-line string this way\n" +
"I have to concatenate two separate strings with a + sign");
/* prints: To make a multi-line string this way
I have to concatenate two separate strings with a + sign */
@paigen11
paigen11 / template-literal-multi-line-string.js
Created September 14, 2019 23:43
Multi-line string created using template literal syntactic sugar
console.log(`With template literal back-ticks, I can spread strings across
as many lines as I want
with
no
problem.`);
/* prints: With template literal back-ticks, I can spread strings across
as many lines as I want
with
no
@paigen11
paigen11 / og-expression-interpolation.js
Last active September 15, 2019 00:04
The old way of injecting expression values into strings in JavaScript
const c = 10;
const d = 5;
console.log('It used to be harder to calculate that ' + (c + d)
+ '\n is not the same as ' + (2 * c) + ' in a string.');
/* prints: It used to be harder to calculate that 15
is not the same as 20 in a string. */
@paigen11
paigen11 / template-literals-expression-interpolation.js
Created September 15, 2019 00:10
Template literal syntax using expression interpolation
const c = 10;
const d = 5;
console.log(`With the syntactic sugar of ES6 template literals,
doing math in strings like this: ${c + d}
and that: ${2 * c} is a cinch.`);
/* prints: With the syntactic sugar of ES6 template literals,
doing math in strings like this: 15
and that: 20 is a cinch. */
@paigen11
paigen11 / es5-nesting-templates.js
Last active September 15, 2019 00:41
Creating nested template strings in ES5 without template literal assistance.
var classes = 'header';
function isDesktopSize(){
window.innerWidth > 1400 ? true : false;
};
var navbar = {
isOpen: false
};