Skip to content

Instantly share code, notes, and snippets.

@omarwaleed
omarwaleed / install-docker.sh
Last active September 18, 2017 09:00
Script to download Docker-ce amd64
#!/bin/bash
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#!/bin/bash
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
@omarwaleed
omarwaleed / default
Created July 24, 2017 14:38
nginx default reverse proxy from port 80 to app running on port 443
server {
listen 80;
listen [::]:80;
server_name api.insurancespot.ca;
return 301 https://api.insurancespot.ca$request_uri;
}
server {
#listen 80 default_server;
#listen [::]:80 default_server;
#!/bin/bash
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf
@omarwaleed
omarwaleed / wrapper.ts
Last active March 18, 2023 00:01
Allows you to wrap your express async handlers in a way that removes the need to put all your function body handlers in a try catch phrase. Instead, if an error is thrown, it returns a default response from the server
import { Request, Response, NextFunction } from 'express';
type ExpressRouteFn<T> = (req: Request & Partial<T>, res: Response, next: NextFunction) => unknown;
export function wrapper<T = {}>(fn: ExpressRouteFn<T>): ExpressRouteFn<T> {
return function(req, res, next) {
return (fn(req, res, next) as Promise<ExpressRouteFn<T>>).catch((err) => next(err));
}
}