Skip to content

Instantly share code, notes, and snippets.

View cadd's full-sized avatar
💭
yeah

Robert cadd

💭
yeah
View GitHub Profile
@cadd
cadd / App.js
Created June 16, 2020 14:56 — forked from onedebos/App.js
import React, { useState, useEffect } from "react";
import axios from "axios";
const App = () => {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [user, setUser] = useState();
useEffect(() => {
const loggedInUser = localStorage.getItem("user");
@cadd
cadd / node_nginx_ssl.md
Last active September 3, 2020 19:23 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to Digital Ocean 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

@cadd
cadd / ssh.md
Created August 26, 2019 10:19 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@cadd
cadd / run.py
Created August 16, 2019 10:18 — forked from vulcan25/run.py
psycopg2 flask implementation with connection pooling support
from flask import Flask, g, jsonify
import werkzeug, os
from werkzeug.utils import secure_filename
import psycopg2
from psycopg2 import pool
def get_db():
print ('GETTING CONN')
if 'db' not in g:
@cadd
cadd / app.js
Created May 15, 2019 16:40 — forked from saiumesh535/app.js
error handling in express applicaiton
const express = require('express');
const http = require('http');
const app = express();
app.get('/', (req, res) => {
res.send('Hey!!');
});
app.post('/exceptionRoute', async (req, res) => {
@cadd
cadd / mysql_cheat_sheet.md
Created April 23, 2019 09:10 — forked from bradtraversy/mysql_cheat_sheet.md
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@cadd
cadd / tools.py
Created April 4, 2019 09:24 — forked from akhenakh/tools.py
flask jsonify with support for MongoDB from tools import jsonify
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
raise ImportError
import datetime
from bson.objectid import ObjectId
from werkzeug import Response
echo "
----------------------
MEANIE
----------------------
"
# clone meanie project from github into /opt/meanie folder
sudo git clone https://github.com/cornflourblue/meanie /opt/meanie
# install npm packages for meanie
#!/usr/bin/env bash
echo "
----------------------
NODE & NPM
----------------------
"
# add nodejs 10 ppa (personal package archive) from nodesource
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
@cadd
cadd / mongodb_model.py
Created February 1, 2019 09:12 — forked from fatiherikli/mongodb_model.py
Very simple MongoDB Model in Python
from pymongo import Connection
from bson import ObjectId
from itertools import imap
class Model(dict):
"""
A simple model that wraps mongodb document
"""
__getattr__ = dict.get