Skip to content

Instantly share code, notes, and snippets.

PostgreSQL High Availibility on Kubernetes

  • Installation
  • Create PostgreSQL Cluster
  • Connect to a PostgreSQL Cluster
    • psql
    • pgAdmin
  • Updating PostgreSQL Cluster
  • High Availability
@bolerap
bolerap / app.js
Created November 19, 2020 04:39 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
  1. getInitialProps only works with component exported default by the page.
  2. Navigation via <a> will reload page because it call to remote API server, to navigation on client side let use wrapper component Link from "next/link"
@bolerap
bolerap / JAVA.md
Last active January 7, 2020 04:53

A. JDK

  1. install jenv by brew install jenv, install gradle by brew install gradle
  2. list installed java jenv versions
  3. install jdk by brew cask install java
  4. list all installed jdk /usr/libexec/java_home -V
  5. add JDK to jenv by jenv add <path> (paths get from step 4). eg jenv add /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
  6. set JDK used by jenv global <name> (name get from step 2)

B. GRADLE

  1. specify build errors by ./gradlew --scan. At this step we can know what errors occurred (usually is mismatch versions of lib or JDK)

Cannot route message for exchange 'reply.celery.pidbox': Table empty or key no longer exists This issue occurred on kombu version 4.6.5 Try to upgrade to 4.6.7 the issue will be fixed

@bolerap
bolerap / alpine_proxy_setting.md
Created September 11, 2017 08:13
Setting proxy for alpine linux
  1. create a file to keep environment variables (called env.sh here) at /etc/profile.d/env.sh
  2. export two proxy variable in /etc/profile.d/evn.sh as below
export http_proxy=http://<ip/name>:<port>
export https_proxy=$http_proxy
# Send POST request with data to github api to create a gist
curl --user "<username>" --request POST --data '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# or in short
curl -u "<username>" -X POST -d '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# or more short, if supplied -d (data) POST method can ommited as below
curl -u "<username>" -d '{"description": "Test create a github gists via api", "public": "true", "files": {"test.txt": {"content": "Hello"}}}' https://api.github.com/gists
# Send POST request with multiple data
curl --data "login=<username>" --data "token=<token_string>" https://github.com/api/v2/json/user/show/<username>
# or combine into single --data
#!/usr/bin/env bash
sudo apt -y update && sudo apt upgrade -y && \
sudo apt -y install apt-transport-https ca-certificates wget gnupg && \
wget -q -O - "https://repos.ripple.com/repos/api/gpg/key/public" | \
sudo apt-key add - && \
echo "deb https://repos.ripple.com/repos/rippled-deb bionic stable" | \
sudo tee -a /etc/apt/sources.list.d/ripple.list && \
sudo apt -y update && sudo apt -y install rippled && systemctl status rippled.service && \
sudo systemctl start rippled.service && sudo systemctl enable rippled.service
@bolerap
bolerap / BasicERC20.sol
Created July 19, 2019 10:53 — forked from giladHaimov/BasicERC20.sol
Basic ERC20 implementation
pragma solidity ^0.4.19;
contract ERC20Basic {
string public constant name = "ERC20Basic";
string public constant symbol = "BSC";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);