Skip to content

Instantly share code, notes, and snippets.

View purwandi's full-sized avatar
🏠
Working from home

purwandi purwandi

🏠
Working from home
View GitHub Profile

Useful Postgres Commands

1. Determine disk usage of a particular table/database

For a particular table,

SELECT pg_size_pretty( pg_total_relation_size('tablename') );
@purwandi
purwandi / packer-build.json
Created January 8, 2023 11:04 — forked from charandas/packer-build.json
coreos container linux OVA generation using Packer
{
"variables": {
"name": "coreos-baseimage",
"release": "stable",
"iso_checksum": "",
"iso_checksum_type": "none",
"disk_size": "40000",
"cpus": "4",
"memory": "2048",
"boot_wait": "15s",
@purwandi
purwandi / docker-compose.yml
Created July 21, 2019 12:12 — forked from danmrichards/docker-compose.yml
CockroachDB - Docker Compose Manifest. Spins up a simple 3 node CockroachDB cluster.
version: "3"
services:
roach1:
container_name: roach1
image: cockroachdb/cockroach:v1.1.3
command: start --insecure
ports:
- "26257:26257"
- "8080:8080"
volumes:
@purwandi
purwandi / Install.txt
Created May 25, 2019 15:40 — forked from soderlind/Install.txt
macOS DoH! (DNS over HTTPS) using cloudflared
1) Install cloudflared using homebrew:
brew install cloudflare/cloudflare/cloudflared
2) Create /usr/local/etc/cloudflared/config.yaml, with the following content
proxy-dns: true
proxy-dns-upstream:
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query
@purwandi
purwandi / dnsovertls.md
Created May 25, 2019 15:33 — forked from uraimo/dnsovertls.md
Configure your Mac to use DNS over TLS
@purwandi
purwandi / README.md
Created May 24, 2016 17:28 — forked from dominikwilkowski/README.md
Ubuntu 16.04 setup with NGINX http/2 and letsencrypt

Intro

This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.

Basics

After creating the server (droplet on DigitalOcean) log in with

@purwandi
purwandi / letsencrypt.md
Created May 24, 2016 17:15 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@purwandi
purwandi / README.md
Created May 24, 2016 16:40 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@purwandi
purwandi / .gitlab-ci.yml
Created December 19, 2015 19:05 — forked from iolson/.gitlab-ci.yml
GitLab CI
# Before Tests
before_script:
- bash ci/docker_install.sh > /dev/null
- composer self-update
- composer install --prefer-dist > /dev/null
- cp .env.gitlab .env
- php artisan key:generate
- php artisan migrate:refresh
# Services
@purwandi
purwandi / .ci-installer.sh
Created December 19, 2015 19:05 — forked from kevinvdburgt/.ci-installer.sh
Laravel 5.1 - GitLab CI
#!/bin/bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 0.12
nvm alias default 0.12
npm config set cache-min 86400
npm config set cache /cache/node_modules/
npm install -g gulp
npm install