Website::BlogPreview()
User->Login();

Leave me a message

Name:
Email:
priority (page me)
Message:

2008-02-02 19:19:58

Singletons by delegate

Singletons are a common programming model, wherein a program ever only uses a single instance of a certain class, and that instance is shared program-wide.

The typical implementation of this is an if-null/lock/if-null setup that looks something like this:

class OnlyOne

{

private OnlyOne _instance;

public OnlyOne Instance

{

get

{

if (_instance == null)

{

lock (typeof(OnlyOne))

{

if (_instance == null)

{

_instance = new OnlyOne();

}

}

}

return _instance;

}

}

}

The reason for the if-null/lock/if-null is one for a different discussion, but it is basically the fastest portable way to allow thread-safe access to the single instance. However, it requires that the first if-null be executed every time a request for the instance is made. If your instance never changes, this is needless overhead.

I developed a quick and dirty solution using delegates. The basic idea is that when you create the first instance and you know it can no longer be null, you change the "GetInstance" routine to point to a routine that does not check for null. I created a generic for this. Here's the result:

public class Singleton<T> where T: new()

{

public delegate T InstanceGetter();

private static T _instance;

public static InstanceGetter GetInstance = new InstanceGetter(_GetNewInstance);

private static T _GetNewInstance()

{

if (_instance == null)

{

lock (typeof(T))

{

if (_instance == null)

{

_instance = new T();

GetInstance = new InstanceGetter(_GetInstance);

}

}

}

return _instance;

}

private static T _GetInstance() { return _instance; }

}

And then reusing it is quite easy:

class OnlyOne : Singleton<OnlyOne>

{

}

Now only the first call to OnlyOne.GetInstance() will actually check for null in a single threaded environment. And in the worst-case multithreaded environment, only the first simultaneous calls will check, the rest will just return the instance immediately.

My tests showed about a 25% performance gain. This is actually of questionable usefulness because you should not be calling the GetInstance method in a tight loop, you should call it once and assign it to a local. But I thought I'd share the basic idea because using delegates in this fashion might be useful in other scenarios.... More: Click to Read/Comment

2007-12-11 21:46:04

Monodevelop

I'm still relatively new to Mono, which is a cross platform, open-source implementation of .Net. The implementation has proved surprisingly gap free for the most part.

But, what Mono suffers from is its lack of Visual Studio. Much of what makes .Net development so effortless is what is a really good implementation of an IDE (refactoring, a really good debugger, smart tags, and several other nice things). An IDE is beyond the scope of the Mono project, and another project, "Monodevelop" is filling in that gap.

Unfortunately, there are still gaping holes which makes it frustrating to anyone who has been spoiled by Visual Studio. I miss the refactoring, the smart tags which prompt you to effortlessly add a "Using" if necessary, but most of all, a debugger.

It is not hard to write complex code, it isn't hard to write code quickly, but if you need to do both, you really need a debugger to get it right. And this is where Monodevelop (and also Mono) are way short. It's relatively young still and free open source; and most importantly the developers are planning to implement all these things. I may see about getting in on that myself. But for now, Monodevelop is slightly refreshing but mostly frustrating.... More: Click to Read/Comment

2007-12-05 20:52:15

Latest mono on Ubuntu

The current version of mono on Ubuntu 7.10 is 1.2.4.2. There are fixes in 1.2.5.2 which I need. Getting 1.2.5.2 built is no problem, but getting it installed without causing all kinds of problems appears to be. This is something I miss about Gentoo.

I've tried building my own package, but the official packages for mono are split up into many smaller packages which made that impossible.

I think what I'll have to do in order to upgrade is to get the source package using apt-get source, unpack it all, and see if I can just replace the 1.4.2.2 code with the 1.2.5.2 code.

I have already pulled the source package down successfully and unpacked it. It looks like the Ubuntu guys applied many patches to it. I don't know if those patches will work with the new version of code, or if the new version of code contains those patches. It's probably some combination of the two. This will take some time. I'll post a follow up if I ever get this working.... More: Click to Read/Comment

2007-12-04 16:51:09

Back to Linux

Over two years ago I shed Windows from my desktop and built a Gentoo desktop. At the time, I was working from home only and had lots of extra time to tweak, compile and troubleshoot. When I changed jobs again, the lack of time, and compatibility issues with being back in a Microsoft environment at work forced me to abandon my Gentoo and go back to Windows.

