Skip to content

Instantly share code, notes, and snippets.

View mrts's full-sized avatar

Mart Sõmermaa mrts

  • Tallinn, Estonia (EET, UTC +2 hours)
View GitHub Profile
@mrts
mrts / test-string-reserve-impact-for-ostringstream.cpp
Created February 20, 2025 17:54
Determine whether manually reserving capacity in a std::string reduces memory usage when that string is later moved into a std::ostringstream.
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <random>
using byte = unsigned char;
using byte_vector = std::vector<byte>;
@mrts
mrts / README.md
Last active November 24, 2024 13:07
A Python script that interacts with the Merit API to download invoice attachments, check invoice payments and validate invoice line item prices based on a list of invoice numbers provided via a file.

Merit invoice manager

Features

  • Download attachments: fetch and save invoice attachment PDFs.
  • Check payments: retrieve and display the payment status of invoices.
  • Check line item price: validate line item prices against a specified amount.

Requirements

@mrts
mrts / e-arveldaja-api-usage-example.py
Created October 29, 2024 21:41
E-arveldaja API usage example in Python. See https://abiinfo.rik.ee/en/node/302 for docs.
import requests
import json
import hmac
import hashlib
import base64
from datetime import datetime
API_KEY_PUBLIC_VALUE = 'aWQ9OTI3NDMwNWZhYjQ3NDgzNzg0NTkwNTUyNzU5MGUwZGQmZGlnZXN0PWZlOTUxMDc0MmFjMWVhZjZlOThmZTZlMWJkMTllNjU3OWY4NGNkOTU4MzE4ZmM1YmEwZjI4NDUxYjEwZDY4MzI='
API_KEY_ID = '9274305fab474837845905527590e0dd'
API_KEY_PASSWORD = '28198cf21d8a4f6fa33fc07bc87bc92c'
@mrts
mrts / merit-api-get-customer-emails.py
Created December 24, 2023 12:10
Get customer emails from Merit using Merit API
import hmac
import datetime
import json
from base64 import b64encode
from urllib.parse import urlencode
import requests
API_KEY = b'...'
API_ID = '...'
@mrts
mrts / maven-deploy-to-gitlab.sh
Created April 11, 2023 18:02
Deploy a Maven package to GitLab Packages
cat << 'EOF' > gitlab-mvn-settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>gitlab</id>
<configuration>
<httpHeaders>
<property>
<name>Deploy-Token</name>
@mrts
mrts / add-copyright-licence-header-from-git-commit-authors.py
Last active January 15, 2023 21:17
Add copyright license headers with author information from Git commits to source code files
@mrts
mrts / App.vue
Last active November 3, 2022 22:04
A simple app for creating slide presentations with Vue.js
<script setup lang="ts">
import { $ref } from "vue/macros";
import { onMounted, onUnmounted } from "vue";
import { SLIDE_TEXTS } from "./assets/slides/slideTexts";
import PresentationSlide from "./components/PresentationSlide.vue";
// Width of the slide images in pixels, change this if the images are of different width
const IMAGE_WIDTH_PX = 1024;
const MAX_INDEX = Object.keys(SLIDE_TEXTS).length;
@mrts
mrts / list-digitalocean-spaces-content.py
Created June 25, 2022 17:42
List all DigitalOcean Spaces files with Python
import boto3
ENDPOINT_URL = 'https://fra1.digitaloceanspaces.com'
SPACE = "space-name"
REGION = "FRA1"
ACCESS_KEY_ID = "..."
SECRET_ACCESS_KEY = "..."
def main():
session = boto3.session.Session()
@mrts
mrts / password-permutations.py
Created April 26, 2022 18:00
Recover KeePass password that was entered with a typo with John the Ripper.
"""
Generate wordlist for recovering a password that was entered with a typo.
Assume the password consists of three elements of random words generated by gpw,
separated by punctuation marks and numbers.
python password-permutations.py > passwords.txt
sudo snap install john-the-ripper
john-the-ripper.keepass2john Database.kdbx > passwordhash.txt
john-the-ripper --wordlist=passwords.txt passwordhash.txt
"""
@mrts
mrts / cypress-proxy.py
Last active April 26, 2022 20:19
A simple Python HTTP proxy that forwards all requests to download.cypress.io to enable Cypress download from NPM behind a Nexus proxy.
"""
A simple Python HTTP proxy that forwards all requests to download.cypress.io
to enable Cypress download from NPM behind a Nexus proxy.
This is to work around Nexus proxy limitations, see
- https://issues.sonatype.org/browse/NEXUS-22887 and
- https://issues.sonatype.org/browse/NEXUS-22889.
Requires Python 3.