Skip to content

Instantly share code, notes, and snippets.

View wbond's full-sized avatar

Will Bond wbond

View GitHub Profile
@wbond
wbond / 50-cloud-init.yml
Last active March 3, 2021 08:33
RPi 4 Setup
# /etc/netplan/50-cloud-init.yml
network:
renderer: NetworkManager
ethernets:
eth0:
dhcp4: true
version: 2
@wbond
wbond / package_control.py
Last active August 14, 2020 18:42
How to monkey patch a Python module with code from another location
import importlib
import os
__pkg_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
'Packages',
'Package Control',
'package_control'
)
__file_path = os.path.join(__pkg_path, '__init__.py')

Completion Kinds

  • python: sublime.KIND_ID_AMBIGUOUS, .sublime-completions: "ambiguous"
  • python: sublime.KIND_ID_KEYWORD, .sublime-completions: "keyword"
  • python: sublime.KIND_ID_TYPE, .sublime-completions: "type"
  • python: sublime.KIND_ID_FUNCTION, .sublime-completions: "function"
  • python: sublime.KIND_ID_NAMESPACE, .sublime-completions: "namespace"
  • python: sublime.KIND_ID_NAVIGATION, .sublime-completions: "navigation"
  • python: sublime.KIND_ID_MARKUP, .sublime-completions: "markup"
  • python: sublime.KIND_ID_VARIABLE, .sublime-completions: "variable"
from Default.exec import ExecCommand
class MyFirstExecCommand(ExecCommand):
def finish(self, proc):
super().finish(proc)
errs = self.output_view.find_all_results()
if len(errs) == 0:
sublime.active_window().run_command('my_second_exec_command')
class MySecondExecCommand(ExecCommand):
from asn1crypto.csr import CertificationRequest
cr = CertificationRequest.load(der_bytes)
attrs = cr['certification_request_info']['attributes']
print(attrs.native)
if signed:
if value < 0:
bits_required = abs(value + 1).bit_length()
else:
bits_required = value.bit_length()
if bits_required % 8 == 0:
bits_required += 1
else:
bits_required = value.bit_length()
width = math.ceil(bits_required / 8) or 1
@wbond
wbond / YAML.yaml
Last active February 27, 2023 13:43
%YAML 1.2
# The MIT License (MIT)
#
# Copyright (c) 2015 FichteFoll <fichtefoll2@googlemail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
TrustedCertificate ::= SEQUENCE {
trust SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
reject [0] IMPLICIT SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
alias UTF8String OPTIONAL,
keyid OCTET STRING OPTIONAL,
other [1] IMPLICIT SEQUENCE OF AlgorithmIdentifier OPTIONAL
}
@wbond
wbond / anon.php
Created December 2, 2015 14:53
How PHP closures have to be created and how I wish they could also be created.
<?php
$conn = fsockopen('localhost', 8080);
$send = function($data) use ($conn) {
fwrite($conn, $data);
}
$send('Hello');
$send('World');
$send('\n');
@wbond
wbond / x509_type_name_and_value.py
Created October 20, 2015 04:30
X.509 Name TypeNameAndValue Decoding in Python
from asn1crypto import x509, pem
with open('path/to/my.crt', 'rb') as f:
data = f.read()
if pem.detect(data):
_, _, data = pem.unarmor(data)
cert = x509.Certificate.load(data)
for rdn in cert.subject.chosen:
for type_value in rdn:
type_name = type_value['type'].native