The random rantings of a concerned programmer.

Archive for December, 2007

Paypal o.o

December 31st, 2007 | Category: Random

I don’t recall if I mentioned it, but despite getting one of the Intel SR1450′s, I never did receive the second one I ordered. After spending a week or two trying to contact the seller (and getting no response), I filed a claim with Paypal about not receiving the item.

I checked my email today, and Paypal ruled in my favor, returning half of the payment made for the two cases ($35). I’m kind of sad I didn’t get both of them in the mail, but kind of relieved at the same time that the fiasco is finally concluded. I’m not really sure what the hell happened, haven’t heard from the seller since he sent me a mail to resolve the Fedex address confusion. Honestly, I don’t really care anymore, I’m just happy to have my money back without having to deal with a painful process.

Almost concerned me how little I had to do to get my money back.

Despite all the horror stories I’ve heard about Paypal (and I guess, in this case, I’m on the delivering end of such a story), I honestly don’t mind using them for all my transactions, as a buyer. I don’t think I’d even consider accepting Paypal as a seller – it really seems too easy to get screwed over by a malicious user, since the system seems like it’s designed to always favor the buyer. lawds.

On a side note, I just finished watching Crest of the Stars. Despite being a somewhat aged series (originally aired in 1999), I really enjoyed it. Hopefully Banner of the Stars is equally awesome :3

Comments are off for this post

Foray Embedding Pythong

December 29th, 2007 | Category: Random

I was bored today and decided to poke around with Boost.Python, because I’ve never used it before. I didn’t want to write a trivial “hello world” application, I so instead decided to write a cellular automata framework which reads in a Python script for the atomic cell update stuff.

Turns out that it’s actually really nice (once it’s working, lawds), to expose a function there’s some sickening hacks that allow this beautiful syntax -

int getCell( int x, int y ) {
        return *getCell_( x, y );
}

void setCell( int x, int y, int v ) {
        *getCell_( x, y ) = v;
}

BOOST_PYTHON_MODULE( CA ) {
        def( "getCell", getCell );
        def( "setCell", setCell );
}

Loading the python script from file wasn’t too hard. The tutorial code I was using was a little bit off – the tutorial code needs to pass in the namespace for both the global and local variable dictionaries otherwise the interpreter shits all over itself (at least it did for me, running Python2.5 etc). Anyway, the code to actually create the main namespace for the interpreter and load in the script from a file looks like this -

object main_module, main_namespace;
try {
        main_module = import( "__main__" );
        main_namespace = main_module.attr( "__dict__" );
        exec_file( argv[4], main_namespace, main_namespace );
}
catch( error_already_set const& ) {
        PyErr_Print();
        running = false;
}

Which gets used to (in the debugger) load the following Python script:

import CA
import random

g_neighbors = []
g_width = 0
g_height = 0

def init( width, height ):
        globals()["g_width"] = width
        globals()["g_height"] = height
        for y in xrange( 0, height ):
                for x in xrange( 0, width ):
                        CA.setCell( x, y, random.randint( 0, 1 ) )
                        globals()["g_neighbors"].append( 0 )

def precalc():
        for y in xrange( 0, g_height ):
                for x in xrange( 0, g_width ):
                        g_neighbors[ y * g_width + x ] = 0
        
        for y in xrange( 0, g_height ):
                for x in xrange( 0, g_width ):
                        if CA.getCell( x, y ):
                                for iy in xrange( -1, 2 ):
                                        for ix in xrange( -1, 2 ):
                                                if ( ix or iy ):
                                                        g_neighbors[ ( ( y + iy ) % g_height ) * g_width + ( ( x + ix ) % g_width )] += 1

def update( x, y ):
        #count = 0
        #for iy in xrange( -1, 2 ):
        #       for ix in xrange( -1, 2 ):
        #               if ( ix or iy ):
        #                       count += CA.getCell( x + ix, y + iy )
        
        count = g_neighbors[ y * g_width + x ]

        if CA.getCell( x, y ):
                if count < 2:
                        return 0
                elif count > 3:
                        return 0
                else:
                        return 1
        else:
                if count == 3:
                        return 1
                else:
                        return 0

Calling the functions from within the C++ application is fairly straightforward, because the generic PyObject wrapper that Boost.Python provides defines an overloaded operator(), which makes calling the grabbed functions really easy:

object init = main_namespace["init"];
init( screen_width, screen_height );

Despite the ease with which I was able to embed Python into my application with Boost.Python, there was a significant performance overhead for doing so. The Python implementation of Conway’s Life performed approximately 4x slower than the C++ implementation. While for many applications the advantages of writing the logic in Python may far outweigh performance losses, for cellular automata it just isn’t feasible, since the logic is the primary bottleneck for the simulation.

Fun to tinker with, nonetheless. The source and binary can be obtained here (165KB).

2 comments

(Untitled)

December 28th, 2007 | Category: Random

whoo, looks like I can grab a Core2 Q6600 off Ebay for lower-than-retail price too! Haven’t got the money quite put together yet (it’s still like $230-250), but that’s a couple bux off the hefty $290 retail tag.

Also, after a little bit of effort, I got FreeBSD 7.0-BETA4 running on Microsoft Virtual PC 2007! I used the boot-only distribution ISO, then downloaded the rest over FTP from within the VM. One quirk was that I originally had allocated 128M of RAM for the VM, but sysinstall shat all over itself until I raised it up to 192M. Something to take a look at in the future, might actually be a bug D:

Anyway, so I got it running, but Virtual PC is slow as fuck on this machine. I don’t know whether it’s something I misconfigured, or due to lack of hardware virtualization support, but it’s practically unusable. It almost feels like network lag: the VM appears to be processing shit fine, the display just doesn’t update very often.

I turned it off for now, experiment complete etc, since I still have one machine working that I can ssh into and tinker around with. Don’t want to do too much with it (since it’s my “Production Machine”), and I’d hate for it to break. Actuall, I’d hate for it to even powercycle, I’ve got 50 days of uptime on it, and that’s quite a bit for my systems!

EDIT: Huh. So I started up SSH on the FreeBSD virtual machine, and the ssh terminal doesn’t exhibit any lag – it’s just a slow display update. It’s probably because Virtual PC doesn’t have good emulation for the console display (why would it? Windows doesn’t use it for anything except the boot sequence). Time to do some testing :>

Comments are off for this post

(Untitled)

December 27th, 2007 | Category: Random

Goddammit.

So I was getting all ready to order the parts for my new box when I decided to check the prices on NewEgg. The first thing on my list to check, of course, was the Intel DG33TL Motherboard, which, funnily enough I was recommending to a friend today since he’s planning on building a new system too. The first thing I notice though, is that it’s gotten quite a bit of “mixed” reviews. Sure, there are a few good ones, but there are an awful lot of bad reviews too.

Now, the board itself comes with no FDD header and only 1 PCI slot. For my purposes this isn’t a problem: I’m not going to be sticking a GPU (or any other card) in here since I’m planning on running in a 2U formfactor. And ffh floppies are teh suck anyway. The funny thing is, a couple of the drivers (like, the RAID drivers) that come with the board are on a floppy disk. Yes, that’s right, they included a floppy disk with a board which doesn’t come with a FDD header. Way to go, guys.

The drivers, are of course, downloadable from Intel’s site. And really, you’re going to really want to download them from there because there’s a serious issue with the drivers they shipped. Thankfully, you can still boot the system if you use one of the first two SATA connectors (or the IDE connector), but the RAID functionality (in addition to the other connectors) are b0rk. lol guys, lol.

That’s not the only thing I’d need to fix, oh lawds no. From the reviews on NewEgg, it seems like the BIOS is pretty fucked up too. Not only is it very limited, but it fucking loads the drive controllers before booting the BIOS, which means if there aren’t any attached drives, it can’t boot at all. This, for me, is a serious motherfucking problem considering the amount of diskless shit I do. Supposedly there’s a newer BIOS version which isn’t as shit, but again, that’s an extra step (which is made a bit more difficult due to the lack of a BIOS).

The final issue is that the board can only take 1.8V 5-5-5 CAS RAM, but that’s clearly noted in the board documentation. A couple of people missed that and are stuck with a bunch of unusable RAM (well, unusable on this board, at least), but that’s purely their own fault. I have a shitton of old high-density ECC PC133 that I can’t use because I don’t have any compatible boards. It isn’t too big of a deal.

Despite all that, I’ll probably buy the board anyway. It seems all of the problems can be fixed by flashing the BIOS and using up-to-date drivers (and, lol, reading the manual beforehand?), and it really is a damn good price. I think I will order from NewEgg though – at least if the board really is unusable, I can try to get some kind of refund.

lawds.

EDIT: lol just bought one on ebay for $56 ($15 shipping = $71 total, compared to the $120 retail price). New in box, should be good. HA HA HA!!! Won’t be able to pay for it until tomorrow etc, but should have it in sometime next week I think :D

Comments are off for this post

(Untitled)

December 27th, 2007 | Category: Random

lol, so apparently I had some weird interests set up in my StumbleUpon profile, so I went ahead and re-configured it so I get more than just cookies and cellular automata articles. Finding pages like Top 100 Network Security Tools makes me really sad that all my machines at home are down, because I really want to tinker around with some of those things.

:(

And I wish this poor little laptop had the power to run a couple of virtual machines, so I could emulate my test network off a single computer, but since it only has one core (lol an old celeron), I’m not even going to bother with it. I really want to build that new computer… I think I’ve got all the parts laid out for it -

All the prices listed are the retail ones; I think I might be able to get the motherboard for a little cheaper off eBay, but they’re pretty hot compared to the shit I normally get. Assuming I buy it all retail, I’m looking at a $675 pricetag, which is pretty damn good considering the components I’m putting together.

I’m probably not going to spring for a GPU, simply because I don’t think I play enough games to get much out of it. I have two justifications for building this machine: first, I need something to put that SATA drive into. Second, while it’s nice building old dual P3-based 1U boxes for under $100, they aren’t really that powerful, and I’d like to have a desktop (Windows environment) where I can fuck around with virtualization.

The benefit is, when I decide to build another high-quality machine a couple years from now this one is in a 2U formfactor with 4 SATA hotswap trays, so it’ll be a perfect fileserver. And, by the time I discard it as such, I’ll probably have purchased (or found, or built) an 8-12U rack to stow all my machines instead of just stacking them >_>

Comments are off for this post

Next Page »