Skip to content

Instantly share code, notes, and snippets.

View taniarascia's full-sized avatar
💾

Tania Rascia taniarascia

💾
View GitHub Profile
@taniarascia
taniarascia / listAllEventListeners.js
Created October 23, 2018 20:44 — forked from dmnsgn/listAllEventListeners.js
List all event listeners in a document
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@taniarascia
taniarascia / reactrouter.js
Created September 25, 2018 18:56
React Router
import React, { Component } from 'react'
import { NavLink, Switch, Route } from 'react-router-dom'
import './App.css'
const Navigation = () => (
<nav>
<ul>
<li>
<NavLink exact activeClassName="current" to="/">Home</NavLink>
</li>
@taniarascia
taniarascia / React.md
Created September 23, 2018 04:10
React notes

React Notes

  • A React component can only return one parent element.
return <h1>Hello</h1><p>World</p>            // error
return <div><h1>Hello</h1><p>World</p></div> // okay 
  • JavaScript expressions can be interpolated in JSX with {}
@taniarascia
taniarascia / roadmap.md
Created September 23, 2018 03:58
Roadmap

Roadmap of Web Development

Getting Started

Operating System

What operating system your computer runs on.

  • Mac, Windows, Linux
@taniarascia
taniarascia / pandoc.md
Created September 23, 2018 03:45
Pandoc

Pandoc Resources

brew instal pandoc
mkdir pandocking
cd pandocking
pandoc chapter1.md -s -o chapter1.html

Flags

@taniarascia
taniarascia / php.md
Created September 23, 2018 03:36
PHP functions

PHP Functions

Display PHP errors

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
@taniarascia
taniarascia / .prettierrc
Created September 11, 2018 19:05
Prettier
{
"semi": false,
"printWidth": 100,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"bracketSpacing": true
}

Build a REST API With Node.js and Express: Connecting a Database

In Part 1: Understanding RESTful APIs, we learned what the REST architecture is, what HTTP request methods and responses are, and how to understand a RESTful API endpoint. In Part 2: How to Set Up an Express API Server, we learned how to build servers with both Node's built in http module and the Express framework, and how to route the app we created to different URL endpoints.

Currently, we're using static data to display user information in the form of a JSON feed when the API endpoint is hit with a GET request. In this tutorial, we're going to set up a MySQL database to store all the data, connect to the database from our Node.js app, and allow the API to use the GET, POST, PUT, and DELETE methods to create a complete API.

Installation

Up to this point, we have not used a database to store or manipulate any data, so we're going to set one up. This tutorial will be using MySQL, and if you already have MySQL insta

@taniarascia
taniarascia / index.html
Last active February 13, 2024 07:50
Upload to server
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Upload Functions</title>
@taniarascia
taniarascia / .bash_profile
Created March 9, 2018 18:47
Show current Git branch and colors in terminal
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\$(parse_git_branch)\[\033[m\]\$ "