Monday, July 25, 2011

Politics: Debt and Destruction

Some seriously perverted stuff going on.

What is "Government Revenue"?

There are a number of definitions of "revenue", but I believe they are misleading when used in the government. Because the government concurrently increase revenue and debt when borrowing (or printing) money, revenues can be grossly inflated (at a rate proportionate to that of the debt). I also don't believe they "earned" that money, as it is all either taxes or loans, but that's subjective (you could argue that taxes, at least, are "earned").

How can you put some "savings" on the books?

From the article: "Boehner ridiculed the $1 trillion in war savings as gimmicky, but in fact, they were contained in the budget the House passed earlier in the year." ..."$1 trillion in war savings", "in the budget"? It's not tangible, for one, and it's money you had already; you can't add it to what you have already, because it IS what you have already. So, tell me again, how did that end up in the budget? Somebody didn't pay attention in math class....

We need to cut spending...period.

No amount of spending (by the government) will reduce the debt (if they continue to borrow in order to perform said spending). If we want to actually reduce the debt, then we'll need to sell more products to other countries, and pay off our debts (to increase the worth of our dollar). In order to do that (make products and sell them), businesses and individuals need money, and that money needs to be worth something. Government taxation isn't helping the former in that regard, and further government loans and money printed by the government isn't helping the latter (and is, thus, counterproductive for the former)

Long story short

There is a simple solution to our problem: Cut spending, cut taxes, increase exports.

Monday, July 18, 2011

Pipes (aka, Pipe Dream), now for Python too!

Ah, the classic game, Pipes. You know, the one where you arrange pipes on a grid and try to reach the goal while creating as long a chain as possible? Yeah, that game.

I've played around with the logic a bit in Python, and came up with this. It's not a complete game yet, obviously, but I've got the flow logic down.


Stuff needed in order to be considered "complete":

  • Set up input (and a queue of pipes)
  • Move from text to some other rendering method (probably GL, via pygame or some such Looking like Gtk+; Partially complete.)
  • Maybe, convert to multiprocessing (Not as easy as I thought, but done)


Of course, the next step after "completion" is improvement...

  • Implement levels (with larger maps and faster flow rates)
  • Blocks (obstacles) to put a wrench in your design
  • etc. (feel free to make suggestions in the comments)
...but let's not get ahead of ourselves. ;-)

Monday, June 13, 2011

Python Classes and XML Nodes

I know...I just keep doing stuff that others have already done. But I thought it was interesting, and that's all that mattered; never mind that using the end product would end up being more work than just writing XML by hand (except for the--not so?--rare case where you repeat the same element many times over), my idea was brilliant! ;-)

First thing's first, the code:

from random import randint
from collections import OrderedDict as orddict

class Node(object):
    def __init__(self, tag, type=None, key=None, text=None, **kwargs):
        """Base class for other parts of an (x)html document

            tag  : The tag that will be used for this node

            type : The node type (currently only None or 'textnode' are used

            key  : The key that is used in the OrderedDict; if unspecified,
                 will try to get the value from the attributes value (a dict)
                 in kwargs. If id is not present in attributes, a random number
                 will be generated instead.

            text : The text of a 'textnode' type Node. Otherwise unused.

            **kwargs : A dict containing one of these keys:
                'attributes' : attributes which will be added to the tag (dict)
                all others   : currently unused

        Node Types:
            None : The default; nothing special.
            'textnode' : only contains text, may not have any children
        self.children = orddict()
        self.tag = tag
        self.type = type

        if key != None:
            self.key = key
            self.key = randint(1, 2**32)

        if type != 'textnode':
            for arg in kwargs:
                if arg == 'attributes':
                    self.attributes = kwargs[arg]
                #elif arg ==
            if text is not None:
                self.text = text
                self.text = ""

    def create_child(self, tag, type=None, key=None, **kwargs):
        """Append a Node to self.children with the given...stuff"""
        if self.type == 'textnode':
            raise NodeTypeError('Node type "%s" cannot contain children' %
            element = Node(tag, type, key, **kwargs)
            self.children[element.key] = element
            return element.key
            # isinstance(element.key, (int, long))

    def append_child(self, node):
        if isinstance(node, Node):
            while node.key in self.children.keys():
                #print "'%s' already exists, trying" % (node.key),
                node.key = randint(1, 2**32)
                print node.key
            self.children[node.key] = node
            #print 'Success!'

    def get_tree(self, debug=False, depth=0):
            Return a string representing a Node tree
            with this Node as the tree root
        if self.type == 'textnode':
            node = self.text + "\n"
            node = '<%s' % (self.tag)
            if hasattr(self, 'attributes'):
                for attrib in self.attributes.iterkeys():
                    if self.attributes[attrib] is not None:
                        node += ' %s="%s"' % (attrib, str(self.attributes[attrib]))
                        node += ' %s="%s"' % (attrib)
            if len(self.children) > 0:
                node += '>\n'
                for child in self.children.iterkeys():
                    node += self.children[child].get_tree(debug=debug, depth=depth + 1)
                node += '%s\n' % (self.tag)
                node += ' />\n'

        if debug == True and depth == 0:
            print node
        return node

class NodeTypeError(Exception):
    """Raised when an attempt to create a child on a parent
    who doesn't support children occurs."""

