Skip to content

Instantly share code, notes, and snippets.

Will Bond wbond

Block or report user

Report or block wbond

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View myexec.py
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):
View csr_attributes.py
from asn1crypto.csr import CertificationRequest
cr = CertificationRequest.load(der_bytes)
attrs = cr['certification_request_info']['attributes']
print(attrs.native)
View int_to_bytes.py
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
View YAML.yaml
%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
View gist:9c026de123800e01e0c4
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 Dec 2, 2015
How PHP closures have to be created and how I wish they could also be created.
View anon.php
<?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 Oct 20, 2015
X.509 Name TypeNameAndValue Decoding in Python
View x509_type_name_and_value.py
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
View requests_logging.py
import logging
import http.client as http_client
http_client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
View repr.lua
function repr(data, level)
if not level then
level = 1
end
local data_type = type(data)
if data_type == 'table' then
if level == nil then
level = 1
@wbond
wbond / gist:d83e8e41f5ae2d51cc11
Created Jun 17, 2014
decrypt an encrypted procedure
View gist:d83e8e41f5ae2d51cc11
CREATE PROCEDURE dbo.sp__procedure$decrypt
(@procedure sysname = NULL, @revfl int = 1)
AS
SET NOCOUNT ON
IF @revfl = 1
BEGIN
PRINT 'CAUTION: THIS PROCEDURE DELETES AND REBUILDS THE ORIGINAL STORED
PROCEDURE.'
PRINT ' MAKE A BACKUP OF YOUR DATABASE BEFORE RUNNING THIS PROCEDURE.'
You can’t perform that action at this time.