Skip to content

Instantly share code, notes, and snippets.

View pnhoang's full-sized avatar

Hoang Pham pnhoang

View GitHub Profile
@pnhoang
pnhoang / gist:dae226aa5353c92d184232ed365e3a6e
Created April 16, 2017 21:24
node.js express session secret
How I use sessions:
.env file (always in my .gitignore file so it never hits my public repos):
SECRET="This is my funky secret oh my god it has ninja turtles"
app.js:
var express = require('express'),
env = (function(){
var Habitat = require("habitat");
@pnhoang
pnhoang / gist:a5032fce9eeb8df4bc6da591f7ae8d72
Created April 16, 2017 22:21
node.js express testing with supertest and mocha
SuperTest works with any test framework, here is an example without using any test framework at all:
const request = require('supertest');
const express = require('express');
const app = express();
app.get('/user', function(req, res) {
res.status(200).json({ name: 'tobi' });
});
@pnhoang
pnhoang / bumpme
Last active November 24, 2017 14:59
Fri Nov 24 14:59:11 UTC 2017
[To delete all local branches that are already merged into the currently checked out branch:](https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged)
```git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d```
explain:
- git branch --merged: get all merged branch, this may include master or dev branch that you want to keep
- the second command, egrep -v, will look for all these branches and invert the search with a regular expression to search for master or dev branch
- all the results are listed on multiple lines, we need them as input parameters to the next command, we use xargs. The xargs utility reads space, tab, newline and end-of-file delimited strings from the standard
input and executes utility with the strings as arguments.
- then we can delete them with git branch -d as usual.

Notes from the docker workshop

docker ps

docker run -d -p 9000:80 nginx:latest

docker rm -f id-container

docker images

$ brew install mongodb

$ brew services start mongodb

$

@pnhoang
pnhoang / terminal.md
Last active September 7, 2018 14:18
Terminal Utilities

You can use Ctrl+U to clear up to the beginning.

You can use Ctrl+W to delete just a word.

You can also use Ctrl+C to cancel.

If you want to keep the history, you can use Alt+Shift+# to make it a comment.

@pnhoang
pnhoang / gatsby.md
Last active May 23, 2019 21:26
Gatsby presentation
@pnhoang
pnhoang / dev-notes.md
Last active June 4, 2019 14:35
Dev Notes

Troubleshooting Prisma

UnhandledPromiseRejectionWarning: Error: Project not found: 'default$default'

$ docker ps
$ docker logs -f <container-id>

Connecting to Postgres Container using Postico, same connection, user/password, databasename is also prisma.

Frontend Masters: AWS for Frontend Engineers

You should have the following completed on your computer before the workshop:

  • Install the AWS CLI.
  • Have Node.js installed on your system. (Recommended: Use nvm.)
    • Install yarn with brew install yarn.
  • Create an AWS account. (This will require a valid credit card.)
  • Create a Travis CI account. (This should be as simple as logging in via GitHub).