Skip to content

Instantly share code, notes, and snippets.

@isabellachen
isabellachen / develop-into-master.md
Last active October 23, 2017 14:54
Merge develop into master
$ git checkout develop
$ git pull origin develop
$ git checkout master
$ git merge develop
$ git push origin master
@isabellachen
isabellachen / fetch-rebase-changes.md
Last active May 7, 2018 12:33
Fetch and rebase changes from remote

Jack and Jill are working on a feature together. Jack has pushed to the feature branch on github. Before Jill pushes her changes, she needs to fetch and rebase her changes over Jack's.

git fetch
git rebase //replay Jill's commits over Jack's
gss  (list files with conflicts)
>> go to atom and fix the conflicts
git add <file-with-conflicts.js> or git add .
git rebase --continue (continue with rebase)
gss (check there are no conflicts)
@isabellachen
isabellachen / find-process-and-kill.md
Last active January 4, 2018 16:36
Kill terminal process running on port 3000 - for error EADDRINUSE
sudo lsof -i :3000

kill -9 <PID>
@isabellachen
isabellachen / chrome-authentication.md
Created October 27, 2017 10:09
How to set up user authentication for a Chrome Extension using the Chrome Identity API

How to set up user authentication for a Chrome Extension using the Chrome Identity API

  1. Create a private key file, from which you can create the manifest key and Application ID, as detailed here: https://stackoverflow.com/questions/23873623/obtaining-chrome-extension-id-for-development
  2. Add the manifest key to "key" in manifest.json
  3. Create a new project in Google Developer Console https://console.developers.google.com/project
  4. Go to "APIs & auth > Credentials" and create new client id for a Chrome Application using the Application ID generated in step 3.
  5. Copy the Client ID to oauth2.client_id in the manifest.json

Deprecated?

@isabellachen
isabellachen / promiseAll.js
Last active January 4, 2018 16:44
Use Promise All to return an array of values derived from a fetch call to an API
const fetchFromGithub = async (endpoint) => {
const url = `https://api.github.com/users/${endpoint}`
const response = await fetch(url)
return await response.json()
}
const getGithubUserInfo = async (handle) => {
return await Promise.all([
fetchFromGithub(handle),
fetchFromGithub(`${handle}/repos`)
@isabellachen
isabellachen / promise-example-async.js
Last active January 3, 2018 19:14
example using setTimeout to create a delayed, async function that is returned in a promise.
//contrived example creating a delayed function and a function that returns a promise where the delayed functio is resolved.
const delay = (cb) => {
setTimeout(() => {
cb('delay over')
}, 2000);
}
const promiseDelay = new Promise((resolve, reject) => {
delay((message)=>{
@isabellachen
isabellachen / async-error-handling-promise-chain.js
Last active February 20, 2018 12:35
Async function error handling in promise chain and async fuction
const fetchGithubUser = async (handle) => {
const url =`https://api.github.com/users/${handle}`
const response = await fetch(url)
const body = await response.json()
if (response.status !== 200) {
throw Error(body.message)
}
return body
}
@isabellachen
isabellachen / swapInPlace.js
Created January 26, 2018 19:32
Swap two values in place
let a = 1
let b = 2
b = [a, a=b][0]
console.log(a)//2
console.log(b)//1
@isabellachen
isabellachen / mysql-start.md
Last active July 24, 2019 15:02
Start up and exit mysql

INSTALL

brew install mysql
//Homebrew installs MySQL database without a root password

START PROCESS

mysql.server start
mysql -u root -p
@isabellachen
isabellachen / sequlize.js
Created January 31, 2018 22:57
quickly set up a connection to mysql db
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'myLibrary',
});
connection.connect(function (err) {