This is a story of trying to do the right thing… without reading all the instructions. I recently was setting up OpenVPN for my home network. The instructions are pretty strait forward. For those of you who are security conscious, there is even an option to drop elevated privileges in Linux. That sounds good, right? Well, what happens when you try to tear down the VPN connection, without elevated privileges?
Pro Tip: Moving Multiple Component Primitives in Altium Designer
Sometimes you have a design where you don’t want to make a new footprint, but need to move a certain track or via 10 mil one way… for 30 copies of the same footprint. Continue reading
Multithreading, Python and passed arguments
Recently I\’ve had a project that required precompiling the firmware for a device so that the end user could program the device, but not have the source code. We\’re not talking about a few versions of the code, but almost 1000. This is something that no person would want to do, especially since it would have to be redone every time the source code changes. Python to the rescue. It was simple enough to write a program that would copy the source code, change a bit of information in a header file, compile it and save the binary to the appropriate location. Controlling other programs is pretty easy with the subprocess module. That\’s great and all, but doing it single-threaded, that\’s so 90s. Python makes multithreading pretty simple using its multiprocessing library. The trick is not stepping on any toes when you do it.
Cleaning up filenames for transfer to windows
For those of you run multiple operating systems, you may have run across the problem where the filenames on one are not valid on the other. Specifically I\’ve had that problem when using NTFS filesystems between Linux and Windows. The NTFS3G drivers on Linux will allow characters in the file names that windows doesn\’t like. To solve this, I wrote a quick python script that will make the filenames windows acceptable. Enjoy.
windows_rename.py
#Copyright 2012 Chad Kidder
#Released under GPL v3.0
import os, sys, re, shutil
def SafeNames(location):
for root, dirs, files in os.walk(location):
for tfile in files:
NewFile = InvalidCharacters.sub("_",tfile)
if NewFile <> tfile:
shutil.move(os.path.join(root, tfile), os.path.join(root, NewFile))
print "%s -> %s" % (os.path.join(root, tfile), os.path.join(root, NewFile))
for tdir in dirs:
NewDir = InvalidCharacters.sub("_",tdir)
if NewDir <> tdir:
print "%s -> %s" % (os.path.join(root, tdir), os.path.join(root, NewDir))
shutil.move(os.path.join(root, tdir), os.path.join(root, NewDir))
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Please enter a directory to fix the file names on"
else:
InvalidCharacters = re.compile(r"[\\/?:*|\'\\"]")
for location in sys.argv[1:]:
SafeNames(location)
Using the Python HTMLParser library
When writing a script to download files off a site, I figured there was an easy python library to do that. Well, sort of. I chose to use the HTMLParser library. The documentation is not the best, so I thought I would add a bit of what I found. If I had to do it again, I might just use regular expressions to do it all.
Continue reading
Automating Dreamhost backups
We here at Curious System Solutions use dreamhost as our hosting provider. One of the nice things they give us is a nice, tidy, backup every month, if we ask for it. It may take a few days if you ask at the beginning of the month, and it is easy to forget to download. So, we have a handy python script that will check an imap4 email server to see if the backup is ready, and if so, download it. The script is designed to be a cron job that can be ran every night so you don\’t have to worry about remembering to download things.
Compact Emergency 12V DC Power Supply
This board was designed to be a good beginning board for someone to learn to solder on. There are a lot of amateur radio operators that originally got into the hobby as part of an emergency communications group (RACES, ARES, etc.). This board is designed to start them down the path to the… hardware side (cue evil laugh).
Fun with SQL or, I know it should do this…
Occasionally, one comes across a problem where using a relational database is the correct tool. For me that is very occasionally. Some things I recently (re)learned that I thought I would share are:
Continue reading
ATX Power Supply Breakout Board
How many of you have or know of someone who has an old computer just sitting in the closet gathering dust. How many of you would like to have a multiple output bench power supply? Do you need an extra +12V DC power supply for your CB, ham shack or office? What we have here is a 4\” x 6.3\” PCB that has all the standard connectors needed to take the output connectors from an ATX power supply and give you easy access to them.Continue reading
Automated Setup of Subversion Repository
I may be unique in this respect, but I like to keep individual subversion repositories for each project. To make life a little easier in setting up the repository, I have a handy little bash script that sets up the repository with the /branch /trunk and /tags directories. Continue reading