Oct 232015

I was trying to set up a fail2ban jail for wordpress inside a FreeBSD jail, but I just couldn’t get the rules to match.  The fail2ban instance was running on the host machine, checking a log inside the jail.  Turns out the time zone in the jail was incorrect, and fail2ban was not matching log entries because the time was different.

You may need to restart processes after this – I restarted both syslogd and Apache in the jail.

May 102015

I’ve decided that I want to build a repeater controller using an Arduino. I’ve been wanting to learn Arduino for a while, and this seems like a great excuse.  There are a lot of great repeater controllers out there already – I am a big fan of the SCOM 7330 – but they’re pricey, and this is ham radio.  We’re supposed to build stuff and experiment!

Continue reading »

Sep 262012

If you are running a transparent HTTP proxy on your network, you may have trouble with running Internet Recovery and Apple Hardware Test on Macs that support it.  You’ll see a “-4403D” or “-4403F” error.  For some reason, Apple’s servers return a 403 when they see the “via” header that many proxy servers send.  Here’s the configuration I used in Squid to turn off that header.  I also disabled the “forwarded-for” header – essentially, this makes it impossible for servers to determine that the request is coming through a proxy server:

# Be more anonymous
forwarded_for transparent
via off
visible_hostname proxy.local
httpd_suppress_version_string on

Aug 112012

I’ve been trying to install Mountain Lion in as a guest in Parallels 7, and I kept getting stuck at the initial grey Apple logo.

To fix it, I just changed the number of CPUs to 2, and it booted right up.  Other documents I’ve seen have indicated that you need to increase the video memory.  I did not need to do that, but it would probably help with performance.

Aug 032012


Eclipse Juno looks terrible in Linux Mint 13 with the MATE desktop environment. Here’s an example of part of the screen:

Everything is big and bulky, the tool bar’s style doesn’t really match the theme’s style.

Here are the steps I’ve taken so far to correct this:

  • Create a file called gtkrc, I’ve created one in my ~/eclipse directory:
    gtk-color-scheme = "selected_text_color:#000000"
    style "compact"
      font_name="Liberation Sans,Sans Regular 8"
      text[SELECTED] = @selected_text_color
    class "GtkWidget" style "compact"
    style "compact2"
    class "GtkButton" style "compact2"
    class "GtkToolbar" style "compact2"
    class "GtkPaned" style "compact2"
  • Next, in Eclipse, go to Window -> Preferences -> General -> Appearance, and under Theme, make sure GTK is selected.
  • Run eclipse like this:
    GTK2_RC_FILES=$GTK2_RC_FILES:~/eclipse/gtkrc ~/eclipse/eclipse

This ought to improve it a bit:

More to come as I figure out how to further improve this.





May 252012

I can’t believe it’s taken me this long to learn this: Python’s default argument values are only evaluated once during runtime. I’ve never encountered this before because I don’t use default arguments very often, and when I do, it’s often to set something to a static value.

Today, I encountered a function definition where I wanted to default an argument to the current date/time:

def do_something(self, entry, date_time = datetime.datetime.now()):

Every time I ran the function, the value of date_time was the same: Whatever the date/time was when the method first ran. So, instead, I did something like this:

def do_something(self, entry, date_time = None):
    if date_time is None:
        date_time = datetime.datetime.now()

This is actually mentioned in the Python documentation.

May 252012

Install Visual Studio 2008 SP1 Express Edition.

Go to the command prompt.

First, I had to set the following variable:

C:>set VS90COMNTOOLS=C:Program FilesMicrosoft Visual Studio 9.0Common7Tools

Note the trailing backslash – that needs to be there. The value must also NOT be in quotes.

C:>cd "Program FilesMicrosoft Visual Studio 9.0vcbin"
C:Program FilesMicrosoft Visual Studio 9.0VCbin>vcvars32
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

Then, from your PyCrypto directory, run:

python setup.py install

And it should install with no problem.

May 032012

Because Python isn’t strongly typed, sometimes PyDev doesn’t know what type a variable is – and therefore it cannot give you accurate code completions. Here’s how to make that better.

In simpler situations, PyDev works very well. For example:

emp = Employee()

Typing ’emp.’ will get you a good autocomplete.

Now, let’s say you have something like this:

emp = something.find_employee("dave")

Then ’emp.’ won’t get you anything – PyDev doesn’t necessarily know what type is being returned.

If you use python’s assert method:

emp = something.find_employee("dave")
assert isinstance(emp, Employee)

PyDev now knows what type the variable is, and you’ll get more effective code completions.

When running in production, you can pass the “-O” flag to the interpreter, and it will ignore the assert statements.

Nov 182011

I needed to return all the members of an object as an XML document in Python. I used the ElementTree library to do this.

The class in question is pretty basic: It has a constructor, member variables, getters and setters for the member variables, and now this new function.

Every Python class has a built-in __dict__ member, which is a dictionary ({}) of key/value pairs for all of the member variables, so I use that to get all of the variables to add to the ElementTree.

This function returns an xml.etree.ElementTree.Element object, which can be turned into a string if needed by using ElementTree’s tostring() method.

def getXML(self):
    """ Returns an XML representation of the object """
    topElem = Element("item")
    for key in self.__dict__.keys():
        elem = SubElement(topElem, key)
        elem.text = str(self.__dict__[key])
    return topElem
Nov 162011

Often times, in your Squid proxy, you may have a redirector configured – such as SquidGuard:

redirect_program /usr/local/bin/squidGuard -c /usr/local/etc/squid/squidGuard.conf

I ran into a problem tonight with my Roku box where SquidGuard was seeing Roku’s NetFlix access as a security threat.  So, to make Squid bypass the redirector, add an ACL and a redirector-access rule:

acl netflix dstdomain .netflix.com
redirector_access deny netflix

There you have it – any requests to *.netflix.com will skip the redirector.