Skip to content

Instantly share code, notes, and snippets.

View NguyenDa18's full-sized avatar
🎧
Listening to Funny Podcasts

Danh Nguyen NguyenDa18

🎧
Listening to Funny Podcasts
View GitHub Profile
@NguyenDa18
NguyenDa18 / quickstart.md
Last active January 13, 2020 21:16
Clojure QuickStart

Working with the REPL

  • lein repl : To start
  • (pst) : Print stack trace
  • (load-file "myfile.clj") : Run a CLJ file
  • Results of 3 most recent expressions: *1, *2, *3
  • (require '[clojure.by.example :as cbe]) : Require namespace
  • (use 'clojure.lib) : Use library at the REPL
  • (lein test :only clj-testing.namespace.my-test) : Run a specific namespace tests
  • use lein-try to test out clojars in repl
@NguyenDa18
NguyenDa18 / connectDb.js
Last active September 30, 2019 01:22
NEXT.js MERN Basics
// Util function : /utils/connectDb.js
// Use in routes handler like:
// import connectDb from '../../utils/connectDb'
// connectDb()
// ...stuff
import mongoose from 'mongoose'
const connection = {}
async function connectDb() {
@NguyenDa18
NguyenDa18 / redux-quick.md
Last active September 28, 2019 22:56
Redux Notes

Redux Quick

Install

  • npm i redux react-redux redux-thunk redux-devtools-extension
    • redux-thunk: middleware allows us to make async functions inside actions, await response then dispatch to reducer
    • redux-devtools-extension allows easier setup of redux chrome ext use

Init

    1. Set up store.js
@NguyenDa18
NguyenDa18 / nextjs-notes.md
Last active September 9, 2019 14:02
Next.js Notes

Next.JS Notes

  • Server rendered React
  • Pages in pages dir correspond to routes in app
  • Don't need to bring in React for every page
  • Hot code reloading out of box for Next

Install

npm i next react react-dom

  • Add dev script in package.json: dev: next
  • if diff port than 3000 needed: dev: next -p
@NguyenDa18
NguyenDa18 / node.md
Created October 20, 2018 23:28
Node and NVM basics

Node and NVM basics

Getting started with NVM

  • curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

If you already have Node installed:

  • nvm use system
  • npm uninstall -g a_module
@NguyenDa18
NguyenDa18 / docker2.md
Created October 13, 2018 08:24
Exploring Docker [2]

Docker Compose with Node + MongoDB

In this tutorial we will Dockerize a Node + MongoDB app: with a Docker Compose so that each of our containers are separated and can talk with one another. Then we will deploy to a DigitalOcean droplet.

Let's get started.

Getting Started

The app is simple. A user can create an Item and post it. The Item model has the attributes of a name and date.

@NguyenDa18
NguyenDa18 / docker1.md
Last active October 13, 2018 07:57
Exploring Docker [1]

Exploring Docker Part 1

Intro - Docker Overview

So you probably heard of Docker. Before delving into containers and images and Dockerfiles think of Docker as this: Your operating system is a kitchen, with all the ingredients and appliances you need to make delicious meals. Containers are the foods you will be making. If operating systems are like kitchens then using virutal machines before was like having separate kitchens to make different foods -pretty complicated and more importantly very heavyweight. Now the modular approach with Docker. Think of Dockerfiles as recipes. Portable sandboxes

  • Ability to run software in containers separate from operating system
  • Lightweight, less overhead, easy to port and deploy for machines