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
"""
A small utility that creates OCSP responses for testing for the web-eid-authtoken-validation-java library.
Run it as follows:
python -m venv venv
. venv/bin/activate
pip install asn1crypto
python ocsp.py
@mrts
mrts / CMakeLists.txt
Last active February 11, 2021 16:14
Print VCPKG OpenSSL path with CMake
# 1. Install VCPKG and the OpenSSL package
# 2. Run CMake: cmake -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake .
# 3. Run print-ssl-path target: cmake --build . --target print-ssl-path
project(PrintOpenSSLPath)
find_package(OpenSSL REQUIRED)
get_filename_component(SSL_PATH "${OPENSSL_CRYPTO_LIBRARY}" DIRECTORY)
get_filename_component(SSL_PATH "${SSL_PATH}/../bin" ABSOLUTE)
message(STATUS "SSL_PATH: ${SSL_PATH}")
@mrts
mrts / unblock-pin.sh
Created November 20, 2020 21:39
Unblock PIN with pkcs15-tool
pkcs15-tool --unblock-pin -a 01 --puk 12345678 --new-pin 1234
@mrts
mrts / nexus-maven-repo-delete-artifacts.py
Last active December 25, 2020 09:37
Nexus 3 Maven repo artifact deletion with Python
# See API docs at http://nexus-url/#admin/system/api
import requests
USERNAME = 'user'
PASSWORD = 'password'
NEXUS_BASE_URL = 'http://nexus-url/service/rest/beta'
REPOSITORY = 'some-project-snapshots'
GROUP_FILTER = 'com.some.group'
@mrts
mrts / markdown-to-slack.py
Last active March 28, 2025 21:48
Markdown to Slack
# Translates Markdown syntax to Slack, replaces:
#
# - hyphened lists with bullet symbols
# - double bold marker asterisks `**` with single asterisk `*`
# - headers `#` with bold marker asterisks `*`
#
# Run with
#
# python markdown-to-slack.py filename.md
#
@mrts
mrts / read-esteid-firstname.py
Created August 23, 2018 11:56
Read cardholder name from Estonian ID card using the Python smart card framework pyscard
# Prerequisites:
# sudo apt install build-essential swig python-dev
# virtualenv venv
# source venv/bin/activate
# pip install pyscard
from __future__ import print_function
from smartcard.System import readers
SELECT_EE_FOLDER = [0x00, 0xA4, 0x01, 0x0C, 0x02, 0xEE, 0xEE]
@mrts
mrts / index.html
Last active June 12, 2021 11:17
Example of Gitgraph.js usage
<!DOCTYPE html>
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<p style="margin: 20px"></p>
<canvas id="gitGraph" style="padding: 20px"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.js"></script>
@mrts
mrts / calculate_reference_number.py
Last active May 21, 2018 20:21
Estonian bank invoice reference number calculator
"""
See https://www.pangaliit.ee/settlements-and-standards/reference-number-of-the-invoice/check-digit-calculator-of-domestic-account-number
"""
def calculate_reference_number(n):
"""
Calculates Estonian bank invoice reference number.
Argument:
n - a string of numbers, e.g. invoice number or any other identifier chosen by the invoicer.
@mrts
mrts / merit-api-update-customer-email-django.py
Last active May 6, 2018 20:22
Update customer in Merit from Python with Merit API
import hmac
import datetime
import json
from base64 import b64encode
from urllib.parse import urlencode
import requests
from customers.models import Customer
@mrts
mrts / merit-api-nodejs-get-purchases.js
Last active May 6, 2018 15:31
Merit API getpurchorders request example with saving to CSV
// Merit API spec:
// https://www.merit.ee/juhend/muud/Merit_Aktiva_API_specification.pdf
// Install required packages:
// npm install crypto-js moment request request-debug
const CryptoJS = require('crypto-js');
const moment = require('moment');
const axios = require('axios')
const json2csv = require('json2csv').parse;