Yes, it's not that pretty, but it does the job. Ideally, you might build some framework around this, or maybe you want to take it and make chunks of a page which will be reused in different areas of a page. Regardless of what you want to do, you likely can do it with this. The flexibility of Python classes (which I am just now discovering for myself) is quite useful: At first glance, you might think this class is rather useless--that couldn't be more wrong; throw in a few properties (or modify the get_tree method to accept arbitrary kwargs) and intuitive templating is just around the corner.

The breakdown

I think it's decently documented, but in case you're still finding it hard to follow, here's how it goes:

  • You create an instance of Node (say, html)
    • This is your root node of either a node tree or tree fragment
  • You create children by one of two methods:
    • The create_child method, which creates another Node instance and appends it to the parent Node's children property
    • Append a Node instance, which may or may not have children, to a parent Node's children property with the parent's append_child method (preferred) or manually
  • Profit!!!

Other Thoughts

I imagine someone has already done this (or something very similar); I would be very surprised to learn otherwise. However, I figure it couldn't hurt to put this out there anyway, for those who may not have thought of this, but could do a much better job than I. Feel free to tastefully mention other projects with similar intent in a comment, or criticize my poor understanding of the Python language (well thought out corrections to common mistakes are appreciated).
As for the're free to do anything you like to it (meaning you may copy it, paste it, butcher it, turn it into some horrible monster, create a masterpiece, and/or call it your own). I only ask (not require) that you mention me where ever you see fit. Thanks!

Tuesday, May 3, 2011

I dream of...well, nothing; but that's not the point!

I have a dream. A dream of a perfect world. A world where all e-mail clients handle replies and threads perfectly. A world where there is no top or bottom-posting, but where the user decides where to put the message body. A world where the client understands relationships between messages and can use hints--hints from the reply--to associate parts of a reply with it's parent message.

I have a, to make it reality!

Wednesday, August 4, 2010

Chrome Extension: Minimum Font

