Skip to content

Instantly share code, notes, and snippets.

View steevehook's full-sized avatar
📖
redefining education

Steve Hook steevehook

📖
redefining education
View GitHub Profile
@steevehook
steevehook / node-folder-structure-options.md
Created January 16, 2018 00:40 — forked from lancejpollard/node-folder-structure-options.md
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@steevehook
steevehook / pcat-install.sh
Created February 3, 2018 12:44 — forked from BretFisher/pcat-install.sh
On macOS: Install pygmentize and alias pcat for shell code syntax highlighting
# first install pygmentize to the mac OS X or macOS system with the built-in python
sudo easy_install Pygments
# then add alias to your ~/.bash_profile or ~/.bashrc or ~/.zshrc etc.
alias pcat='pygmentize -f terminal256 -O style=native -g'

After Sierra upgrade, all my JDK were removed. So here is how I reinstalled all of them with only brew commands, and manage them with jEnv.

First do all your mac updates (especially XCode), then:

Install Brew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@steevehook
steevehook / docker-machine.sh
Created March 18, 2018 12:30 — forked from skatsuta/docker-machine.sh
Tired of running `eval "$(docker-machine env host)"` every time? Just paste this in .bashrc / .zshrc. This script automatically sets environment variables for one of running host machines in Docker Machine.
# check if `docker-machine` command exists
if command -v docker-machine > /dev/null; then
# fetch the first running machine name
local machine=$(docker-machine ls | grep "Running" | head -n 1 | awk '{ print $1 }')
if [ "$machine" != "" ]; then
eval "$(docker-machine env $machine)"
fi
fi
@steevehook
steevehook / remove-docker-containers.md
Created March 19, 2018 21:40 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
Paste this in .zshrc
prompt_dir() {
prompt_segment blue black "%$(( $COLUMNS - 61 ))<...<%3~%<<"
}
@steevehook
steevehook / prop-decorator.ts
Created April 19, 2018 11:44 — forked from RomkeVdMeulen/prop-decorator.ts
How to change instance properties through decorators in TypeScript: http://romkevandermeulen.nl/2018/01/24/typescript-property-decorators.html
function makePropertyMapper<T>(prototype: any, key: string, mapper: (value: any) => T) {
const values = new Map<any, T>();
Object.defineProperty(prototype, key, {
set(firstValue: any) {
Object.defineProperty(this, key, {
get() {
return values.get(this);
},
set(value: any) {
values.set(this, mapper(value));

Install cask that extends the brew command :

brew install phinze/cask/brew-cask

Install calibre using cask :

brew cask install calibre
@steevehook
steevehook / nginx-websocket-proxy.conf
Created May 17, 2018 13:42 — forked from uorat/nginx-websocket-proxy.conf
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
@steevehook
steevehook / nginx.conf
Created May 21, 2018 07:15 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048