Skip to content

Instantly share code, notes, and snippets.

View tudorilisoi's full-sized avatar

Tudor Ilisoi tudorilisoi

View GitHub Profile

Embedding an image

Storybook for React Demo

function fetchProtectedData(url, opts = {}) {
let headers = {
'Content-Type': 'application/json',
}
if (JWT_TOKEN) {
headers = {
...headers,
'Authorization': `Bearer ${JWT_TOKEN}`,
}
class ControlledInput extends React.Component {
constructor(props) {
super(props)
this.state = { value: props.initialValue || '' }
}
componentDidUpdate(prevProps, prevState) {
console.log(prevProps.initialValue, this.props.initialValue)
if (prevProps.initialValue !== this.props.initialValue) {
this.setState({ value: this.props.initialValue || '' })
// npm i animated-scroll-to --save
// import animateScrollTo from 'animated-scroll-to';
<li className="nav-item"><Link onClick={ev => {
console.log('clicked!')
// document.getElementsByClassName('flex-bottom')[0].scrollTop=0
if (window.location.pathname === '/players') {
ev.preventDefault()
animateScrollTo(0, {
element: document.querySelector('.flex-bottom'),
});
function getUrbanAreas() {
console.log(urbanAreaNames);
let userInputUA = Object.keys(urbanAreaNames);
for (let i = 0; i < userInputUA.length; i++) {
let urbanAreaDropdownlist = `<option value="${urbanAreaNames[userInputUA[i]]}">${userInputUA[i]}</option>`
$('#urbanAreas-Dropdown').append(urbanAreaDropdownlist);
}
$('#urbanAreas-Dropdown').chosen();
}
function setupDropdownSubmit() {
// https://www.npmjs.com/package/faker
const faker = require('faker')
faker.seed(123);
const { parse, stringify } = require('flatted/cjs');
function unique(fn, arr, objKey) {
const value = fn()
const exists = arr.find(item => item[objKey] === value)
if (exists !== undefined) {
const persons =[{
id: 'aBcDeFgH',
firstName: 'Juan',
lastName: 'Doe',
age: 32
},
{
id: 'zYxWvUt',
firstName: 'Alex',
lastName: 'Smith',
@tudorilisoi
tudorilisoi / http.md
Last active March 10, 2020 20:02
HTTP protocol 101
const express = require("express");
const app = express()
// NOTE the router should go into its own file and do
// module.exports = usersRouter;
const usersRouter = express.Router();
usersRouter.route('/id/:id')
.get((req, res, next) => {
res.status(200).json({ message: 'Hello' })
})

In these drills, you'll practice executing basic CRUD (create, read, update, delete) operations in the psql shell.

Before you get started, download this SQL data dump. Create and populate a new database using the data dump (make sure to update the path with the location where you saved the file):

psql -U dunder_mifflin_admin -d restaurants-app -f ~/Downloads/nyc-restaurants-data-backup.sql

Take a moment to get familiar with this new database. You can use \dt+ to see a list of public tables and \d <TABLENAME> to see a description of those tables.