Well, I'm still in a Microsoft environment at work, and I still don't have any time, but now I'm trying to make a go of it again. This time, however, noting my lack of available tinker time, I'm going with the flow and have installed Ubuntu. (I love Gentoo but just don't have the time to deal with its idiosyncrasies right now).... More: Click to Read/Comment

2006-08-31 22:50:43

PHP Class Autoload

It's been a long time since I posted.   I just wanted to write up a quick post today to say how much I like the new __autoload() function in PHP.   For those not familiar with it, the function gets called when a class is used in PHP that has not been defined.   This gives the developer a chance to allow the script to find the include file it needs and include it to define the class.

The function's not all that new, but I'm just getting around to using it and it's changing the way I design my sites.

So now I don't use ever need to manually include a file anymore.   I don't use any global functions.   I make all my otherwise-global functions static functions of some class and call them that way.   I never have to remember to include the file at the top of the page, I never have to worry about including it twice because of the quirks of include_once(), and I don't have a bunch of orphaned include()s at the top of the script anymore from removing a function but leaving it's include.

I'm sure there's someone out there that thinks this isn't a good idea for whatever reason.   I'm all ears, but for now, this has made my PHP development much easier.... More: Click to Read/Comment

2006-07-12 18:11:53

Margin of Error

Here, provided for your enjoyment, are the results of a poll displayed, today, on Headline Prime with Erica Hill:

Is It OK To Lie?

52% lying is never justified

65% lying OK to avoid hurting feelings.

source: AP/IPSOS Poll

I just simply could not resist blogging this. What does this mean about at least 17% of survey respondents?

To me, this means that in addition to the margin of error on polls, we need to be aware that the margin of too-frickin-stupid is at least 17%.... More: Click to Read/Comment

2006-06-01 18:41:34

Stupid Standards

I'm all for standards in web browsers. But it really bugs me when the standards-compliant behavior is worse than the non-compliant browsers' behavior. So here we have made a standard protocol, and to follow the protocol means making your browser behave poorly. This isn't always the case. Quite often the standard is better, and for the most part a standard is almost always better than no standard.

It's almost strange how little agreement there is between browser makers on the best way to implement what's known as the box model. The box model refers to the dimensions and spacing given to html tags. For instance, a box in html has the main body where the text goes, surrounded by the padding which is filled with the object's background color but is otherwise empty of text. That is surrounded by the border, which is surrounded by the margin, which is more empty space which is transparent and collapses against (is allowed to overlap) margins of other elements. The confusion comes when it's time to set the width of the element. To which part of the box model does/should the width refer?

The standard apparently says that the width refers to the body part, not the padding. Internet Explorer, on the other hand, says that the width refers to the body plus the padding plus the border. Oddly, in standards compliant mode, IE still says that the width refers to the body plus the padding. IE's "quirks" way makes the most sense to me. The standard way does not. Why? Because the standard way makes certain things impossible, whereas, IE's way does not.

Take for instance a table of data. In one column of the table, you have an input field in each row so that the user can edit information. You want the input field to expand horizontally in size to fill the cell it's in. So you set its width to 100% and that works perfectly, except you notice that the text seems to butt up against the left edge too closely, so you add padding to the left (about five pixels (5px) or so). Ah, that seems to work fine in IE, but in Firefox, now, the right edge of your input field has encroached five pixels into the neighboring cell on the right. Why? Because the 100% width you set doesn't apply to the padding. So how do you take the padding into account? You can't, because you can't do math in CSS. Otherwise 100% - 5px would be nice. Or it might be nice to be able to actually specify which part of the box model you want width to affect.

Now IE gets a lot of flack when it doesn't adhere to the standard, and for the most part it should. And I like that IE can be switched into "compliance" mode with a DOCTYPE declaration (even though it is only a little more compliant). However, I often find that it is the standard which is most annoying.... More: Click to Read/Comment

2006-05-30 09:45:55

Development in Variable Width (follow up)

I am still using variable width for my development. I still have not noticed any more annoyances besides those I had already noted in my first post (space character too thin, developers that try to line stuff up too often etc.). I have corrected the space-too-thin problem by editing the font. I took the liberty of merging the monospace versions of the parentheses, angle brackets, and curly braces (I used Bitstream Vera Mono for that) into my favorite proportional font so far (Verdana - like Tahoma, but with wider spacing between letters).

I also fixed some other annoyances, such as the tiny margin on either side of single and double quotes. This made it very hard to read, and made things such as a single quote, wrapped in double quotes, a very hard thing to decipher. So I increased that margin significantly.

Then I did a couple more things. I made the parentheses (that I copied in from the monospace font) to be more concave. I like that much better. I also made their footprints wider to compensate. Then I added a dot in the middle of the zero, and even put a very thin line through the seven, just because.

I even adjusted the kerning between certain characters to make operators easier to read. I made >>, => and -> spaced closer together, but when I tested them out, I found that my development environment does not seem to take advantage of kerning. If it had, I might have also added some more operator kerning.

So for anyone who is interested, here is the font: WF-Programmer Postscript Font file

... More: Click to Read/Comment

2006-05-16 10:40:38

DOM Builder Shortcut Function

I've created a library to aid in the creation of DOM trees from within Javascript using a json-like syntax. If you've ever createElemented or appendChilded your way to a DOM tree, you know why this might be handy.... More: Click to Read/Comment

2006-05-10 09:51:52

Development in Variable Width

The traditional font family for use in writing computer code is monospace. Partly this is because monospace was all that was available when computer programming began and remained largely the only choice until relatively recently. Mostly, though, monospace is used because coders use spacing to line up their code to make it more readable.

I visited a website which listed some favorite programming fonts and described the properties of each font which made it suitable for programming. All the fonts were monospace as one would assume. However a commentor on the site said that he began using a variable width font a few years previously and never looked back.

So I've decided to give it a try, and so far, I like it. Variable width fonts are just easier on the eyes after a while. Still, you need a decent programming font. I would like one where the parentheses (and brackets) have wider than average spacing, and similar characters such as zero and the letter 'O' are distinguishable. Interestingly, I've found that when I don't intentionally line my code up, I actually don't want it to line up. I have found that it is actually easier to read the code when all the characters in the line below do not line up directly under characters in the line above. My left margin is always clean because the spaces and tabs are always the same size. For the most part, I don't see spacing as a problem. In my particular font, I wish the space character was bigger, though. Another "pro" is that I can fit a whole lot more on one line without using a small font or a harder to read, narrow font.

There are some "cons" though. That narrow font means that people who wrap their comments to more than one line seem to wrap them way too soon. And using a variable width font means I will, likewise, tend to wrap mine later than would be readable for a monospace-font developer. My left margin is always clean, but every once in a great while, I find that code that was intended to line up does not. However, this hasn't been a problem for me. Coders, I think, often over-format their code, even reducing readability to some degree.

What I would like to see is an editor that can mitigate the downsides of variable width fonts by manipulating the whitespace and recognizing the language syntax. For instance, the editor should be able to detect when a monospace-font developer adds superfluous whitespace for the purpose of lining up code and then expand the variable width whitespace as necessary to make sure the code is lined up. Though this can't ever be perfect, it can be perfected to a reasonable degree. Also, comment blocks that are obviously wrapped intentionally could be "unwrapped" then "rewrapped." There are email applications that do this with email text wrapped to the standard 80-or-so lines.   The editor can then automatically wrap comments back to monospace width when saving.

I am currently using KDevelop, KDE's development environment, for my C++ development.   I might just try to find out where the editor code is and see if I can implement something like this.   In the mean time, though, I think I'll keep experimenting with different variable width fonts anyway.... More: Click to Read/Comment

2006-04-20 13:40:40

No 64bit Flash Player [updated]

And so it goes, one of the first problems I am running into while using linux is that there is no 64 bit flash player for linux. In fact, there might not be a 64 bit flash player at all. This surprises me. I hear people argue that there just isn't that much demand for it, but part of the benefit of flash was supposedly its wide adoption and cross-platform availability, giving a developer a way to code without worrying about browser incompatibilities. If nobody on a 64 bit system is going to be able to use it, then that seems like a rather big deal. As far as I can tell, there are no official plans to create a 64 bit version.

What does this mean? No google video in linux, was the first thing I noticed.

[UPDATE] You can actually download the video as an AVI reportedly by pasting the following address in the address bar in mozilla (or by making it a bookmark):

javascript:if(document.getElementById('macdownloadlink')!=null){window.location.href=document.getElementById('macdownloadlink')}else{alert('Go to Google Video to download videos as AVI.')};

[UPDATE2] Also, if you can figure out how to download the FLV file, you can install ffmpeg which comes with ffplay, that can play flv files. It should be possible to write a quick plugin or something to do this easily. Of course, I don't have time to be bothered with that.... More: Click to Read/Comment

2006-04-20 09:07:55

It works ...mostly

Well after a lot of pain, I finally got a good linux system up and running on my AMD64 with ATI x850. It seems to work alright for the most part, though there are a couple glitches. Currently my entire system locks up if I try to quit X. I have not been able to determine if this is a problem with ATI's drivers or the kernel, or some combination of both. It only seemed to have happened when I got dual monitors working (finally).

The dual monitors works much like Windows once it works. The basic dual monitor or multi-monitor technology in linux is usually referred to as Xinerama, though it isn't always the exact same technology. What I found out was that KDE had to be recompiled to become "xinerama aware" before it would work correctly in the dual monitor system. Before being recompiled, the system behaved exactly like I had one double wide monitor. That means things maximized across both screens, and dialog boxes popped up centered between the screens. I don't know, yet, if other applications have to be xinerama aware or not, or if it was enough that KDE and its window manager are now. I will find out soon enough. If it isn't, I'll be sure to post a complaint about that here.

Note that recompiling KDE to be xinerama aware is a gentoo thing. Most common (binary) distributions will probably have this already built-in.

3D accelleration does not seem to be working either. DRI is apparently enabled, but when I run the glxgears test, I get 450fps or so. I see other people reporting 8000fps or higher, so I know that mine is not working correctly. I may, therefore, move to the open source radeon driver since it is rumored to be more stable. If 3d accelleration is all I have to sacrifice, then I haven't lost anything.... More: Click to Read/Comment

2006-04-12 16:52:21

Trouble With Dual Monitors

So yet another thing I have to deal with when trying to make a switch from Windows to Linux. In Windows, we simply right click the desktop, go to properties, settings, where I see my second monitor, which I can move to where I want it to be, relative to my primary monitor, and it even prompts me to extend the desktop onto it. How nice.

My single monitor "mirror" or "clone" works fine, but if I want to try to do dual monitors, the secondary goes into power save mode and the primary just stays blank (and, of course in true X fashion freezes and takes no more input).

I followed ATI's instructions, but it seems to be that the second monitor has a different BusID which has a different chip id and that it isn't in the list of supported chip ids in ATI's driver. I'd heard of this happening before for primary monitors where companies like Asus where "branding" their chips and changing the chip ids. ATI fixed that, as I understood it, yet my primary is in the list and my secondary is not. The thing is that I don't really see any secondaries in there and I don't know if I should. But I do know that it doesn't recognize mine.

Here is the list, from my log file:

RADEON 9000/9000 PRO (RV250 4966), RADEON 9000 LE (RV250 4967),

MOBILITY FireGL 9000 (M9 4C64), MOBILITY RADEON 9000 (M9 4C66),

RADEON 9000 PRO (D9 4C67), RADEON 9250 (RV280 5960),

RADEON 9200 (RV280 5961), RADEON 9200 SE (RV280 5964),

MOBILITY RADEON 9200 (M9+ 5C61), MOBILITY RADEON 9200 (M9+ 5C63),

FireGL 8800 (R200 5148), RADEON 8500 (R200 514C),

RADEON 9100 (R200 514D), RADEON 8500 AIW (R200 4242),

RADEON 9600 (RV350 4150), RADEON 9600 SE (RV350 4151),

RADEON 9600 PRO (RV360 4152), RADEON 9600 (RV350 4E51),

MOBILITY RADEON 9600/9700 (M10/M11 4E50),

MOBILITY RADEON 9550 (M12 4E56), RADEON 9500 (R300 4144),

RADEON 9600 TX (R300 4146), FireGL Z1 (R300 4147),

RADEON 9700 PRO (R300 4E44), RADEON 9500 PRO/9700 (R300 4E45),

RADEON 9600 TX (R300 4E46), FireGL X1 (R300 4E47),

RADEON 9800 SE (R350 4148), RADEON 9550 (RV350 4153),

FireGL T2 (RV350 4154), RADEON 9800 PRO (R350 4E48),

RADEON 9800 (R350 4E49), RADEON 9800 XT (R360 4E4A),

FireGL X2-256/X2-256t (R350 4E4B),

MOBILITY FireGL T2/T2e (M10/M11 4E54), RADEON X300 (RV370 5B60),

RADEON X600 (RV380 5B62), RADEON X550 (RV370 5B63),

FireGL V3100 (RV370 5B64), MOBILITY RADEON X300 (M22 5460),

MOBILITY RADEON X600 (M24 5462), MOBILITY FireGL V3100 (M22 5464),

RADEON X600 (RV380 3E50), FireGL V3200 (RV380 3E54),

MOBILITY RADEON X600 (M24 3150), MOBILITY RADEON X300 (M22 3152),

MOBILITY FireGL V3200 (M24 3154), RADEON X800 (R420 4A48),

RADEON X800 PRO (R420 4A49), RADEON X800 SE (R420 4A4A),

RADEON X800 XT (R420 4A4B), RADEON X800 (R420 4A4C),

FireGL X3-256 (R420 4A4D), MOBILITY RADEON 9800 (M18 4A4E),

RADEON X800 XT Platinum Edition (R420 4A50), RADEON X800 (R423 5548),

RADEON X800 PRO (R423 5549),

RADEON X800 XT Platinum Edition (R423 554A),

RADEON X800 SE (R423 554B), RADEON X800 XT (R423 5D57),

FireGL V7100 (R423 5550), FireGL V5100 (R423 5551),

MOBILITY RADEON X800 XT (M28 5D48), MOBILITY FireGL V5100 (M28 5D49),

RADEON X800 XL (R430 554D), RADEON X800 (R430 554F),

RADEON X850 XT Platinum Edition (R480 5D4D),

RADEON X850 PRO (R480 5D4F), RADEON X850 XT (R480 5D52),

MOBILITY FireGL V5000 (M26 564A), MOBILITY FireGL V5000 (M26 564B),

FireGL V5000 (RV410 5E48), FireGL V3300 (RV410 5E49),

RADEON X700 XT (RV410 5E4A), RADEON X700 PRO (RV410 5E4B),

RADEON X700 SE (RV410 5E4C), RADEON X700 (RV410 5E4D),

RADEON X700 (RV410 5E4F), MOBILITY RADEON X700 (M26 5652),

MOBILITY RADEON X700 (M26 5653), MOBILITY RADEON X700 XL,

RADEON 9100 IGP (RS300 5834),

RADEON 9000 PRO/9100 PRO IGP (RS350 7834),

MOBILITY RADEON 9000/9100 IGP (RS300M 5835),

RADEON XPRESS 200 (RS400 5A41), RADEON XPRESS 200M (RS400 5A42),

RADEON XPRESS 200 (RS480 5954), RADEON XPRESS 200M (RS480 5955),

RADEON XPRESS 200 (RS482 5974), RADEON XPRESS 200M (RS482 5975),

RADEON XPRESS 200 (RC410 5A61), RADEON XPRESS 200M (RC410 5A62),

RADEON 9000 (RV280 5962), MOBILITY RADEON 9500 (M11 4E52),

RADEON 9500 (R350 4149), RADEON 9600 (RV351 4155),

MOBILITY RADEON X300 (M22 5461), RADEON X800 SE (R420 4A4F),

RADEON X800 VE (R420 4A54), RADEON X800 GT (R423 554B),

MOBILITY RADEON X800 (M28 5D4A), RADEON X800 GT (R430 554E),

RADEON X800 GTO (R430 554F), RADEON X800 GTO (R480 5D4F),

RADEON X850 (R481 4B48), RADEON X850 XT (R481 4B49),

RADEON X850 SE (R481 4B4A), RADEON X850 PRO (R481 4B4B),

RADEON X850 XT Platinum Edition (R481 4B4C)

My card is in bold. Here is what I get from lspci -v and lspci -n (relevant sections in bold):

02:00.0 VGA compatible controller: ATI Technologies Inc R480 [Radeon X800 GTO (PCIE)] (prog-if 00 [VGA])

Subsystem: ATI Technologies Inc Unknown device 0112

Flags: bus master, fast devsel, latency 0, IRQ 50

Memory at d0000000 (64-bit, prefetchable) [size=256M]

Memory at e3000000 (64-bit, non-prefetchable) [size=64K]

I/O ports at a000 [size=256]

[virtual] Expansion ROM at e2000000 [disabled] [size=128K]

Capabilities: [50] Power Management version 2

Capabilities: [58] Express Endpoint IRQ 0

Capabilities: [80] Message Signalled Interrupts: 64bit+ Queue=0/0 Enable-

Capabilities: [100] Advanced Error Reporting

02:00.1 Display controller: ATI Technologies Inc R480 [Radeon X800 GTO (PCIE)] (Secondary)

Subsystem: ATI Technologies Inc Unknown device 0113

Flags: bus master, fast devsel, latency 0

Memory at e3010000 (64-bit, non-prefetchable) [size=64K]

Capabilities: [50] Power Management version 2

Capabilities: [58] Express Endpoint IRQ 0

02:00.0 0300: 1002:5d4f

02:00.1 0380: 1002:5d6f

Notice that 5D4F is the primary display, and it is in the list (I bolded it). Notice that 5D6F is not. And this is the message I get in the log:

(WW) fglrx: No matching Device section for instance (BusID PCI:2:0:1) found... More: Click to Read/Comment

2006-04-11 14:15:25

ATI x850 Working, but not with X11R7

Well, I went back through /var/log/emerge.log to find all the stuff that was merged to setup Modular X and I unmerged it all. I should have binaries of them to make remerging them easier if I change my mind again later. I emerged Xorg 6.8.2 again and got the card working. I'm using version 8.23.7 of the proprietary ATI driver (x11-drivers/ati-driver in portage).

It wasn't perfect from the start, though. I ran X -configure and it exited on signal 11. I moved all the modules out of /usr/lib64/modules/drivers into a temporary directory except fglrx and vesa, but still, signal 11. However, the xorg.conf.new file was written, so I ran aticonfig on that one and then tried X -config xorg.conf.new and, to my surprise, it started up. I copied that config file to /etc/X11/xorg.conf and started everything up with /etc/init.d/xdm start

I'll probably look into seeing if it is possible to get it running with X11R7 later on, but in the mean time, I'm going to poke around in KDE 3.5.2 and see how things work.... More: Click to Read/Comment

2006-04-09 00:02:06

Gentoo Binary Packages

In an effort to save myself some time, I'm looking into setting up a share on my network dedicated to hosting precompiled gentoo packages (that I've compiled myself). This way when I unmerge a package and want to remerge it later, or I want to merge the same package on identically configured (same architecture and optimizations), I don't have to go through all the trouble of recompiling everything.

I'm using a samba share because I already have one. If you want to use NFS or something else, then that is fine, but you'll have to transpose this list as necessary. Also note that to use a samba share, you'll want to have the smbfs module compiled and inserted, or compiled into the kernel. The basic process works as follows:

UPDATED: I've updated this now due to a problem with newer versions of portage getting ACCESS DENIED errors when creating the binaries. Because of the way the sandbox works, you can't have symlinks inside the package directory (PKGDIR) that point outside the sandbox's directory write list.

  1. [Server A] Set up a centralized directory with read/write access for storing the binary packages. Share it with samba.
  2. [Server B] Set up a centralized web server (apache in my case) that can point to the share. This could be the same box as "A", but mine is not.
  3. [Client] Mount the samba share somewhere. Mine is called "pub" because it was already created and I mount it in /mnt/pub, for instance.
  4. [Client] cd into the share, and create a folder for your architecture. This should be something like i686-pc-linux-gnu-4.1.0/pentium4/O2. The first directory name (e.g. i686-pc-linux-gnu) is the compiler architecture (CHOST) being used (from `gcc-config -c`). The next directory name (e.g. pentium4) is the architecture. This comes from the -march in CFLAGS in /etc/make.conf. The next is the compiler optimization used (e.g. O2 for -O2) in the CFLAGS of /etc/make.conf.
  5. [Client] Add PKGDIR variable to /etc/make.conf that points to the directory you created in the previous step
  6. [Client] Add to /etc/make.conf: FEATURES="buildpkg"
  7. [Client] (optional, see caveat) Use quickpkg to create binary packages of everything you already have built. Caveat: if the package contains any files you've modified, these go into your binary package. So this isn't really safe. The better thing to do is to re-emerge everything.
  8. [Client] Add the following alias to your /etc/bash/bashrc aliases, alias emerge="emerge --usepkg --getbinpkg"
  9. [Client] Add to /etc/make.conf: PORTAGE_BINHOST="http:///path/to/share/i686-pc-linux-gnu/pentium4/O2/" (Try not to miss the last slash as it results in a redirect from the server and an annoying message from emerge)

The basic idea, here, is that steps 1 and 2 create a central repository. Steps 3-8 ensure that binaries are cached for existing builds and new builds, and step 9 sets the system up to use the cached binaries if they are available.

Tips:

One thing I noticed is that I have some machines configured to use the -march k8 and some to use -march athlon64, but that these are aliases for the same thing and produce identical binaries. So, if you want to share binaries between these machines, you can symlink the k8 and athlon64 directories under the x86_64* dir.

Caveats:

  1. I believe that different glibc versions might cause problems and this could potentially be remedied by adding a glibc version into the PKGDIR and PORTAGE_BINHOST paths.
  2. If you upgrade gcc, gcc-config will not fix /etc/make for you to put the new binaries in a new folder, so you just have to remember to do that. I experimented with having make.conf detect the current version, but that caused problems with gcc-config.
  3. If you share these among machines, it looks like the USE flags are compiled into the binaries so the two machines are forced to use the same USE flags or compile separately. Compiling separately might cause some confusing problems since the paths to the binary packages will be identical causing overwrites.
... More: Click to Read/Comment

2006-04-06 16:25:38

Compiling KDE 3.5.2

I've put the video card debacle on hold for now to compile KDE because it is convenient at this time to have my machine doing large compiles while I'm off doing other things. I have set up a script which runs the build, and then texts my cellphone when it is complete so that I don't have to keep monitoring it. This is quite handy.

The first problem I run into is kde-base/superkaramba-3.5.2. I immediately tried 3.5.1 but it requires downgrading the kde-libs to 3.5.1 and I can't do that because all the other packages depend on it. So I have to fix 3.5.2.

The failure message appeared to be that Python.h was missing in one of the compiles. However running make in the working directory didn't reproduce that error. In fact, it succeeded fine. So I went and tried to run ebuild ... install and there was the error, during the install phase, it is compiling. That led me down a wild goose chase. When I tried the whole thing over again step-by-step, I found that the compile appears to succeed, and portage things it succeeds, but it doesn't. The configure script complains that it is missing Python.

Superkaramba can't be compiled

because of missing Python libraries/headers.

Python is almost certainly installed, but let's check:

# equery list python

[I--] [ ] dev-lang/python-2.4.2 (2.4)

[I--] [ ] dev-python/python-fchksum-1.7.1 (0)

Yep, it's installed. So why does the configure script miss it? I'm looking at config.log and see that it finds Python 2.4 headers and libraries but apparently not the modules. I'm looking at this line:

configure:34568: result: header /usr/include/python2.4 library /usr/lib64 modules no

It is looking for the modules in the following locations:

configure: 34552: /usr/local/lib64/python2.4/copy.py

configure: 34552: /usr/lib64/python2.4/copy.py

configure: 34552: /usr/local/python2.4/copy.py

configure: 34552: /usr/lib64/python2.4/copy.py

Specifically it is looking for copy.py, and, of course, it isn't in any of those locations, it is in /usr/lib/python2.4/copy.py. So I'm thinking that this has something to do with the fact that I'm on a 64bit system. Well, at least, that's why it hasn't been fixed yet.

It isn't clear whether the configure script is looking in the wrong place, or the python installation isn't quite right. My guess is to blame the configure script because it is searching the same location twice.

If I look at the configure script, I find that it in fact is hard coded to search the same location twice. Here's the line:

python_libdirs="$ac_python_dir/lib$kdelibsuff /usr/lib$kdelibsuff /usr/local /usr/lib$kdelibsuff $kde_extra_libs"

