Skip to content

Instantly share code, notes, and snippets.

View bradtraversy's full-sized avatar
💭
Always Coding :)

Brad Traversy bradtraversy

💭
Always Coding :)
View GitHub Profile
@bradtraversy
bradtraversy / python_mysql.py
Last active August 5, 2023 12:47
Python & MySQL crash course for beginners
import mysql.connector
from mysql.connector import errorcode
config = {
'user': 'root',
'password': '',
'host': 'localhost',
'database': 'acme'
}
@bradtraversy
bradtraversy / stack.js
Created May 29, 2020 14:35
Stack data structure
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 January 4, 2024 18:18
Python in the browser with Brython
<!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 November 30, 2022 14:05
Scrapy commands and code
@bradtraversy
bradtraversy / flutter_setup.md
Last active March 19, 2024 04:59
Flutter dev setup & notes
@bradtraversy
bradtraversy / devcamper_specs.md
Last active March 17, 2024 17:25
Specs for Devcamper Udemy course project

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 April 24, 2024 10:14
Node app deploy with nginx & SSL

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 March 1, 2024 02:44
Commands for Django 2.x Crash Course

Django Crash Course Commands

# Install pipenv
pip install pipenv
# Create Venv
pipenv shell
@bradtraversy
bradtraversy / node_redis_cache.js
Created August 20, 2019 12:55
Node.js & Redis Caching
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 August 20, 2019 12:31
Node.js & Redix Caching
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();