Older blog entries for amars (starting at number 321)

One could easily put together a comic strip satirizing what I have to deal with for work. It's hard to take these people seriously when they, well, erm, can't be taken seriously. The next time someone uses a particular buzzword with me, i feel like saying "You have no idea what you are talking about do you."

George W. Bush does not speak for me.

Back from "Spring Break" to a world of stress. I had a good time at home and in Austin. The Molotov show at SXSW was great, they just released a new CD and as big as they are getting in Mexico, it was fun to be able to see them at a venue that supports less than 1,000 people. I ended up in the mosh pit for awhile until i found my way up to he front, almost losing a shoe in the process. Also managed to see a band called Libido, which apparently has gone triple platinum in Peru, in a very short period of time.

In a situation unrelated to Spring Break, i'm beginning to ask myself if it's better to regret something you've done or to regret something you have not done.

12 Mar 2003 (updated 12 Mar 2003 at 23:08 UTC) »
Interesting things are happening. A successful prosthetic hippocampus would spark the beginning of an era of cybernetic beings. In my honest opinion, the limbic system is what forms our personality, it makes us who we are. The hippocampus, part of the limbic system is responsible for essentially "routing" new memories into long-term storage. The scientific world would benefit in at least two areas. First, naturally, it would benefit patients who have lost the ability to form new memories (like in "Memento"). Secondly, a functioning silicon hippocampus that works in a real human being could be used in an artificial being and be the start of the first true artificial intelligence i.e. a human brain can be simulated in software and could actually gain consciousness, which ultimately would result in mechanical brains with consciousness i.e. androids.

Anyways, successful or not, it would make for some good science fiction. Imagine a big brotheresque world in which memories are implanted to alter the past.

[UPDATE] looks like the story has been picked up by both slashdot and boingboing, the comments by bloggers and slashdotters will be entertaining, to say the least.

This weekend I will be going to Austin to visit a cousin and check out SXSW, i'm hoping to catch the molotov show if possible. If not there are plenty of others i would like to attend.

7 Mar 2003 (updated 7 Mar 2003 at 06:49 UTC) »
IRC woes
Why do i get the feeling that all IRC daemons are the unholy spawn of BIND and sendmail when it comes to configuration and services. I'd kill for a modern (but very basic) IRC daemon that works with minimal configuration and has basic services. For my application, i don't even need the ability to link to other servers. Every time i try something, i produce a working daemon that, once started, lets me go in and create channels and chat as expected, but it is by no means configured properly to allow /oper and i can never get any of the services working, period.
deekayen: Actually, I just might have one you can borrow to see what all the fuss is about. After i got my powerbook, my G3 has been collecting dust. It's pre-Y2k and is slow, but it runs Jaguar. Let me know if you're interested.

I'm very close to losing what very little of my sanity is left. I'm to the point where I feel like continuing working the way I am is unhealthy and possibly a threat to my well-being. Not because i'm working too many hours, i'm still just working part-time, but because of my current situation and the people I have to deal with. I currently attend school on a full-time basis, studying something i'm very much interested in and fascinated by, while at the same time work part-time for two direct employers for several clients. I'm very seriously considering re-evaluating my employment situation in favor of something less stressful. My sanity is far too important to risk losing it for such little money for such pointless clients.

I ended up adapting my materialized path tree to use periods as separators and instead of bothering with sorting them with MySQL, i wrote a cmp_signatures function in PHP to pass to the usort function. It's not as elegant as i'd like it to have been, but it works reasonably well with as little obfuscation as possible. So, now i'm able to fetch all children of any given node with one query and sort them with one call to usort in order to produce an array of organized nodes.

I'm rather surprized that there isn't an equivalent to substr_count in MySQL. in order to effectively select all root children, i have to keep track of the depth of a node by counting the number of periods and storing that in a depth column. That way, i'm able to select all where depth=1 to fetch all root nodes.

Despite the otherwise empty apartment, i still felt the need to "go out" to get some work done so i could gather my thoughts. So, i'm in the student union now with my powerbook on wireless access. Having managed to solve a problem, i imagine i'll return to watch one of the DVDs i recently bought.

26 Feb 2003 (updated 26 Feb 2003 at 17:23 UTC) »
obi,jbucata: After reading the articles, the method i'm using is more or less a materialized path, only using colons instead of periods. It works great, as i've found and the article indicates for fetching full trees of children and parents , but as usual, the problem is ordering.

While the Netsted set, imho seems ideal, in this particular case i'm bound to the Stock MySQL 3.23 with MyISAM tables. I see the nested sets method as only being effective with stored procedures, transactions and table locking.

I managed to come up with a way to have MySQL return a sorted result set, but it requires first knowing how deep a thread goes (for successive concatinating) and the greatest number of digits in an identifier (for padding zeros). That can all be accomplished by storing metadata in additional columns and the process can be sped up by using an intermediate table of cached ordered threads.

The materialized path method will work even if i don't get an ordered set from MySQL, i can live with sorting the set in userland but naturally, would prefer to have MySQL do it. It's just a matter of testing to see what works best.

Thanks for the advice guys.

