Skip to content

Instantly share code, notes, and snippets.

@mrtrihuynh
mrtrihuynh / npmcrashcourse.txt
Created July 27, 2021 02:54 — forked from bradtraversy/npmcrashcourse.txt
NPM Crash Course Commands
# GET VERSION
npm -v (or --version)
# GET HELP
npm help
npm
# CREATE PACKAGE.JSON
npm init
npm init -y (or --yes)
# GET VERSION
yarn -v (or --version)
# GET HELP
yarn help
# CREATE PACKAGE.JSON
yarn init
yarn init -y // Use defaults
@mrtrihuynh
mrtrihuynh / myscript.sh
Created July 27, 2021 02:53 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@mrtrihuynh
mrtrihuynh / ssh.md
Created July 27, 2021 02:53 — 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

@mrtrihuynh
mrtrihuynh / blogscraping.py
Created July 27, 2021 02:52 — forked from bradtraversy/blogscraping.py
Simple scraping of a blog
import requests
from bs4 import BeautifulSoup
from csv import writer
response = requests.get('http://codedemos.com/sampleblog/')
soup = BeautifulSoup(response.text, 'html.parser')
posts = soup.find_all(class_='post-preview')
@mrtrihuynh
mrtrihuynh / sw_cached_pages.js
Created July 27, 2021 02:52 — forked from bradtraversy/sw_cached_pages.js
Service worker to cache pages
const cacheName = 'v1';
const cacheAssets = [
'index.html',
'about.html',
'/css/style.css',
'/js/main.js'
];
// Call Install Event
@mrtrihuynh
mrtrihuynh / sw_cached_site.js
Created July 27, 2021 02:51 — forked from bradtraversy/sw_cached_site.js
Service Worker To Cache Response
const cacheName = 'v2';
// Call Install Event
self.addEventListener('install', e => {
console.log('Service Worker: Installed');
});
// Call Activate Event
self.addEventListener('activate', e => {
console.log('Service Worker: Activated');
@mrtrihuynh
mrtrihuynh / node_cheerio_scraping.js
Created July 27, 2021 02:50 — forked from bradtraversy/node_cheerio_scraping.js
Simple example to scrape some posts and put into a CSV file using Node & Cheerio
const request = require('request');
const cheerio = require('cheerio');
const fs = require('fs');
const writeStream = fs.createWriteStream('post.csv');
// Write Headers
writeStream.write(`Title,Link,Date \n`);
request('http://codedemos.com/sampleblog', (error, response, html) => {
if (!error && response.statusCode == 200) {
@mrtrihuynh
mrtrihuynh / docker-help.md
Created July 27, 2021 02:50 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@mrtrihuynh
mrtrihuynh / docker_wordpress.md
Created July 27, 2021 02:49 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes