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 / 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 April 22, 2024 11:04
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;
ack-grep __unicode --ignore-dir=venv -l | xargs sed -i 's/__unicode/__str/g'
@mrts
mrts / merit-api-glbatch-request.js
Last active April 1, 2018 10:40
glbatch request with Merit API in Node.js
// See API spec here:
// https://www.merit.ee/juhend/muud/Merit_Aktiva_API_specification.pdf
var CryptoJS = require('crypto-js');
var request = require('request');
require('request-debug')(request);
var moment = require('moment');
var API_KEY = '...';
var API_ID = '...';
@mrts
mrts / add-on-delete-to-models.sh
Last active December 30, 2017 16:09
Add on_delete=models.CASCADE to Django models automatically (Django 2.0 migration)
find . -name models.py | xargs sed -i 's/\(ForeignKey(\w\+\)/\1, on_delete=models.CASCADE/; s/\(OneToOneField(\w\+\)/\1, on_delete=models.CASCADE/'