techrobatics.com

Sysadmin Ex Machina

Browsing Posts in Programming

Here’s a short script to give you an idea of how to programmatically answer basic authentication prompts using python. #!/usr/bin/env python import urllib2, sys, re, base64 from urlparse import urlparse #base64string = base64.encodestring(‘%s:%s’ % (data['name'], data['pass']))[:-1] #req.add_header(“Authorization”, “Basic %s” % base64string) username = ‘some_userid’ password = ‘some_password’ theurl = ‘http://www.techrobatics.com/protected’ #realm = ‘REALM’ base64string = [...]

I wrote this little class to be able to convert in and out of all four temperature formats: #!/usr/bin/env python “”" My Rankines Convertor I am creating these routines to help convert all nonsense temperature systems into the only one that makes any real rational sense. Why does it make more sense than fahrenheit or [...]

This attractive bit of python gadgetry will allow you to auto-generate new python files in Komodo. I use it to create a new “daily notes” file each day of work. It contains the to-do, reminder, and technical notes of each day. from datetime import datetime import os, os.path import komodo def create_file_by_date(dd, prefix=None): parts = [...]