Minimum Font is an extension which I created for Google Chrome (and Chromium, the open-source bit of Chrome) in light of the fact that there is no way to set the minimum font size for Web sites in Chrome. Of course, after making it I discovered that there is a way, but you must edit a configuration file (which some or most users won't want to deal with); there is also an issue filed on the Chromium bug-tracker, for those who are interested in seeing what's being done (Only useful comments, please, and star the issue if you would like to have updates mailed to you or to show your support).

I'm still maintaining the extension, so if you encounter any pages which the extension doesn't work on, or you have a fix for an issue you've encountered, please leave a comment here or on the extension's gallery page and I'll see what I can do to fix it.

Currently, the font size for <body>, <div>, <font>, <span>, <pre>, <p>, <a>, <h1>, <h2>, <h3>, <h4>, <h5>, <legend>, <label>, <td>, and <th> tags are checked. Additionally, you may separately choose the size of <small> and <textarea> elements, and enable or disable their minimum setting if you like, as well as disable or enable Minimum Font on individual sub-domains by clicking on the pageaction.

Random notes:

  • The changelog is on the (developer) website.
  • Extensions don't work in the gallery; as such, you'll have to go to another site to see it work.
  • I've set what I think are sane defaults, but it's best to go into the extension's options page and customize the settings to your liking.

Monday, September 21, 2009 "Paint it Blue!" Userstyle

I haven't posted in a while, and I thought I should write something, so here I go... (changes and links at end of post)

A while back (a year or two ago, I guess) I created a Userstyle called " - Paint it Blue!" for the Firefox extension, Stylish (see also the link at the end of this post). The style simply changes a few images for ones that I colored blue, and changes some text to better match the blue color. It was a pretty good style (at least in my opinion), but I hadn't been maintaining it for a while and had since changed their site design--effectively breaking my style. I have recently resurrected it from the dead, modifying it to again work with the site.

Basically, they changed from using one image per element and a couple images in the header, to one image for many (or all) of the main elements (header, login button, etc.). This helped make the CSS a lot cleaner, but also broke my style in some parts, so I had to scrap a large portion of my code. Luckily, Webkit (a Web browser engine/project), has a very nice page inspector (or simply "Inspector", I believe) which shows the styles applied to an element, as well as all the other elements that style applies to. That allowed me to quickly find all the elements that used the sprite--which I modified to a blue color--and create a single rule which makes all those elements use my modified image instead. And because they had the black and red versions of all the elements in the same image, it allows you to choose one or the other (red or black), and have a different appearance depending on your choice.


  • 06/27/08 - Changed color of user/language dropdown menu.
  • 06/30/08 - Fixed #header at (originally had no background-image).
  • 06/31/08 - Last fix somehow ended up not being applied. It should be fixed now.
  • 08/20/08 - Colored the nav links(Active/current) on the left blue, and the links at the top/right(login/help/language) to white. Suggested by user runwithvampires.
  • 08/21/08 - Added comment to allow option of removing globe image left of language selection.
  • 12/01/08 - Removed some header images, as removed and resized some of their headers.
    Simplified Scrobble Counter and colored it blue.
  • 12/13/08 - Centered the numbers in the Scrobble Counter a little more; made it more unified. Changed colors to "named colors"(eg: "white") or "rgb"(eg: "rgb(225, 255, 225)")
  • 09/20/09 - Major changes to fit new site design.
    • Old code: (may be used to create a new style if you wish)


The Userstyle: - Paint it Blue!
Companion Greasemonkey script: (may not be relevant anymore)
Stylish website (Userstyles/Firefox extension):

Monday, August 3, 2009

Chromium on Linux Coming Along

Chromium is coming along nicely on Linux. Using the chromium-daily PPA the browser is really getting some polish now: GTK theming is almost perfect, with a few minor glitches here and there; The Flash plugin is working well on many sites (there may still be some bugs, though); Developer tools and the task manager are mostly working; most (if not all) font settings are working. Some of the missing/buggy features:
  • The toolstrip isn't complete (it displays when an extension is using it, but that's about it).
  • The top of some of the stock GTK images used in buttons (eg: the stop button) are cut off (minor).
  • HTML5 video element doesn't appear to work yet (on Ubuntu 9.04 x86_64 using the packages from the PPA). I assume it works if you use the official builds, though. It's working now (Aug 06, '09), but still has some bugs.
  • Chromium's Task Manager doesn't yet show the individual memory usage for tabs sharing a process. (don't know if it does on Windows, but I thought it did)
  • Chromium's Task Manager doesn't show CPU usage for individual processes (they all show the same usage).
  • about:memory isn't working yet.
  • There are some problems with certain window managers (eg: OpenBox's borders controls don't disappear when you switch to Chromium's controls, or don't come back when you switch back to OpenBox's. Not sure whether that's an OpenBox problem or Chromium one, but it happens with other WMs too).
  • There's still one Zombie process (called chromium-browse, for some reason) under the main chromium-browser process. All the other processes appear to go under a separate process for whatever reason.
  • Text (font?) display isn't quite right yet (using DejaVu Serif/DejaVu Sans 13, the dots in password input boxes are irregularly spaced).
  • Language settings aren't visible (or implemented?) yet.
Aside from those and a few other problems, things are looking good! Just remember that if you decide to use the chromium-daily PPA that these are possibly unstable, definitely untested builds, and that there is the possibility of bad stuff happening. If you're looking for a stable browser, you should probably wait until Google releases a stable version of Chrome themselves, or until Chromium is included in your distribution's stable repository. ;)

[This post is now out-dated; many of the issues have been mostly or entirely fixed. Those that aren't, may be soon; the reverse may also be true. Such is the way of bleeding-edge software.]