Skip to content

Instantly share code, notes, and snippets.

View leelu's full-sized avatar

Leeladharan Acharya leelu

View GitHub Profile
@leelu
leelu / listen.py
Created February 13, 2023 06:32 — forked from kissgyorgy/listen.py
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@leelu
leelu / create-vod-hls-gpu.sh
Created February 8, 2023 11:56 — forked from maitrungduc1410/create-vod-hls-gpu.sh
Bash scripts to create VOD HLS stream with ffmpeg using GPU
#!/usr/bin/env bash
START_TIME=$SECONDS
set -e
echo "-----START GENERATING HLS STREAM-----"
# Usage create-vod-hls-gpu.sh SOURCE_FILE [OUTPUT_NAME]
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1
# comment/add lines here to control which renditions would be created
renditions=(
@leelu
leelu / wget.sh
Created May 24, 2021 07:13 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@leelu
leelu / apache.conf
Created April 26, 2021 14:16 — forked from rambabusaravanan/apache.conf
SPA - Apache, Nginx Configuration for Single Page Application like React.js on a custom path
# To host on root path just use "<Location />" for http://mydomainname.in
# To host on non-root path use "<Location /myreactapp>" for http://mydomainname.in/mypath
# If non-root path, don't forgot to add "homepage": "/myreactapp" in your app's package.json
<VirtualHost *:80>
ServerName mydomainname.in
DirectoryIndex index.html
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
@leelu
leelu / mysql-5.7-master-slave-replication-centos-7.md
Created April 1, 2021 08:55
MySQL 5.7 Master-Slave Replication on CentOS 7

MySQL 5.7 Master-Slave Replication on CentOS 7

Install and configure MySQL 5.7 with master-slave replication. The benefits of this include high availability, backups, disaster recovery and reporting.

Install MySQL 5.7

Enable MySQL repository

yum localinstall -y https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
// attribution: http://stackoverflow.com/a/15281070/32453
// you can compile this with gcc [mingw or mingw-w64] and probably other compilers as well
#include <stdlib.h> // NULL
#include <stdbool.h> // false
#include <windows.h> // AttachConsole, CTRL_C_EVENT, etc.
#include <stdio.h> // printf
#include <strsafe.h>
void logLastError()
#!/bin/bash
ARCHIVEDIR='/var/lib/pgsql/wal_archive'
LAST_BACKUP=$(ls -lto ${ARCHIVEDIR})
FILE_LIST=$(pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}")
## TEST FIRST
pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}" | find -type f -mmin +30 | xargs ls -lh
@leelu
leelu / elasticache_backup.sh
Created September 24, 2018 15:01 — forked from luckyjajj/elasticache_backup.sh
Hacky AWS ElastiCache Hourly Backup Shell Script
#!/bin/bash
## Requires AWS CLI Tools
aws elasticache create-snapshot --cache-cluster-id redis-replica-1 --snapshot-name cg-backup-hourly-"$(date +"%Y-%m-%d-%H%M")"
if [ $(aws elasticache describe-snapshots --cache-cluster-id redis-replica-1 |grep SnapshotName | wc -l) = "8" ]; then
old_snapshot="$(aws elasticache describe-snapshots --cache-cluster-id redis-replica-1 |grep SnapshotName | head -1 | cut -d \" -f 4)"
aws elasticache delete-snapshot --snapshot-name $old_snapshot
fi
@leelu
leelu / gist:7b954fd7c2127eb9cc86625a11dde0cd
Created July 7, 2018 20:14 — forked from Ray33/gist:ba189a729d81babc99d7cef0fb6fbcd8
Amazon Elastic Network Adapter (ENA) on CentOS 7
sudo su
yum --enablerepo=extras install epel-release
yum -y install patch dkms kernel-devel perl
yum update
reboot
//TODO fetch latest ena_driver from: https://github.com/amzn/amzn-drivers/releases, this script is based on 1.5.3
cd /tmp