24 Feb 2003 (updated 24 Feb 2003 at 16:30 UTC) »
obi: much thanks, i'll definitely give it a try. As SQL goes, i generally prefer to do the heavy processing upon insert to minimize the processing load upon read as that's what gets done most often. Re-sorting in PHP is not something i want to have to do every time someone views a thread.

MySQL woes...

For while, actually for as long as i've been working with MySQL, i've been trying to figure out the best way to handle heirarchal relationships between rows. I have three goals, to fetch all children resulting from a single node, count all children from a single node and have them in their respective order.

This simplest, most obvious choice is to have a column to store a node id and a column to store the id of the node's parent. The problem with this method, with regards to MySQL, is to achieve my three goals, one would have to recursively traverse the database via sql call in a recursive function. While it's easy to, say, fetch the immediate children of any given node, it's not good when i want to fetch everything and have it in order.

My most recent attempt is as follows...

Two tables, one with the nodes and the other to handle the relationships. the node table isn't important... just know that there is a unique node id that corresponds to a node in that table. The other table, i call the signature table or more appropriately the relationship table. In the relationship table i have a unique relationship id, for the sake of being able to update/delete it from the command line, a node id, a node signature and a depth. node id is obvious, a node signature consists of the nodes id appended to it's parents signature, separated with ':' (example: :1:2:3:4:) and the depth, calculated upon entry into the database is how deep the node is in it's particular thread.

With such a method, i am able to achieve my first and second goal easily with the use of LIKE. The problem arises when i try to order the results from MySQL. First off, since the signature is text, ORDER BY orders the results alphabetically, which puts 10 before 9, so i can't do a straight ORDER BY signature. The solution is to break it up by parts and order by each part successively. But that requires prior knowledge of how deep the thread goes so you can construct a string of parameters to pass to ORDER BY, which is where the depth comes in.

So theoretically, upon proper depth calculation upon entry, i can achieve my goal in two SELECT statements, first the one to determien the length and the other to select with successive ORDER BY parameters. The next problem therein is the fact, again, that ORDER BY orders alphabetically, so 10 still comes before 9. The solution to that is to type cast it to decimal, which is only supported in 4.x, so i can't use that. The next option is to convert between bases. Since substring_index returns text, it can be seen as outputting a number of base 36 (0-9a-z), which mysql supports.

But that doesn't work either... for some reason MySQL isn't sorting beyong the first parameter... it seems to be ignoring the rest.

So, i'm at a loss. I was hoping i could do this without having to sort it via PHP. If someone knows about this type of thing, i'd be interested in some pointers in the right direction. This kind of stuff pops up all the time, most notably in comment systems. Right now my best option is to use my signature method to fetch all children and sort it with PHP. Sample query is below.

select substring_index(substring_index(signature,':',5),':',-1) as 'e',
substring_index(substring_index(signature,':',4),':',-1) as 'd',
substring_index(substring_index(signature,':',3),':',-1) as 'c',
substring_index(substring_index(signature,':',2),':',-1) as 'b',
signature_id,ticket_id,signature,depth from tickets_signature
order by conv(substring_index(substring_index(signature,':',2),':',-1),36,10) asc,
conv(substring_index(substring_index(signature,':',3),':',-1), 36,10) asc,
conv(substring_index(substring_index(signature,':',4),':',-1),36,10) asc,
conv(substring_index(substring_index(signature,':',5),':',-1) ,36,10) asc;

And resulting output...

+------+------+------+------+--------------+-----------+--------------+-------+
| e    | d    | c    | b    | signature_id | ticket_id | signature    | depth |
+------+------+------+------+--------------+-----------+--------------+-------+
|      |      |      | 1    |            1 |         1 | :1:          |     0 |
|      |      |      | 2    |            2 |         2 | :2:          |     0 |
|      |      |      | 3    |            3 |         3 | :3:          |     0 |
|      |      |      | 4    |            4 |         4 | :4:          |     0 |
|      |      | 14   | 4    |           14 |        14 | :4:14:       |     1 |
|      | 15   | 14   | 4    |           15 |        15 | :4:14:15:    |     2 |
|      | 16   | 14   | 4    |           16 |        16 | :4:14:16:    |     2 |
| 17   | 16   | 14   | 4    |           17 |        17 | :4:14:16:17: |     3 |
| 18   | 16   | 14   | 4    |           18 |        18 | :4:14:16:18: |     3 |
|      |      |      | 5    |            5 |         5 | :5:          |     0 |
|      |      |      | 6    |            6 |         6 | :6:          |     0 |
|      |      |      | 7    |            7 |         7 | :7:          |     0 |
|      |      | 10   | 7    |           10 |        10 | :7:10:       |     1 |
|      | 13   | 10   | 7    |           13 |        13 | :7:10:13:    |     2 |
|      |      | 11   | 7    |           11 |        11 | :7:11:       |     1 |
|      | 12   | 11   | 7    |           12 |        12 | :7:11:12:    |     2 |
|      |      | 8    | 7    |            8 |         8 | :7:8:        |     1 |
|      | 9    | 8    | 7    |            9 |         9 | :7:8:9:      |     2 |
+------+------+------+------+--------------+-----------+--------------+-------+

312 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!