Notice that /usr/lib$kdelibsuff exists twice. Why would you want to search the same dir twice? I'm changed that to:

python_libdirs="$ac_python_dir/lib$kdelibsuff /usr/lib$kdelibsuff /usr/local /usr/lib $kde_extra_libs"

...and reran configure. Look in config.log to find how portage is running configure. Mine was:

# ./configure --prefix=/usr \

--host=x86_64-pc-linux-gnu \

--mandir=/usr/share/man \

--infodir=/usr/share/info \

--datadir=/usr/share \

--sysconfdir=/etc \

--localstatedir=/var/lib \

--with-x \

--enable-mitshm \

--without-xinerama \

--with-qt-dir=/usr/qt/3 \

--enable-mt \

--with-qt-libraries=/usr/qt/3/lib64 \

--disable-dependency-tracking \

--disable-debug \

--without-debug \

--disable-final \

--without-arts \

--prefix=/usr/kde/3.5 \

--mandir=/usr/kde/3.5/share/man \

--infodir=/usr/kde/3.5/share/info \

--datadir=/usr/kde/3.5/share \

--sysconfdir=/usr/kde/3.5/etc \

--enable-libsuffix=64 \

--libdir=/usr/kde/3.5/lib64 \

--build=x86_64-pc-linux-gnu

This gives me:

Good - your configure finished. Start make now

And so I go back to portage to do run all the steps, but this time editing the file before compiling, and I find that the configure script is built from a file called acinclude.m4 where we want to make our change, and then I also see another file in the admin directory with the same line so I edit and change that one too just in case.

# cd /usr/portage/kde-base/superkaramba/

# ebuild superkaramba-3.5.2.ebuild clean

# ebuild superkaramba-3.5.2.ebuild unpack

# nano -w /var/tmp/portage/superkaramba-3.5.2/work/superkaramba-3.5.2/acinclude.m4

(made my change and saved)

# nano -w /var/tmp/portage/superkaramba-3.5.2/work/superkaramba-3.5.2/admin/acinclude.m4.in

(made my change and saved)

# ebuild superkaramba-3.5.2.ebuild compile

I remember, that the compile appeared to succeed, before, even though nothing was compiled, so this time, I am watching and I see the "Good - your configure finished..." message scroll by and it does, and portage is compiling stuff. I sigh with relief, cross my fingers and finish it off:

# ebuild superkaramba-3.5.2.ebuild install

# ebuild superkaramba-3.5.2.ebuild qmerge

All goes well.

[EDIT] ... And I have no further problems compiling KDE 3.5.2... More: Click to Read/Comment

2006-04-05 10:00:16

ATI Radeon x850 on (vs.) Linux

I got a great deal on the ATI card and I got it for gaming in Windows. Otherwise, I advise anyone interested in one day switching to linux to avoid ATI. Nvidia is so much nicer to the linux community.

Nevertheless, I'm going to try to get this working because ATI is what I have. The x850 is based on the radeon 300 chipset. The open-source drivers for linux just don't work with it, from what I understand and so we need the proprietery (pronounced: "evil") driver from ATI.

And I'm doing this all on an AMD64 machine with Gentoo, running X11 7.0 and gcc 4.1.0. Both of which, at this point, are not really stable.

I managed to get X11 compiled after fixing one of the ebuilds, but X doesn't actually work. I first tried to install the stable version of the ATI drivers but the build failed.

Then I tried to install the testing (unstable) drivers. Those built, but didn't work. I'm going to work on getting these to work rather than trying to get the stable version built. If I find myself in over my head, I'll go back to the stable version and just try to get it built.

The error I'm getting with the development drivers is that when I run

X -configure

I get the following error:

dlopen: /usr/lib64/xorg/modules/drivers/fglrx_drv.so: undefined symbol: __glXActiveScreens

(EE) Failed to load /usr/lib64/xorg/modules/drivers/fglrx_drv.so

(EE) Failed to load module "fglrx" (loader failed, 7)

I'll post my progress (if any) here as comments... More: Click to Read/Comment

2006-04-05 09:34:08

X11 v7 (Modular X) Compiles

This wasn't as difficult as I thought it would be. The only problem I encountered buliding it successfully was in the previous post where mesa-progs failed to compile. I'm not even sure at this time why it is required, but I did get it working. Here's what I did.

ebuild /usr/local/portage/x11-apps/mesa-progs/mesa-progs-6.4.2.ebuild unpack

cd /var/tmp/portage/mesa-progs-6.4.2/work/Mesa-6.4.2

Then I edit one of the Makefiles in there and add four lines.

nano -w progs/xdemos/Makefile

I add the following:

glxgears: glxgears.c

$(CC) $(CFLAGS) -I$(INCDIR) glxgears.c $(GLUT_LIB_DEPS) -o $@

glxinfo: glxinfo.c

$(CC) $(CFLAGS) -I$(INCDIR) glxinfo.c $(GLUT_LIB_DEPS) -o $@

Now I can compile, install and merge

ebuild /usr/local/portage/x11-apps/mesa-progs/mesa-progs-6.4.2.ebuild compile

ebuild /usr/local/portage/x11-apps/mesa-progs/mesa-progs-6.4.2.ebuild install

ebuild /usr/local/portage/x11-apps/mesa-progs/mesa-progs-6.4.2.ebuild qmerge

Done. This is roughly equivalent to running emerge mesa-progs except that it works.

...Well, it compiles. It doesn't work. I can't seem to get my ATI card to work. I am saving that for the next post, though.... More: Click to Read/Comment

2006-04-04 14:13:20

Modular X on Gentoo (amd64) with GCC 4.1.0 and distcc

GCC 4.1.0 is hard masked in Gentoo currently and as I understand it is unsupported. Modular X is not yet listed as stable but is in the testing phase. I can't seem to get a cross compiling distcc setup without using GCC 4.1.0 because the crossdev package is unable to build the toolchain for 3.4.5 correctly (and selects 4.1.0 by default). So to make this work, I have to upgrade to GCC 4.1.0 on everything which up until modular X didn't cause any problems, but within the last 4 packages of the 108 needed for modular X, mesa-progs failed.

