Skip to content

Instantly share code, notes, and snippets.

@akhdaniel
akhdaniel / PostgreSQL HA on Kubernetes.md
Last active January 23, 2024 07:57
PostgreSQL HA on Kubernetes

PostgreSQL High Availibility on Kubernetes

  • Installation
  • Create PostgreSQL Cluster
  • Connect to a PostgreSQL Cluster
    • psql
    • pgAdmin
  • Updating PostgreSQL Cluster
  • High Availability

Postgres - Simple Master-Slave Replication

This is insecure, fast-to-setup setup of simple master-slave replication with dockerized PostgreSQL installation. Note, that below works with version postgres version 12.2: postgres (PostgreSQL) 12.2 (Debian 12.2-1.pgdg100+1).

Preparation:

# This is where your primary database files will be stored
@hongquan
hongquan / Idea.md
Created June 29, 2018 15:22
Ý tưởng phần mềm Ruabien, sắp lịch Tình nguyện viên bảo tồn động vật hoang dã

Mục đích

Ứng dụng giúp sắp xếp các TNV theo nhóm, mỗi nhóm sẽ làm việc 1 tuần, hoặc số ngày cố định, tùy chương trình.

Action flow

  • Admin tạo chương trình mới, đặt tên, đặt ngày tháng bắt đầu và kết thúc, đặt ngày "mở đăng ký".
  • Sinh khung thời gian làm việc (timeslot). Admin chỉ định số ngày mỗi khung sẽ kéo dài (mặc định là 7). Ứng dụng sẽ dựa vào ngày tháng của chương trình để sinh các slot.
  • Tới ngày mở đơn đăng ký, địa chỉ của đơn đăng ký sẽ có thể được truy cập (public available).
  • Khi truy cập link đăng ký, người dùng sẽ được yêu cầu đăng nhập, hoặc đăng ký nếu chưa có tài khoản.
@dexX7
dexX7 / omni_raw_simplesend.md
Last active February 23, 2020 08:46
Create raw Simple Send Omni transactions with Omni Core

The following example demonstrates the creation of a raw Omni transaction, which transfers 0.1 Test Omni with token identifier 2 from 1K6JtSvrHtyFmxdtGZyZEF7ydytTGqasNc to 1Njbpr7EkLA1R8ag8bjRN7oks7nv5wUn3o, with a transaction fee of 0.0006 BTC. For the sake of a demonstration, more than one unspent output was consumed.

1) List unspent outputs

List unspent outputs for 1K6JtSvrHtyFmxdtGZyZEF7ydytTGqasNc.

omnicore-cli "listunspent" 0 999999 '["1K6JtSvrHtyFmxdtGZyZEF7ydytTGqasNc"]'

How to install dlib v19.9 or newer (w/ python bindings) from github on macOS and Ubuntu

Pre-reqs:

  • Have Python 3 installed. On macOS, this could be installed from homebrew or even via standard Python 3.6 downloaded installer from https://www.python.org/download. On Linux, just use your package manager.
  • On macOS:
    • Install XCode from the Mac App Store (or install the XCode command line utils).
    • Have homebrew installed
  • On Linux:
@fernandohu
fernandohu / Reading configuration files before application startup in Angular2 final release.md
Last active July 7, 2024 19:31
Reading configuration files before application startup in Angular2 final release

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

cheat sheets.
$ command line ruby cheat sheets
PostgreSQL
----------
Create the filesystem
----
$ export PGROOT="/var/lib/postgres"
$ mkdir -p $PGROOT/data && chown postgres.postgres $PGROOT/data
@btroncone
btroncone / authentication.ts
Last active April 10, 2022 06:44
Angular 2 application role access decorator, wrapping built in CanAccess functionality. Prevents view transitions when user roles are not appropriate.
import { Injectable } from 'angular2/core';
import { Storage } from './storage';
import { CurrentUser } from '../interfaces/common';
@Injectable()
export class Authentication{
private _storageService : Storage;
private _userKey : string = "CURRENT_USER";
constructor(storageService : Storage){
@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
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
@apolloclark
apolloclark / postgres cheatsheet.md
Last active June 14, 2024 08:25
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL