Skip to content

Instantly share code, notes, and snippets.

View leancode's full-sized avatar

Dom leancode

View GitHub Profile
@mrpeardotnet
mrpeardotnet / PVE-host-backup.md
Created December 17, 2019 18:03
Proxmox PVE Host Config Backup Script

Proxmox PVE Host Config Backup Script

This script can be used to backup essential configuration files from the Proxmox Virtual Enivronment (PVE) host.

The script will create backups using tar with specified backup prefix and date and time stamp in the file name. Script will also delete backups that are older then number of days specified.

Create backup script file

To create backup script that will be executed every day we can create backup script in /etc/cron.daily/ folder. We need to make it writeable by root (creator) only, but readable and executable by everyone:

touch /etc/cron.daily/pvehost-backup
CREATE EXTENSION pgcrypto;
CREATE OR REPLACE FUNCTION totp(key BYTEA, clock_offset INT DEFAULT 0) RETURNS INT AS $$
DECLARE
c BYTEA := '\x000000000' || TO_HEX(FLOOR(EXTRACT(EPOCH FROM NOW()) / 30)::INT + clock_offset);
mac BYTEA := HMAC(c, key, 'sha1');
trunc_offset INT := GET_BYTE(mac, 19) % 16;
result INT := SUBSTRING(SET_BIT(SUBSTRING(mac FROM 1 + trunc_offset FOR 4), 7, 0)::TEXT, 2)::BIT(32)::INT % 1000000;
BEGIN
RETURN result;
END;
@kevinski303
kevinski303 / mcrypt_on_php7.3_.txt
Last active March 3, 2021 23:44
php-mcrypt on debian 10 & php 7.3 apache
#
# The php-mcrypt extension is depricated and therefore was removed from the apt repository.
# As of writing this, on php7.3 there is currently no other way to install mcrypt without downgrading the php version
# except for compiling it locally.
#
###
#
# 1; Install the php-dev version and all the used tools to compile the extension
@sjelfull
sjelfull / Pushover+UptimeRobot.php
Created November 29, 2016 14:54
Use Pushover and a webhook from Uptime Robot to send notifications to your phone
<?php
require __DIR__ . '/vendor/autoload.php';
use Sly\PushOver\Model\Push;
use Sly\PushOver\PushManager;
if (!isset($_GET['key']) || $_GET['key'] !== 'KEY') {
die('No key');
}
$monitorFriendlyName = $_GET['monitorFriendlyName'];
@scottious
scottious / gist:0d99ea77daa041b28929
Created November 10, 2014 00:39
__git_ps1 command not found issue.

I've been having an issue with the following error appear in the prompt after upgrading to Yosemite. The solution was to source the git bash completion and prompt files from a local copy.

    curl -o ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
    curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

Then in:

    vi ~/bash_profile

Add:

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 19, 2025 09:28
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'