Skip to content

Instantly share code, notes, and snippets.

@JonasPf
JonasPf / gist:9461819
Last active August 29, 2015 13:57
Create distinct colours
#
# Creates a html page with a list of distinct looking colours for graphs, etc.
# Algorithm from: http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
#
# Jonas Pfannschmidt
from colorsys import hsv_to_rgb
golden_ratio_conjugate = 0.618033988749895
alert('I am evil');
@JonasPf
JonasPf / customcontrol.py
Created July 14, 2014 22:20
Custom wxPython control
import wx
class CustomPanel(wx.PyPanel):
def __init__(self, parent):
wx.PyPanel.__init__(self, parent)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
@JonasPf
JonasPf / writebmp.py
Created July 15, 2014 11:55
wxPython: Create and save bitmap
w = 500
h = 300
bmp = wx.EmptyBitmap(w, h)
dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.SetBackground(wx.Brush('black'))
dc.Clear()
dc.SetBrush(wx.Brush('green'))
@JonasPf
JonasPf / menus.py
Created April 8, 2013 20:15
A few simple methods to create interactive console applications with menus, prompts for text, date, boolean etc.
"""
menus.py
Version: 0.5
A few simple methods to create interactive console applications. See the example at the bottom of this file.
Tested on Python 2.7 and Windows 7.
Copyright (c) 2013, Jonas Pfannschmidt
Licensed under the MIT license http://www.opensource.org/licenses/mit-license.php
@JonasPf
JonasPf / automate.py
Created April 9, 2013 20:29
Collection of functions and classes I use to automate console applications. Tested on Python 2.7 and Windows 7.
import os
import re
import sys
import zipfile
import shutil
import subprocess
import time
import threading
import Queue
@JonasPf
JonasPf / list_backups.py
Created March 22, 2016 13:51
List openstack freezer backups with datetime and size
import subprocess
import datetime
import re
import sys
backups = subprocess.check_output(['swift', 'list', sys.argv[1]]).splitlines()
width = None
total = 0
@JonasPf
JonasPf / hex2base58check.py
Created February 8, 2017 20:57
Bitcoin hex address to base58check
import binascii
import base58
import sys
string = sys.argv[1]
hex_values = binascii.unhexlify(string)
print(base58.b58encode_check(hex_values))
import json
import subprocess
import os
from collections import namedtuple
from tempfile import NamedTemporaryFile
from ansible.parsing.dataloader import DataLoader
from ansible.vars import VariableManager
from ansible.inventory import Inventory
from ansible.playbook.play import Play
Verifying my Blockstack ID is secured with the address 1GPb42kqRpLpUDG2kAtwzRXDsjFYVmTtGN https://explorer.blockstack.org/address/1GPb42kqRpLpUDG2kAtwzRXDsjFYVmTtGN