The truth is that I don't know if GCC 4.1.0 is to blame for the failure. I successfully emerged 98 of 102 packages, but failed on glxinfo in x11-apps/mesa-progs with the following:

x86_64-pc-linux-gnu-gcc -I../../include -Wall -march=athlon64 -O2 -pipe -m64 -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DUSE_X86_64_ASM -std=c99 -ffast-math glxinfo.c -L../../lib64 -lglut -lGLU -lGL -lm -o glxinfo

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XGetExtensionVersion'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XFreeDeviceList'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XQueryDeviceState'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XListInputDevices'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XFreeDeviceState'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XOpenDevice'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XmuLookupStandardColormap'

/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.0/../../../../lib64/libglut.so: undefined reference to `XSelectExtensionEvent'

collect2: ld returned 1 exit status

distcc[10000] ERROR: compile glxinfo.c on localhost failed

I looked up those undefined references and found the last one in libXmu.so and the rest in libXi.so. I added -lXmu -lXi to the build command and glxinfo.o build correctly.I don't know why GCC 4.1.0 might cause this problem. In fact, perhaps, it is an amd64 bug. Hopefully this helps someone. I will post something about how to fix it and build it with portage as soon as I read up on how to do that.

Since GCC 4.1.0 isn't supported, it isn't clear where I should post this bug since they might not yet consider it a bug. I imagine someone would like to know that the package is not yet forwards compatible, but don't know who to tell or how to tell them.... More: Click to Read/Comment

2006-03-30 15:55:55

Geek Training

Here's a picture of me playing a really simple flash video game to entertain the boys. The game itself isn't loads of fun, but Ethan and Isaac love to sit on my lap and watch me make the Fancy Pants Man jump over the angry penguin. Ethan gets really excited. He asks me to play the "Pantsy Fants" game, and Isaac asks me to jump over the "Anggy Penggin."

[EDIT] The game can be found here for all that are interested.... More: Click to Read/Comment

2006-03-02 13:49:38

Entertainment System Comments

I have a page dedicated to my ideas for The entertainment system to end all entertainment systems. Comments on it can be posted to this blog.... More: Click to Read/Comment

2006-02-17 14:52:00

Elegant Data Representation Draft

I have set up a page to describe my idea for an elegant representation of data to replace the unelegant standard XML simply because I can't bear to work with it anymore than I have to. This should also fit nicely as a component in an application framework I've been conceptualizing for some time now too.

For now, all I have is a draft. The hope is that the draft will be clear about the basic concept of elegant data representation. Later, I will add technical specifications to the draft once they are complete. I would also like comments and questions on the draft. (They can be posted here as comments).... More: Click to Read/Comment

2006-02-17 14:35:16

Elegant Data Representation

The concept of Elegant Data Representation (EDR) is to provide a format for representing relational data in a transportable manner without sacrificing the normalization provided by its original relational structure. The goal of the standard is to be defined as simply as possible.

It is largely a replacement for XML, so where possible, this document will note where XML has a term corresponding to one of EDR's.

(This is currently a draft)

EDR data is organized into packages. It is the EDR package which is transmitted back and forth (in its serialized form). This package is analogous to an XML document. It can be thought of as a file if necessary, but it can exist as more than a file just as XML can be represented in different ways in memory depending on different DOM implementations. The structure of the EDR package will have a standardized serialization protocol for transport, and a standardized access model. But other than that, it may exist in any physical format which makes it possible to access the data using that standardized access model. EDR's serialization protocol is analogous to (but far different from) XML's syntax and well-formedness rules. The standardized access model is analogous to XML's DOM, XPath, and XQuery.

The EDR package is a collection of nodes and axes

Nodes in EDR are analogous to XML nodes except that there is no distinction made between element and attribute. The purpose for the distinction in XML is not clear. So it is absent from EDR because it would introduce superfluous complexity. Every EDR package has a root node. This is analogous to XML's document element and just provides an entry point or a frame of reference for queries.

Nodes, like XML nodes can have values. Currently the only type of value supported is text. This is like XML, but support of other values is expected before this draft is finalized. Also nodes are context points and lead to other nodes. In XML an axis which is the mechanism for traversing from one node to another (or in other words, relating one node to another) is either parent-child or sibling-sibling in nature. There is no such limitation in EDR. Axes are user-defined.

Axes are technically named relationships between nodes. This is difficult to explain from an XML perspective because XML handles the concept so poorly. Instead, it is easier to understand from a relational database perspective. In a relational database, you might have, say, customer, order, and product entities (tables). Each record in the customer table represents a customer. The customers have orders, and orders reference products. In a relational database, these are called relationships. In EDR, the concept is called an "axis" and goes a bit further. In an EDR package, you can traverse from a node representing a customer, down the "placed orders" axis to find the orders that the customer has placed. Then you could follow that down the "for products" axis to find the products. Following axes to related node sets is much like a "JOIN" in relational databases. However, in an EDR package, even the fields are accessed via axes.

EDR package data is accessed using a query which is very much like XPath or XQuery. The nodes that are returned are based on the nodes encountered by following named axes. The concept is quite simple but it might be difficult to grasp or apply at first glance. Axes are not related to a single XML construct, but rather the nature of relationships between nodes in XML.

Imagine that and EDR package is just a huge pool of nodes. The nodes may be values, such as "John", "Smith", "47," etc. Some nodes may not have values associated with them*, but are rather used as points to tie other nodes together (or, relate them, in other words). The job of relating the nodes falls to that of axes.

In XML, there might be an employee element which contains a firstname, lastname, and age element. The employee element doesn't have any value associated with it. It is just used as a node to "parent" the other two nodes or to "tie them together." The relationship of the employee element to the firstname element could be described as "child named firstname." And this is how the element is found by DOM implementations for XML. The EDR equivalent is to have an employee node with no value, and axis called "first name" which when followed from the employee node leads to the node containing the first name.

So now consider that you have an axis named "employee," one named "first name," one named "last name," one named "age," and one named "manages." Don't worry about the syntax of queries right now, just consider that you query nodes by forming a hierarchy of axes together. You can get the names of all employees by following the employee axis from the root node to all the employee nodes in the package. This changes your "context" to be the set of employee nodes. Now from this context, you can continue to follow the "first name" axis and the "last name" axis to get the names of the employees. You can then follow the "manages" axis to get the managers for those employees (which are other employees).

A few principles fall out of this.

  • Unlike XML, none of your nodes actually have names. Their purpose, or class, if they have one, is inferred from the axis that got you there. Note that this doesn't present a problem for a client that queried the information, because the axes returned are a result of the query the client sent.
  • EDR data remains normalized. There is no reason to repeat any data in an EDR package. If one node is related to several other nodes, axes are simply added for this purpose
  • A single EDR package can contain the results of several normal SQL-like queries without redundant data. So if a node is returned by more than one query, it is simply the target of more axes, but its data is not duplicated. This means that only the necessary data is sent from the database to the application. The application can then, with its original query, requery the returned EDR package, locally, for each individual part it needed, but the elements remain joined (matched up) within the package by axes. This also solves problems with recursive "joins."


* note: currently it bothers me that some nodes may or may not have values associated with them. Perhaps that's not a problem, but to me adds an extra layer of complexity that I'm not sure needs to be there... More: Click to Read/Comment

2006-02-15 01:12:37

Valentines Day Pic

Lynn and I on Valentines day wearing our shirts. Lynn bought me the "geek" shirt for my birthday, and bought herself this shirt a week later and hid it until Valentines day. We wore the shirts to the restaurant and received many comments on them. We even had a guy ask us if he could take our picture with his camera phone. (This is not his picture, though.   this picture was taken in our living room before we left).... More: Click to Read/Comment

2006-02-11 16:43:25

Wordpress 2.0 Photo Blogger Plugin

I love wordpress, but if you want to use wordpress as photo blogging software, it is somewhat lacking. Especially if you want it to be quick, easy, and something my wife can do. I have seen a few people tackle photos in different ways, but what I was looking for didn't seem to exist.

My photo blogger plugin allows you to center a post around an image. You begin the post by uploading an image. The system will keep the full quality image, and will also downsample an image for display. The downsampled image is resized to fit completely within independent maximum width and height specifications which are configurable.

A post is automatically created for you with the image attached and the display image placed inline complete with the code necessary to allow users to click the image and see when it was taken, and download or view the full quality version of it.

You can edit the post in the regular wordpress editor to add any extra text etc.

In the future, I expect to add the ability to show a "gallery" or something like that in the Categories list which will find all images and list the thumbnails and post titles.

The plugin is available for download here: wf-blogphoto.php.txt [warrenfalk.com]

If you're new to wordpress plugins, simply download it, remove the .txt from the end and place in your wp-content/plugins folder.... More: Click to Read/Comment

2006-02-11 16:31:20

Contact Form on warrenfalk.com

The "contact" link has been sitting on the current version of my warrenfalk.com site which must be almost two years old if not more.   But it never actually did anything because I never got around to making it work.   Now I have.

Clicking "contact" shows a form on which you can enter a name, email, and a message, and even select a "priority" checkbox which will text my cellphone with the message.

I also have a "works" link on there now which I have to get around to building.   This will be a "portfolio" of some of my web design which I'm attempting to get back into.... More: Click to Read/Comment

2006-02-08 16:13:20

Wordpress and Themes

I've been doing a lot of work on my wordpress installation lately. I migrated my blog to it, then built a theme for it, then trashed it and built another theme for it. I then put up a family weblog and built a theme for that. Then I built a plugin which facilitates photo blogging. It turned out so well, that I think I'll polish that up some more and publish it. Just lateley I completed work on a website for my extended family on my Mom's side, 816pine.com. I also built a theme for that one and am reusing my photo blogger plugin. I expect that blog to require some other new plugins also.

I'm quite impressed with wordpress. So far, it is the easiest blog software I've worked with. Creating themes is easy and fun, and the extensibility through plugins is also the best I've seen so far. I am able to run all my different blogs by modifying the config file to load the config based on the site domain name. The only issue so far is some poor calculation of the upload directory filesystem path and url path which forces you to share the upload path among all blogs. I solved that by making a modification to the code to translate the filesystem path from the url path which is now configurable via the options pages in the admin area as of 2.0.1.... More: Click to Read/Comment

2006-01-24 00:14:20

The Family Weblog

I've completed my family blog now. The main reason for setting it up was so that Lynn could post pictures and things. This is something she's been willing to do for a long time, but I have just now finally gotten around to setting the whole thing up. The new blog is quite a good looking one if I do say so myself. Take a look at The Falk Family Weblog when you get a chance.... More: Click to Read/Comment

2006-01-23 15:24:03

New Blog

I have moved from my Textpattern blog to the much more popular Wordpress blog software. I'm still hosting it myself and have even created this new theme in which you are viewing this. So far I'm pretty impressed by Wordpress, judging it by the standards of other open source blogging software out there.... More: Click to Read/Comment

2006-01-04 17:59:30

About

Blog -

1. v. - Narcissistic authoring of online content in hopes a wandering visitor might read it and care.

2. n. - Online content read only by its author.

We blog. Do we do it because we can, because everyone else does, or because talking to ourselves as if we have a big audience was fun in private and is now acceptable if it's done online and called blogging?

Who cares why. If someone ever ventures, reads what I write, and cares, then that is pleasant icing on the cake. If I blog only for therapeutic benefits, then that, alone, is good enough for me.

This one's mine. I am the author, and the publisher. I pretend that people read it, and it makes me feel good.... More: Click to Read/Comment