Skip to content

Instantly share code, notes, and snippets.

@ledger123
ledger123 / revolut.pl
Created July 10, 2025 09:47
Revolut integration with SQL-Ledger
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
use Mojo::UserAgent;
use Crypt::X509;
use Crypt::JWT ':all';
use Crypt::PK::RSA;
use JSON::XS;
use HTML::Table;
use Data::Format::Pretty::JSON qw(format_pretty);
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
use DBIx::Simple;
use DBI;
use URI::Escape qw(uri_escape);
# Global database configuration
our %db_config = (
database => 'ledger28',
user => 'postgres',
@ledger123
ledger123 / paymentsimport.csv
Created March 18, 2025 08:23
Payments Import (Remove second line containing field names before processing)
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 9 columns, instead of 8 in line 4.
c2,c3,c4,c5,c6,c7,c8,c9,c10
customernumber,datepaid,AR_paid_1,AR,amount,description,source,memo,department
C-0081,17/02/2025,10100,11101,260000,,10500,online,SALES
C-0040,17/02/2025,10100,11101,165000,,10500,online,ACCOUNTS
C-0182,17/02/2025,10100,11101,171125,,10500,online
C-0152,17/02/2025,10100,11101,57341,,10100,cash
C-0059,17/02/2025,10100,11101,82489,,10500,online
C-0117,17/02/2025,10100,11101,159431,,10500,online
C-0037,17/02/2025,10100,11101,185601,,10100,cash
C-0164,17/02/2025,10100,11101,18488,,10100,cash
#!/usr/bin/perl
use strict;
use warnings;
my $username = 'postgres';
my $sql_file = 'dbchanges.sql';
my @databases = `psql -U $username -l -t | cut -d '|' -f 1`;
foreach my $db (@databases) {
@ledger123
ledger123 / pg_extract.sh
Created January 30, 2024 15:07 — forked from fowum/pg_extract.sh
Extract all databases (or one by name) from a sql file created by pg_dumpall
#!/bin/bash
# extract all postgres databases from a sql file created by pg_dumpall
# this script outputs one .sql file for each database in the original .sql file
# unless you pass the name of a database in the dump
if [ $# -lt 1 ]
then
echo "Usage: $0 <postgresql sql dump> [dbname]" >&2
exit 1
fi
@ledger123
ledger123 / res.html
Created September 7, 2023 13:33
Guest reservation form to post data to booking engine.
<form action="https://hotel4u.pk/marcopolomurree/rooms" method="GET" target="_blank" class="form-container">
<input type="date" name="checkin_date" id="datePicker" class="item" onfocus="this.showPicker()">
<!-- Remove the "nights" field -->
<input type="date" name="checkout_date" id="checkoutDatePicker" class="item" onfocus="this.showPicker()">
<select name="adults" id="adults" class="form-item">
<option value="1">1 Adult</option>
<option value="2">2 Adults</option>
<option value="3">3 Adults</option>
<option value="4">4 Adults</option>
<option value="5">5 Adults</option>
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $driver = "Pg";
my $database = "postgres";
my $dsn = "DBI:$driver:dbname=$database;host=localhost";
my $userid = "postgres";
@ledger123
ledger123 / res.pl
Last active September 6, 2023 01:25
Room availability check
use strict;
use warnings;
use DBIx::Simple;
sub is_room_available {
my ($room, $checkin_date, $checkout_date) = @_;
# Connect to the database
my $db = DBIx::Simple->connect("DBI:Pg:dbname=test1", 'postgres', '', { RaiseError => 1, AutoCommit => 1 })
or die "Failed to connect: $DBI::errstr";
@ledger123
ledger123 / generate_chart_file.pl
Last active January 22, 2024 16:27
Generate SQL statements from database
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my @tables = ( 'chart', 'curr', 'defaults' );
my $output_file = 'RMADE_DEU_Basiskontenplan-chart.sql';
my $db_name = 'ledger28';
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="x-apple-disable-message-reformatting">
<title>Ambiance Boutique Art Hotels</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;600&display=swap" rel="stylesheet">
</head>