Skip to content

Instantly share code, notes, and snippets.

View adiroiban's full-sized avatar
🇺🇦
Slava Ukraini!

Adi Roiban adiroiban

🇺🇦
Slava Ukraini!
View GitHub Profile
@adiroiban
adiroiban / i18n_subsites.py
Created March 23, 2022 10:35
My fork for pelican i18n sub-sites
"""i18n_subsites plugin creates i18n-ized subsites of the default site
This plugin is designed for Pelican 3.4 and later
"""
import os
import six
import logging
import posixpath
@adiroiban
adiroiban / 1_radius_chap.py
Last active July 8, 2022 11:09
Python RADIUS client CHAP / MS-CHAP-v1 / MS-CHAP-v2
# Code under public domain.
"""
Authentication based on a remote RADIUS server.
"""
from __future__ import absolute_import, unicode_literals
import contextlib
import os
import socket
import struct
import hashlib
@adiroiban
adiroiban / lets_encrypt.py
Created July 18, 2021 11:43
chevah txacme
# Copyright (c) 2018 Adi Roiban.
# See LICENSE for details.
"""
Act as ACME client to generate and renew SSL certificates from Let's Encrypt.
The certificates are then set to each SSL service and the service
is restarted if required.
The task of updating the service configuration is done by the
certificate storage.
@adiroiban
adiroiban / pp2.py
Created July 6, 2021 19:02
ProxyProtocol v2 wrapper
"""
Proxy protocol support.
Code based on https://github.com/icgood/proxy-protocol
http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
"""
from __future__ import unicode_literals
import socket
import struct
13:15 $ git alias
ae = !/opt/sublime_text/sublime_text ~/.gitconfig
b = branch
st = status -s
ci = commit -a
ca = commit -a --amend --no-edit
push = push --tags
db = branch -d
dr = push origin --delete
rb = branch -m
@adiroiban
adiroiban / gist:288b7f55553cd43bf02050d911b20575
Created April 20, 2021 12:31
pypy-3.7-alldeps-nocov-posix twisted failure on 2eeaacb
https://github.com/twisted/twisted/runs/2372418216#step:9:18222
FAIL]
Traceback (most recent call last):
File "/home/runner/work/twisted/twisted/.tox/alldeps-nocov-posix/site-packages/twisted/words/test/test_irc.py", line 940, in test_ERRMSG
self.assertEqualBufferValue(reply, errReply)
File "/home/runner/work/twisted/twisted/.tox/alldeps-nocov-posix/site-packages/twisted/words/test/test_irc.py", line 38, in assertEqualBufferValue
self.assertEqual(bufferValue, val)
File "/home/runner/work/twisted/twisted/.tox/alldeps-nocov-posix/site-packages/twisted/trial/_synctest.py", line 424, in assertEqual
@adiroiban
adiroiban / aysnc_fs.py
Created March 12, 2021 14:17
Raw export of async FS API
class IResourceRunnable(IRunnable):
"""
A resource which acts as a client to provide the end-user functionality.
"""
avatar = Attribute('The client/credentials for this resource.')
def heartbeat():
"""
Called to signal that a command was requested for the location.
@adiroiban
adiroiban / pyradius_timeout.py
Created February 25, 2021 14:37
pyradius - no timeout error for invalid shared secret
class ChevahRadius(radius.Radius):
"""
Patched version while the upstream project is re-enabled.
"""
def send_message(self, message):
"""
Raise VerificationError if we got a response but couldn't be validated,
instead of raising the same error as timeout.
"""
@adiroiban
adiroiban / putty_ppk_read.py
Created December 16, 2020 16:38
Read putty private key in Python
# Code extracted from my private project, but released here as public code.
@classmethod
def _fromString_PRIVATE_PUTTY(cls, data, passphrase):
"""
Read a private Putty key.
Format is:
PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc | none
Comment: SINGLE_LINE_COMMENT
@adiroiban
adiroiban / twisted_proto_helpers_fork.py
Created December 11, 2020 16:41
Some twisted proto helpers
# Copyright (c) 2012 Adi Roiban.
# See LICENSE for details.
"""
Protocol to help with tests.
This comes in addition to standard twisted.test.proto_helpers
"""
from io import BytesIO
from StringIO import StringIO