Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Always Coding :)

Brad Traversy bradtraversy

💭
Always Coding :)
View GitHub Profile
@bradtraversy
bradtraversy / python_mysql.py
Last active Oct 20, 2020
Python & MySQL crash course for beginners
View python_mysql.py
import mysql.connector
from mysql.connector import errorcode
config = {
'user': 'root',
'password': '',
'host': 'localhost',
'database': 'acme'
}
@bradtraversy
bradtraversy / stack.js
Created May 29, 2020
Stack data structure
View stack.js
class Stack {
constructor() {
this.items = []
this.count = 0
}
// Add element to top of stack
push(element) {
this.items[this.count] = element
console.log(`${element} added to ${this.count}`)
@bradtraversy
bradtraversy / brython.html
Last active Oct 5, 2020
Python in the browser with Brython
View brython.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js" integrity="sha256-rA89wPrTJJQFWJaZveKW8jpdmC3t5F9rRkPyBjz8G04=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython_stdlib.js" integrity="sha256-Gnrw9tIjrsXcZSCh/wos5Jrpn0bNVNFJuNJI9d71TDs=" crossorigin="anonymous"></script>
@bradtraversy
bradtraversy / scrapy.md
Last active Oct 12, 2020
Scrapy commands and code
View scrapy.md
@bradtraversy
bradtraversy / flutter_setup.md
Last active Oct 20, 2020
Flutter dev setup & notes
View flutter_setup.md
@bradtraversy
bradtraversy / devcamper_specs.md
Last active Oct 19, 2020
Specs for Devcamper Udemy course project
View devcamper_specs.md

DevCamper Backend API Specifications

Create the backend for a bootcamp directory website. The frontend/UI will be created by another team (future course). The html/css template has been created and can be used as a reference for functionality. All of the functionality below needs to be fully implmented in this project.

Bootcamps

  • List all bootcamps in the database
    • Pagination
    • Select specific fields in result
    • Limit number of results
    • Filter by fields
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active Oct 22, 2020
Node app deploy with nginx & SSL
View node_nginx_ssl.md

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@bradtraversy
bradtraversy / django_crash_course.MD
Last active Oct 15, 2020
Commands for Django 2.x Crash Course
View django_crash_course.MD

Django Crash Course Commands

# Install pipenv
pip install pipenv
# Create Venv
pipenv shell
View node_redis_cache.js
const express = require('express');
const fetch = require('node-fetch');
const redis = require('redis');
const PORT = process.env.PORT || 5000;
const REDIS_PORT = process.env.PORT || 6379;
const client = redis.createClient(REDIS_PORT);
const app = express();
@bradtraversy
bradtraversy / node_redis_cache.js
Created Aug 20, 2019
Node.js & Redix Caching
View node_redis_cache.js
const express = require('express');
const fetch = require('node-fetch');
const redis = require('redis');
const PORT = process.env.PORT || 5000;
const REDIS_PORT = process.env.REDIS_PORT || 6379;
const client = redis.createClient(REDIS_PORT);
const app = express();
You can’t perform that action at this time.