Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am ez-li on github.
  • I am fours (https://keybase.io/fours) on keybase.
  • I have a public key ASASDkN1e5Fc0h2xvjyJScQwx8sxgBosSOPZNpwHVw8CJAo

To claim this, I am signing this object:

@ez-li
ez-li / README-Template.md
Created October 30, 2019 06:12 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

config:
target: 'http://localhost:3000'
phases:
- duration: 60
arrivalRate: 100
defaults:
headers:
x-my-service-auth: '987401838271002188298567'
scenarios:
- flow:
config:
target: 'http://localhost:3004'
phases:
- duration: 60
arrivalRate: 100
defaults:
headers:
x-my-service-auth: '987401838271002188298567'
scenarios:
- flow:
const { Pool, Client } = require('pg')
const pool = new Pool({
host: 'localhost',
database: 'restaurants'
});
const query = 'SELECT * FROM menus WHERE restaurant_id = 222222';
pool.query(query, (err, result) => {
const end = new Date;
if (err) throw err;
@ez-li
ez-li / dataGenerator.js
Created August 24, 2019 04:42
Response Body for Test API call, Reservations Data
// TEST API CALL
app.get('/api/restaurants/r1', (req, res) => {
db.getReservation('r20', '2019-09-04', (err, data) => {
if (err) return console.log(err);
res.send(data);
});
});
// RESULT
function CashAmount(dollars) {
this.total = dollars;
this.pennies = dollars * 100;
}
CashAmount.prototype.totalInPennies = function() {
return this.pennies;
}
@ez-li
ez-li / largestLevelInTree.js
Created August 8, 2019 16:59
Find Largest Level in Tree
var findLargestLevel = function(node) {
var levelSum = {};
levelSum[0] = node.value;
var levels = [1];
var sumNodes = function(node, level) {
for (var i = 0; i < node.children.length; i ++) {
if (!levelSum[level]) {
levelSum[level] = node.children[i].value;
} else {
@ez-li
ez-li / .js
Created August 1, 2019 16:59
Browser with Back and Forward Buttons
class Browser extends React.Component {
constructor(props) {
super(props)
this.state = {
currentPage: defaultPage,
backPages: [],
forwardPages: [],
inputText: '',
submit: false
/**
* @param {number} numRows
* @return {number[][]}
*/
var generate = function(numRows) {
// the first row is always [1]
// the second row is always [1,1]
// GOAL take the previous array and add elements sequentially
// our result array has numRows # of elements
// we count from 0 to numRows, each row is an array with length of its index