Skip to content

Instantly share code, notes, and snippets.

@JosimarCamargo
JosimarCamargo / README.md
Last active January 27, 2025 07:20
How to setup a Postgres replication with docker and docker-compose

How to setup a Postgres replication with docker and docker-compose

How to use

To run you will need docker and docker-compose installed, and run the command docker-compose up on a folder within this file named docker-compose.yml(attached in this Gist)

How the PGAudit is enable, you will see the queries log and in which database is running which query, this is the main purpose of this Gist, along with have a database with replication working out of the box

To add user with just reading rights to access the database on slave replica

@mokhosh
mokhosh / laravel-deployment-vps.md
Last active December 29, 2023 20:20
Deploy Laravel to VPS (LEMP, Git, Mail, Redis, SSL, etc.)

A BETTER ALTERNATIVE

Use laravel-sheploy instead. It's more capabale and much eaiser to use.

Sign in and create git user

  • ssh root@IP
  • adduser git
  • usermod -aG sudo git

Set SSH keys

on local machine

@fuzunspm
fuzunspm / client-axios.js
Last active January 15, 2024 22:54
Nestjs File download
export default class http {
async download(endpoint) {
const token = this.loadToken();
const invoice = await axios({
url: `${this.NEST_APP_IP}/${endpoint}`,
method: 'GET',
responseType: 'blob',
headers: {
Authorization: `Bearer ${token}`
}}).then((response) => {
@ivanvermeyen
ivanvermeyen / HOWTO.md
Last active August 6, 2024 23:47
Multiple MySQL versions on MacOS with Homebrew

Update - 4 september 2020

Making multiple MySQL versions work with Homebrew was tricky to say the least. Fortunately there are 2 new easy ways that I learned of to achieve this.

DBngin app

As @4unkur and @henrytirla commented below, there is this extremely easy to use app called DBngin, which lets you setup multiple databases (not only MySQL) simultaneously using different ports:

https://dbngin.com/

@davidon
davidon / str2snake.php
Created November 3, 2018 22:24
PHP: Convert a string to snake case
/**
* Convert a string to snake case.
*
* @param string $value
* @param string $delimiter Default to underscore
*
* @return string
*/
public function snake(string $value, ?string $delimiter = null): string
{
@mul14
mul14 / encrypto.js
Created October 15, 2018 17:05
Node.js v10 - crypto.createDecipheriv()
// This is example of using crypto.createCipheriv(), because
// crypto.createCipher() is deprecated since Node.js v10
const crypto = require('crypto')
const encrypto = {
encrypt(text, password) {
const key = password.repeat(32).substr(0, 32)
const iv = password.repeat(16).substr(0, 16)
@danprince
danprince / README.md
Last active May 27, 2020 21:33
Types/Sequelize Scope Repro

Reproducing types/sequelize/120. Run npm test to see compile errors.

index.ts(14,3): error TS2345: Argument of type '{ scopes: { human: { slack_id: { $ne: string; }; }; }; }' is not assignable to parameter of type 'InitOptions'.
  Property 'sequelize' is missing in type '{ scopes: { human: { slack_id: { $ne: string; }; }; }; }'.
index.ts(25,1): error TS2684: The 'this' context of type 'typeof Model' is not assignable to method's 'this' of type '(new () => Model) & typeof Model'.
  Type 'typeof Model' is not assignable to type 'new () => Model'.
    Cannot assign an abstract constructor type to a non-abstract constructor type.
@EECOLOR
EECOLOR / firebaseSaveFile.js
Created August 30, 2017 11:11
Saves a file to Firebase storage with token authentication as if created from the console.
const storage = require('@google-cloud/storage')
const createUuid = require("uuid-v4")
const credentials = require('./test-firebase-credentials.json')
const firebaseProjectName = 'test'
const bucketName = `${firebaseProjectName}.appspot.com`
const bucket = storage({ credentials }).bucket(bucketName)
module.exports = firebaseSaveFile
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active April 16, 2025 20:29
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@tomysmile
tomysmile / mac-setup-redis.md
Last active April 11, 2025 18:01
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis