Thursday, September 11, 2008

installing pylint on win32

Installing pylint on win32 with Python 2.5.2 is fairly straightforward:

1. Download logilab-common (under common), logilab-astng (under astng), and pylint from http://ftp.logilab.org/pub
2. Extract all sources.
3. Inside each base directory, run: C:\Python25\python.exe setup.py bdist_wininst
4. You will find an exe to run in in each directory's dist folder.
5. Install common, then astng, then pylint.
6. Run pylint.bat from C:\Python25\Scripts\pylint.bat

Wednesday, September 3, 2008

My Symmetric Processing Elements

I am trying to turn into a useful individual by learning more about programming for the Cell Broadband Engine. I installed openSUSE Linux 11.0 on my PS3 a few months ago and just last night was able to get some code running.

I followed the following guide:
http://www.ibm.com/developerworks/power/library/pa-linuxps3-1/?ca=dgr-lnxw03Linux-and-Playstation3

Everthing compiled okay, but I kept getting the error "spu_create(): Function not implemented". The fix was to mount the spufs. Contrary to the spufs(7) man page, this was actually done by adding the following to /etc/fstab

none    /spu    spufs   default    0 0

I will still probably need to add the spufs kernel module to /etc/modules so that it is always loaded upon boot.

Wednesday, June 4, 2008

Preparing a Video for the PS3

Last night, I was able to convert a .MOV to an XVID-encoded .AVI using mencoder. This was then playable using the Playstatoin 3 video playback off of a USB memory stick.

Here is the video manual:
http://manuals.playstation.net/document/en/ps3/current/video/filetypes.html

I ran the following command:


mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 -o output_filename.avi input_filename.mov

This says that you want to have MP3 audio encoded at 128 kbps and XVID encoded video at 1200 kbps, which seem to be reasonable quality settings. I also ripped a DVD using the following command:


mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 -o output_filename.avi dvd://0

You may need to increment the number following the dvd:// until it is correct, though 0 is often the right one.
You can download mencoder along with MPlayer from:

Wednesday, May 28, 2008

FreeBSD boot splash

Tonight I was able to set up a FreeBSD boot splash screen. It was an enjoyable experience.

1. I edited /boot/loader.conf and added the following:

bitmap_load="YES"
bitmap_name="splash.bmp"
splash_bmp_load="YES"
vesa_load="YES"

2. I edited the wallpaper found at http://www.freebsd.org/logo/wall3.jpg to make it 256 colors and 1024x768. You may download the modified version here.

3. I moved the wallpaper to /boot/kernel/splash.bmp

4. Rebooted

5. Enjoyed the splash screen. The only issue was that it didn't go away when the boot was finished until I pressed a key. This isn't an issue for me personally, since I use XDM, which cleared it away.

Thursday, April 24, 2008

Metal Gear Solid 2: Substance PC Hex Edit

Without looking at the code, it's impossible to tell why MGS2 has so many issues on the PC using an NVIDIA GeForce graphics card. Regardless, people smarter than me have spent some time figuring out how to edit the binary to replace what appears to be search strings looking for ATI cards, thus allowing NVIDIA GeForce cards to run at full settings. I haven't gotten a chance to try thise myself, yet, but I certainly will soon.

Explanation 1 taken from here:
First download and install patch v2.0 from here:
http://www.konami.jp/gs/game/mgs2pc/english/index.html

Then you need an hex editor like frhed or whatever.
http://www.kibria.de/frhed.html

Find the files mgs2.exe and mgs2_sse.exe in the game's directory and make a backup copy of them in case you mess it up.

Now open the file mgs2.exe with the hex editor and go to edit->find and use the word "geforce" as a search term. Now the word "GeForce" should be highlighted and right next to it to the left side is the word "RADEON". These are the 2 entries you have to edit.

You have to replace the "GeForce" with whatever you like as long as the letter count remains the same. I just overwrote it with "removed".

Then the word "RADEON" to the left, this you have to overwrite with "GeForc". Notice the capital "G" and "F" and also missing "e" at the end, it should look exactly like that.

Now save and do the same steps with the mgs2_sse.exe file.

And just in case:
before:



after:



This should help to fix the problems with NVIDIA cards.



Explanation 2 taken from here:
Don't think from your message that you will have tried this fix, however you have a GeForce card anyway so do this, (thanks to the original poster, can't remember where I saw it now) -

1. Install MGS2.
2. Install the ATI 2.0 patch.
3. Find the files mgs2.exe and mgs2_sse.exe within the directory where the game was installed.
4. Backup a copy of each of these original files!
5. Open mgs2.exe with a hex editor... Frhed is a nice free utility that will suffice for this job: http://www.kibria.de/frhed.html
6. Look for the string RADEON, which starts at the following offset: 0x5f6e44.
7. Replace RADEON with ALL-IN. Don’t add or subtract anything else
8. Save the file.
9. Repeat steps 5-8 for mgs2_sse.exe. Note: this might not be necessary; on my system, Metal Gear seems to only use mgs2.exe… also, the hex offset will be different, but it’s easy to find by analogy.


Right, now you will need to follow the instructions but do a couple of things differently. At point 6&7 instead of replacing "RADEON" with "ALL-IN", replace it with "GeForc". Note the capital G and F and no e on the end. Near (right next) to where it now says GeForc, there will be the string "GeForce" (this starts at 0x5f6e4c in mgs2.exe and 0x5fd83c in mgs2_sse.exe). Replace "GeForce" with anything else as long as it has the same number of letters. The game will now use the Radeon graphics path on a geforce card and looks a hell of a lot better (tested on a GF 6800).

Monday, March 24, 2008

GNOME Terminal colors

When using gnome-terminal, I kept running into the issue of having an obnoxious gray background when using vim in the terminal. After doing some digging, it seems I need to set my gnome-terminal palette.

This is accomplished by:
  1. Edit ⇒ Current Profile...
  2. Choose the Colors tab
  3. Under the Palette section, change Built in schemes to XTerm.
  4. Stop crying.

Saturday, March 22, 2008

openSUSE 10.3

For the longest time, I tried to use FreeBSD 6.x. I found it remarkably stable and reasonably fast. Even though it has a decent binary package management system, there are a number of packages that I built from source for customization reasons. Like Gentoo Linux, the compile times quickly got out of hand. If you are using FreeBSD, make sure to look into portupgrade and its options for configuring software wholesale before an update of all of your installed ports and packages.

Compile times aside, not having an Adobe Flash plug-in (Gnash would crash the X server) is what lead me back to Linux. I've been a big fan of Debian for the longest time, but each time I come back to it, they make it harder and harder for me. The deal with Iceweasel and Icedove is enough to make me puke, as well as how long it takes to get new software.

It seems like all roads lead to Ubuntu. I gave it a shot, but my heart just wasn't in it. I tried Fedora, but that didn't trip my trigger either.

Enter the most reasonable distribution (for me) that I've tried: openSUSE

As with all GNU/Linux distributions, there are a significant amount of things that are exactly the same across all of them, especially in the way of userland. Here are the things that are different about openSUSE.

  1. Top-notch installer. I have to say that the installation process was fantastic from beginning to end. I chose to do a network install and no issues.
  2. Package management at its finest. I've used a few different package managers out there, including FreeBSD/OpenBSD ports & pkg_*, APT, YUM, and Gentoo Linux portage. So far, I think I like SUSE's YaST the most. It has a text mode, a GUI mode, and (here's where it is terribly convenient) the ability to automatically add software and software repositories by clicking on a link to a YMP (YaST MetaPackage). This is how I effortlessly added binary NVIDIA drivers.
  3. Great artwork. While not a technical feature, if I have to sit at a desk all day long, every day, it's easier if it's pretty. No shit brown and burnt orange here. Just a calming green with a number of chameleon logos.
  4. Great documentation. While many people point to Ubuntu as having the best documentation, what they may actually mean is that Ubuntu has one of the best user communities, who answer question after question in the forums. I actually feel like Ubuntu has slightly lacking documentation. With openSUSE being a test harness for SUSE Linux Enterprise Desktop, the documentation is also of enterprise quality. The wiki (which is quite beautifully laid out) is also great.
Ultimately everyone should use what works for them, or what their boss says to use, but if given the opportunity, I'd say take a peek at openSUSE. It's free, attractive, easy, and doesn't suffer from a lot of the obnoxious parts of other distributions (like in-your-face methodologies, unprofessional web sites, ridiculous mascots, bad or impossible to pronounce names, etc.).

Thursday, March 6, 2008

PostgreSQL SERIAL Saved My Life

I needed to prototype a small application that needed a database back-end. I usually just use the Python ODBC bindings (pyodbc), so as long as I had an ODBC driver installed, it didn't really matter which database management system I used.

Being sound of mind, I chose PostgreSQL and began sketching out my simple schema. I ran into a snag because I didn't know how to simulate the ever increasing identifier integer, like MySQL's auto_increment or Microsoft SQL Server's IDENTITY. Enter the pseudo-type SERIAL. It works exactly the same, but on a DBMS you can bring home to your parents.

Check it out here:

http://www.postgresql.org/docs/8.3/static/datatype-numeric.html

Wednesday, March 5, 2008

Interactive Python and It's Good Friend _

I had no idea, but when using the interactive Python interpreter, the variable '_' (without quotes, of course) stores the last thing that was successfully printed to the screen.


>>>> 2 ** 8
>256
>>>> _
>256
>>>> _ ** 8
>18446744073709551616L
>>>> 'Oh yeah'
'Oh yeah'
>>> _.split()
['Oh', 'yeah']


You get the idea. How convenient! I should read the docs more often.

Wednesday, February 20, 2008

OpenOffice.org 2.3.1 and FreeBSD

So, it turns out that OpenOffice.org 2.3.1 on FreeBSD was behaving oddly (not opening documents) due to a missing environment variable. This seems like a bug to me that will be fixed sooner or later. Regardless, normal OpenOffice.org functionality may be returned by setting the following:

OOO_FORCE_DESKTOP=gnome

References:
lucky.freebsd.ports
freebsd-openoffice mailing list archive at nabble.com

Friday, February 8, 2008

My Destroyed Faith in OpenOffice Presentations

So, I'm working on a presentation for work. I can't bring myself to use PowerPoint, since Microsoft has done such a good job of ruining my software self-esteem. I think to myself, "Well, why not OpenOffice.org Impress? It uses the OpenDocument Format, which is damn fine computing karma." So, I made my first draft in OOo 2.3.1 on Win32. Then, I attempt to continue working on the same ODP file on OOo 2.3.1 on FreeBSD. It seemingly hangs. No progress after minutes of processing. Fucking great. Running it from an xterm gives me these messages (no idea if they're related):

(process:1152): GLib-GObject-CRITICAL **: gtype.c:2242: initialization assertion failed, use IA__g_type_init() prior to this function

(process:1152): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:1152): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
That doesn't look good. I'm going to let it keep running for a while to see if things improve, but the outlook is poor. In the meantime, I've decided that the best alternative to multi-platform document creation and editing is Google Docs. It's not perfect, but at least you can save your files as PDF, which is what I use for read-only document exchange anyway.

Since I don't have a Microsoft Windows computer at my disposal, I have to figure out someway to get at least the text portion out of my ODP. This is my half-baked solution for extracting the text:
  1. $ mkdir presentation
  2. $ cd presentation
  3. $ cp ~/path_to_presentation/my_presentation.odp .
  4. $ unzip my_presentation.odp
  5. $ extract_odp_text.py > my_presentation.txt


#!/usr/bin/env python2.5
# extract_odp_text.py -- extract the text parts from an ODP's content.xml
import re
for line in open('content.xml', 'r')
for text_part in re.findall(r'<text:p.*?>(.*?)</text.*?>', line):
print text_part.replace('<text:line-break/>', '')

Wednesday, February 6, 2008

Ecplise 3.3 Exploded My Face

So, Eclipse + PyDev seems to be the premier way to visually debug python apps. The first time you debug your application, you have to choose the debug configuration you want to use, Python or Jython or some others. Anyway, after you make your selection once, you can hit "F11" to debug your last launched. Or at least that's how it used to work.

In Eclipse 3.3, you have to check a special configuration option to get the old behavior. That way you don't have to needlessly click the same debugging configuration each time. The PyDev documentation clued me in to this.

From http://www.fabioz.com/pydev/manual_101_run.html
Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application. This tutorial will always consider this as the default option.
After that, F11 rocks your world.

Tuesday, February 5, 2008

GVIM ♥ Python

When I'm not using UNIX, I'm not. To try and make things a little more tolerable, I use GVIM as much as possible. Unfortunately, the win32 GVIM release expects Python 2.4 if you want to use the amazing omnicomplete Python functions. I hit the wall today and broke down in tears, knowing that I had Python 2.5.1, but a GVIM that didn't use that.

The solution was to compile a GVIM executable myself! It turns out that it is fairly easy. I also assume that Vim is already installed.
  1. Download the source archives.
    1. ftp://ftp.vim.org/pub/vim/unix/vim-7.1.tar.bz2
    2. ftp://ftp.vim.org/pub/vim/extra/vim-7.1-extra.tar.gz
  2. Extract
  3. CD vim71\src
  4. "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"
  5. nmake -f Make_mvc.mak FEATURES=HUGE GUI=yes OLE=yes MBYTE=yes IME=yes GIME=yes PYTHON=C:\Python25 DYNAMIC_PYTHON=yes PYTHON_VER=25 CSCOPE=yes
  6. Make sure the regular Vim 7.1 is installed. I used the installer located at ftp://ftp.vim.org/pub/vim/pc/gvim71.exe
  7. COPY /Y gvim.exe "C:\Program Files\Vim\vim71\gvim.exe"
  8. COPY /Y GvimExt\gvimext.dll "C:\Program Files\Vim\vim71\gvimext.dll"
  9. Turn up your Ashlee Simpson CD
That seems to be it. I didn't add support for TCL, Perl, or XPMs, but you're a smart kid. You can figure it out.

I Threw My MBR Off The Deck

When installing FreeBSD, it gives you the option to install the FreeBSD boot manager or a standard MBR. Since I only have one operating system on my hard drive, a standard MBR will boot right into FreeBSD.

Well, instead of doing the right thing, I did the wrong thing and installed the FreeBSD boot manager, also known as boot0. Luckily, UNIX is amazing and gives you the option to fix things. A quick look at boot0cfg(8) (which means type 'man 8 boot0cfg'), and you can see that the fix is:
  • fdisk -B ad0


The -B option to fdisk means, "Reinitialize the boot code contained in sector 0 of the disk." In FreeBSD, your devices are referred to by the kernel module/driver they use. "ad" is the "generic ATA/ATAPI disk controller driver" and 0 is the number of the first ATA/ATAPI disk (zero-indexed, of course). You might have a different disk. Adjust that last argument as necessary.

Friday, February 1, 2008

X Windows and Unicode

X Windows does seem to support Unicode input. For learning a foreign language, often times an accent mark is put over a letter to indicate syllable stress (lookup diacritical marks if you're interested in more). Anyway, to put an accent over a vowel, placing U+301 after the vowel in question will place the accent mark.

  • In regular X Windows
    • I've bound it to an unused key. First, add 0x100000 to the Unicode code point in question, then bind that value to a keycode.
    • xmodmap -e 'keycode 117 = 0x1000301'
  • In GNOME
    • Hold CTRL + SHIFT, then press 3, then 0, then 1, then release
  • In gVim
    • CTRL + V, u, 0, 3, 0, 1