Skip to content

Instantly share code, notes, and snippets.

@NegativeMjark
NegativeMjark / update-letsencrypt.sh
Created November 12, 2016 15:54
Update my lets encrypt certificate.
#! /bin/bash
set -eu
DATE="$(date +"%Y-%m-%d")"
HOST=negativecurvature.net
CERT="$HOST.$DATE.crt"
COMBINED="$HOST.$DATE.combined.crt"
WITHKEY="$HOST.$DATE.withkey.crt"
@NegativeMjark
NegativeMjark / encryption.html
Last active June 5, 2023 11:22
Encrypt, decrypt, and display an image.
<html>
<head>
<script>
function readFile(file, callback) {
var reader = new FileReader();
reader.addEventListener("load", function() {
callback(this.result);
});
reader.readAsArrayBuffer(file);
@NegativeMjark
NegativeMjark / trivialjson.py
Last active August 29, 2015 14:14
Trivial JSON encoder
OBJECT_CONSTANTS = {
True: '":true,"',
False: '":false,"',
None: '":null,"',
}
ARRAY_CONSTANTS = {
True: 'true,',
False: 'false,',
None: 'null,',
@NegativeMjark
NegativeMjark / bindto.py
Created December 24, 2014 11:03
Bind attributes using decorators and meta classes.
def bindto(target):
def set_attr(name, value):
if name == "__new__" and isinstance(target, type):
setattr(target, name, staticmethod(value))
else:
setattr(target, name, value)
def bind_class(cls, name, bases, members):
for key, value in members.items():
set_attr(key, value)
@NegativeMjark
NegativeMjark / identicon.py
Last active July 3, 2017 10:41
Identicon Generator Webapp
#! /usr/bin/env python
from flask import Flask, make_response
from io import BytesIO
from pydenticon import Generator
app = Flask(__name__)
foreground = [
"rgb(45,79,255)",
@NegativeMjark
NegativeMjark / ObjectModel.rst
Last active August 29, 2015 14:10
Notes on CPython

My Little Python

Everything in python is an object. All objects have a type. Most objects have an instance dictionary. Types can be constructed by calling type("name for type", (parents for type,), {instance dict for type}). Types have a method resolution order which is determined from their parents using http://en.wikipedia.org/wiki/C3_linearization. All operators in python can be overridden including the "." operator. So a.b is really finding a __getattribute__ in one of the types of a and calling it. However

Keybase proof

I hereby claim:

  • I am NegativeMjark on github.
  • I am mjark (https://keybase.io/mjark) on keybase.
  • I have a public key whose fingerprint is 7116 D774 56E7 45E9 F70A 936D 42A6 FB34 D5E6 90F7

To claim this, I am signing this object:

@NegativeMjark
NegativeMjark / .vimrc
Created August 24, 2014 09:05
Vim Config
:syn on
:set number
:set tabstop=8
:set softtabstop=4
:set expandtab
:set autoindent
:set guifont=Source\ Code\ Pro\ 9
:colorscheme koehler
:highlight Trailing ctermbg=red ctermfg=white guibg=#592929
:match Trailing /\s\+$\|\%80v.\+/