Skip to content

Instantly share code, notes, and snippets.

@dmitrodem
dmitrodem / russianpost.py
Created February 10, 2019 14:11
Получить информацию о последнем статусе посылки с russianpost.ru
#!/usr/bin/env python3
import hashlib, base64, uuid
import requests, urllib
import urllib
import time, datetime
import json
import os
class RussianPostClient:
@dmitrodem
dmitrodem / mipt_board.user.js
Created February 21, 2019 13:19
юзерскрипт для zlo.rt.mipt.cc
// ==UserScript==
// @name MIPT board interactive
// @namespace Violentmonkey Scripts
// @match https://zlo.rt.mipt.cc/*
// @match https://board.rt.mipt.cc/*
// @grant none
// ==/UserScript==
'use strict';
function my_content(index) {
let container = document.querySelector('div[id*=d' + index + ']');
@dmitrodem
dmitrodem / synth.tcl
Created March 21, 2019 00:05
synth.tcl
Here is what I'm using:
common-setup.tcl:
Name of top-level design
set DESIGN_NAME "mips32"
# Set Design Path
set DESIGN_PATH [file normalize ~/cad/mips32]
# Aboslute path prefix variable for library/design data. Use this variable to
@dmitrodem
dmitrodem / vpi_udp.c
Created September 23, 2019 06:54
Verilog VPI example
#include <vpi_user.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/un.h>

Import an existing SSH key

To add the key, you need to convert the key format from the Privacy-Enhanced Mail (PEM)-encoded format that SSH uses to an OpenPGP-formatted certificate. The Monkeysphere Project provides a utility, pem2openpgp, that does this for you.

Unfortunately, making this newly added key a subkey is not a one-step process. This longer process is required because there is no clean way to delete the GPG key in the keyring that is just the SSH key. The keys are identified and operated on by keygrip, and the keygrip for a key is the same whether it is a subkey or a standalone key. Thankfully, you only need to work with the private keys, as you can regenerate the public keys at the end.

Also, if you have a newer style OpenSSH key, you'll have a couple of extra steps to convert that into something pem2openpgp can read. Unfortunately, as of version 0.41, Monkeysphere cannot read newer style OpenSSH keys. (Your key is a newer style key if the first line of the private key file is: `-----BEGI

@dmitrodem
dmitrodem / sdbin.py
Created December 4, 2019 02:12
Update 70mai firmware hash
#!/usr/bin/env python3
from hashlib import md5
import sys
import codecs
import argparse
import logging
logging.basicConfig(level = logging.DEBUG)
log = logging.getLogger("update_hash")
<pins>
<pin index="1">
<functions kind="shared" selector="x">
<function id="1">
<name>
</name>
</function>
</functions>
<variants>
#!/usr/bin/env python3
from ctypes import *
libc = CDLL("libc.so.6")
class dirent(Structure):
_fields_ = [
('d_ino', c_long),
('d_off', c_long),
('d_reclen', c_ushort),
=================================================================
==7480==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x6030000169c8 in thread T0
#0 0x7f4943014e4f in __interceptor_free (/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/libasan.so.5+0x10be4f)
#1 0x557bfad16b1b in ipp_free_values /tmp/cups/cups/ipp.c:6325
#2 0x557bfacf17cb in ippDelete /tmp/cups/cups/ipp.c:1756
#3 0x557bfab2d21c in cupsdWriteClient /tmp/cups/scheduler/client.c:2563
#4 0x557bfac62344 in cupsdDoSelect /tmp/cups/scheduler/select.c:485
#5 0x557bfab63028 in main /tmp/cups/scheduler/main.c:847
#6 0x7f4941dc8cfa in __libc_start_main (/lib64/libc.so.6+0x23cfa)
#7 0x557bfaafd259 in _start (/tmp/cups/scheduler/cupsd+0x418259)
@dmitrodem
dmitrodem / bluedio.py
Created October 28, 2020 14:49
Bluedio Headset control application
#!/usr/bin/env python3
import bluetooth
from enum import Enum
import threading
import time
import sys
import argparse
class BluedioPlayAuto(Enum):