Skip to content

Instantly share code, notes, and snippets.

View cmouse's full-sized avatar

Aki Tuomi cmouse

View GitHub Profile
@cmouse
cmouse / motor.py
Created December 10, 2022 19:23
Simple 4 Phase UNL 2003 Stepper Motor Driver PCB controller script for Raspberry PI
#!/usr/bin/env python
## Written by Aki Tuomi 2022
# Released into public domain with NO WARRANTY
# Written for 4 Phase UNL 2003 Stepper Motor Driver PCB
##
# To use, update INx to match your setup
# Then choose steps_4 or steps_8 as steps (4 or 8 steps)
# You can use UP and DOWN arrow to adjust speed
@cmouse
cmouse / test-pkcs11.cc
Last active January 18, 2022 10:41
Test code for PKCS#11
/* This code is released to Public Domain by the Author
*
* Compile using c++ -I/usr/include/p11-kit-1 -o test-pkcs11 test-pkcs11.cc -lp11-kit
*
* Usage example: ./test-pkcs11 yubico 0 02 12345678
*/
#include "p11-kit/p11-kit.h"
#include "p11-kit/pin.h"
#include "p11-kit/pkcs11.h"
#include <memory>
@cmouse
cmouse / dovecot.conf
Created June 4, 2020 16:28
dovecot Dockerfile
## You should mount /etc/dovecot if you want to
## manage this file
mail_home=/srv/mail/%Lu
mail_location=sdbox:~/Mail
mail_uid=1000
mail_gid=1000
protocols = imap pop3 submission sieve lmtp
@cmouse
cmouse / dovemanual.py
Last active October 30, 2019 09:59
Get settings from dovecot documentation
from lxml import etree
import urllib.request
import urllib.parse
import sys
from html2text import html2text
def get_named_setting(name, url="https://doc.dovecot.org/settings/dovecot_core_settings/"):
f = urllib.request.urlopen(url)
parser = etree.HTMLParser()
tree = etree.parse(f, parser)
@cmouse
cmouse / dnsupdate.fcgi
Created October 21, 2019 11:15
FastCGI script to support dyndns from EdgeOS
#!/usr/bin/python3
from flup.server.fcgi import WSGIServer
import bottle
from bottle_log import LoggingPlugin
import json
import logging
import requests
logging.basicConfig(format='localhost - - [%(asctime)s] %(message)s', level=logg
#!/usr/bin/env python
import requests
import subprocess
import sys
PRIVATE_TOKEN="<redacted>"
def get_branch_head(repo, branch):
repo = repo.replace("/","%2f")
@cmouse
cmouse / sendchange.py
Created August 27, 2017 12:25
Sending a change to buildbot
#!/usr/bin/env python
import requests
import subprocess
import sys
PRIVATE_TOKEN="<removed>"
def get_branch_head(repo, branch):
repo = repo.replace("/","%2f")
@cmouse
cmouse / decrypt.rb
Last active April 11, 2023 10:23
Analyze / decrypt dovecot lib-dcrypt stream
This file is now in https://github.com/dovecot/tools/blob/main/dcrypt-decrypt.rb
@cmouse
cmouse / openswan-to-rsa.c
Created July 12, 2016 13:06
Convert OpenSwan key to RSA key
#include <stdio.h>
#include <openssl/rsa.h>
#include <openssl/bn.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
int main(void) {
BIGNUM *bn;
RSA *rsa = RSA_new();
bn = BN_new();
#!/usr/bin/env ruby
key = File.read("input.der").force_encoding('ascii-8bit')
# determine key size
File.open("ssl-parameters.dat", "wb") do |f|
f.write [4096, key.size].pack 'll'
f.write key
f.write [0].pack 'l'
end