Archive for the Category » Code «

Wednesday, October 01st, 2008 | Author: Kalle

So I was seeing if I could possibly figure out how to get some kind of notification from LiveJournal when someone posted a comment to one of the syndicated posts from this blog there. (I should just tag on Stace’s functionality and ditch the syndication and make WP double-post automagically, but eh.)

So I tried going to different pages, and as I typed in “http://kalleblog.livejournal.com/feed/” and hit enter, I was greeted with a 404 error. I hope the LJ team doesn’t mind me quoting it in its entirety. It’s hilarious:

Page Not Found

I’m sorry, you’ve reached a page that I cannot find. I’m really sorry about this. It’s kind of embarassing. Here you are, the user, trying to get to a page on LiveJournal and I can’t even serve it to you. What does that say about me? I’m just a webserver. My sole purpose in life is to serve you webpages and I can’t even do that! I suck. Please don’t be mad, I’ll try harder. I promise! Who am I kidding? You’re probably all like, “Man, LiveJournal’s webserver sucks. It can’t even get me where I want to go.” I’m really sorry. Maybe it’s my CPU…no that’s ok…how bout my hard drives? Maybe. Where’s my admin? I can’t run self-diagnostics on myself. It’s so boring in this datacenter. It’s the same thing everyday. Oh man, I’m so lonely. I’m really sorry about rambling about myself, I’m selfish. I think I’m going to go cut my ethernet cables. I hope you get to the page you’re looking for…goodbye cruel world!

-the webserver

Error: could not find server

What other funny 404 errors are out there? This one got me curious.

Category: Code, Funny  | Tags: ,  | One Comment
Sunday, August 31st, 2008 | Author: Kalle

The Google Weather app needs some work. The circled thingie if mouse-overed, gives a helpful note that it may be snowing tomorrow, despite the 32°C/24°C note (32 celsius is about 86 fahrenheit for those who speak that language).

Category: Code  | Leave a Comment
Friday, July 20th, 2007 | Author: Kalle

Checkers Solved.

From the game’s 500 billion billion positions (5 * 10^20), ‘Chinook’ has determined which 100,000 billion (10^14) are needed for their proof, and run through all relevant decision trees.

Category: Code, Life  | Leave a Comment
Friday, June 15th, 2007 | Author: Kalle

For a long time, I’ve wanted to create something that is generally referred to as a “neural network”. The concept behind neural networks is the desire to “simulate” the decision-making that our minds are capable of and computers aren’t, namely “generalizing”.

A computer is very good at calculating insane algorithms or at following precise orders given to it from a program, but it’s incapable of the generalizing that we do everyday, for example when we see a human being that we’ve never seen before, and still acknowledge the fact that we are looking at a human being (or a ball, or a dog, or whatever). Neural networks are one of the solutions to this kind of generalizing.

In any case, since childhood, I’ve occasionally been hit with bolts of ambition to reproduce such a neural network, coming up with my own little ideas for how they could possibly work, and failing every single time. Well, I tried it again recently and pulled it off, and was in for a few neat surprises on the way…

Before I continue, though, the math for these things is sadly beyond my level of comprehension; I’ve had to stare myself blind at others’ code, guessing what some math professors might mean when they say [insert insane algorithms here], and so on — chances are my implementation is off the rocker by several miles, but it’s doing what I wanted it to, and that’s sufficient for now.

The implementation was basically a mishmash of “evolution-simulation” and “neural network”. A number of critters were added to an environment, and were given the alternatives “eat, drink, reproduce, or do nothing” every “cycle”. A number of factors decided when a specific decision was a) possible and b) a very good or very bad decision. If the decision was very bad, the “mind” of the critter in question was modified slightly to not think so highly of that particular action in those kinds of situations in the future. When a critter reproduced, there was a 5% chance the child mutated, i.e. random modifications made to its mind. This became a rather important aspect as it turned out later on. A critter could only reproduce once every 20 cycles, and if it tried earlier, the counter was reset to 0 (i.e. it’s a very bad idea to try when you can’t).

Once the critters ate and drank and, uh, reproduced efficiently enough, the population in the world literally exploded. After about a hundred cycles, they quadrupled in quantity, and kept going infinitely (or rather, until my memory ran out). Every time this happened, I made things trickier for them and reran the test, and without exception, they managed to (eventually) find a way to overpopulate themselves.

One of my first surprises was the fact that they realized that NOT EATING was a great idea. And it turns out they were right. All actions use up 2 cycles (if you do something, you have to idle the next cycle), and if they only drank they would, most of the time, survive long enough to reproduce before they starved to death. And by reproducing so much earlier than the other critters, they literally took over the world. (The reason they had to drink was because thirst increases at a higher pace than hunger, in conformity with how it works in the real.)

In order to cope with the ever present overpopulation problem, I introduced another factor — food availability. Food availability was per-race, and decreased as the population of the particular race increased. An overpopulated race had a much lower chance of finding food than a regular one, so what would happen was that, initially, a few dominant races would appear, grow to overpopulation, and then a number of them would die of starvation and they’d “fall down” to good levels again and go on their merry ways. So I figured that wasn’t very interesting, and decided to add the “turn-predator” syndrome.

The turn-predator syndrome basically comprises of this: an overpopulated herbivore-race has a small chance of “mutating”; if it does, 30% of its population branch off into a new, predating race. This can only happen if there are 0 predators in the world (when I initially let it happen at any time, predators eventually took over the world; then died out because they didn’t have any grassophiles to gnaw on).

Let me tell ya… when I did that, I wondered if I’d done something wrong somewhere. There was this perpetual, evil circle thing going on. The grassophiles would start off on their own, grow to a certain size, then one of them would branch into a new predator race, and then gobblegobble… they’d all die out in a few hundred cycles. Doesn’t matter how many of them there were, they’d simply vanish from the face of the planet. Whenever there was a wipe, the system would recreate ~300 random grassophile races and let them go until the same thing happened. Over and over and over again. Sometimes in a matter of 50 cycles, sometimes in a matter of 5000 cycles, but it kept on happening.

And then it struck me that the critters have an in-born desire to reproduce, but they did not have a desire to NOT reproduce, when reproducing was a bad idea (when the race in question is overpopulated). So I put that in, and boom!

Well, “boom!” is an exaggeration. The evil circles were gone anyway. After a few civilizations, they “got it”, and they got it in a very distinct way.

The ratio herbivore/predator was stubbornly stuck at ~5.5. That is, 5-6 herbivores in the world, for every predator. I also observed a precise pattern in how the world population increased…

Basically, there is an abysmal difference between the population that “is lucky but doesn’t get it (yet)” and the population that “gets it”. The former flutters up and down in wild, irregular manners, and either crashes (wipes) or gets a grip and gets it. The “gets it” population stays mostly still; it increases and decreases slightly, and occasionally it takes little jumps, upward. If plotted on a graph, it would look sort of like a stock report for a company that’s doing pretty well with both ups and downs, but an overall, green little line that kept going ever upward.

Something else I noted was when populations seemed to get it, but, somewhere, either due to bad luck or for some other reason, crashed. I kept thinking that the “system” was so incredibly fragile, but at the same time so surprisingly robust. Just like how biology classes teach you how eco systems function.

There’s a lot more, but to be honest, I somehow doubt anyone will read all this, so I’ll put an end here. I’m incredibly excited about seeing where this is headed, though, that’s for sure. The last couple of days, I’ve been able to focus on nothing else!

Category: Code  | 3 Comments
Saturday, June 02nd, 2007 | Author: Kalle

zwoc@zabre:~$ enrogue
Linux enrogue 2.6.8-2-686 #1 Tue Aug 16 13:22:48 UTC 2005 i686 GNU/Linux
n.
1. An unprincipled, deceitful, and unreliable person; a scoundrel or rascal.
2. One who is playfully mischievous; a scamp.
3. A wandering beggar; a vagrant.
4. A vicious and solitary animal, especially an elephant that has separated itself from its herd.
5. An organism, especially a plant, that shows an undesirable variation from a standard.

adj.

1. Vicious and solitary. Used of an animal, especially an elephant.
2. Large, destructive, and anomalous or unpredictable: a rogue wave; a rogue tornado.
3. Operating outside normal or desirable How could a single rogue trader bring down an otherwise profitable and well-regarded (Saul Hansell).

v. rogued, rogu-ing, rogues
v. tr.

1. To defraud.
2. To remove (diseased or abnormal specimens) from a group of plants of the same variety.

v. intr.

To remove diseased or abnormal plants.

[Origin unknown.]

(dictionary.com)

Last login: Sun Jun 3 02:04:38 2007 from zabre
zwoc@enrogue:~$ sudo halt
Password:

Broadcast message from root (pts/0) (Sun Jun 3 02:05:04 2007):

The system is going down for system halt NOW!
zwoc@enrogue:~$ who
zwoc pts/0 2007-06-03 02:04 (zabre)
zwoc@enrogue:~$ Connection to enrogue closed by remote host.
Connection to enrogue closed.
zwoc@zabre:~$

And thus my reign (heh) as sys admin ends after over 4 years of keeping enrogue running at my home. I’m hoping a lot of people benefited from it all, and it was all good fun. The reason I chose to stop is not because it got boring (although hardware needed replacing) but moreso because I won’t be able to maintain things once I move to another country.

Category: Code, Hardware, Life, Random  | 4 Comments
Friday, August 18th, 2006 | Author: Kalle

When I switched to Debian those years ago, X apps done from a su’d user didn’t work. I in fact decided that they don’t work, period, and for a good reason, so I stopped using them.

Today, I installed FF 2.0, and really wanted it to not use (read: mess up) my default profile. Despite this, I didn’t want it to ask me which profile to use whenever I started it. I know, I’m lazy that way. So the “su doesn’t do graphical” issue reoccured. And this time I decided that I have a good enough reason to look into it.

Update: gksu basically fixes the issue. A launcher with ‘gksu -u testy /usr/local/lib/firefox-2.0b1/firefox’ is enough. gksu is a GNOME application, but has equivalents for KDE, at least.

Friday, May 26th, 2006 | Author: Kalle

The following is a message written by Richard Stallman of the Free Software Foundation in 1994. I stumbled upon it on my computer and was struck by how well written it is, as well as how important a message it bears even today, 12 years later.
Pardon the lengthiness.

Why Software Should Not Have Ownersby Richard Stallman

Digital information technology contributes to the world by making it easier to copy and modify information. Computers promise to make this easier for all of us.Not everyone wants it to be easier. The system of copyright gives software programs “owners”, most of whom aim to withhold software’s potential benefit from the rest of the public. They would like to be the only ones who can copy and modify the software that we use.

The copyright system grew up with printing–a technology for mass production copying. Copyright fit in well with this technology because it restricted only the mass producers of copies. It did not take freedom away from readers of books. An ordinary reader, who did not own a printing press, could copy books only with pen and ink, and few readers were sued for that.

Digital technology is more flexible than the printing press: when information has digital form, you can easily copy it to share it with others. This very flexibility makes a bad fit with a system like copyright. That’s the reason for the increasingly nasty and draconian measures now used to enforce software copyright. Consider these four practices of the Software Publishers Association (SPA):

* Massive propaganda saying it is wrong to disobey the owners to help your friend.

* Solicitation for stool pigeons to inform on their coworkers and colleagues.

* Raids (with police help) on offices and schools, in which people are told they must prove they are innocent of illegal copying.

* Prosecution (by the US government, at the SPA’s request) of people such as MIT’s David LaMacchia, not for copying software (he is not accused of copying any), but merely for leaving copying facilities unguarded and failing to censor their use.

All four practices resemble those used in the former Soviet Union, where every copying machine had a guard to prevent forbidden copying, and where individuals had to copy information secretly and pass it from hand to hand as “samizdat”. There is of course a difference: the motive for information control in the Soviet Union was political; in the US the motive is profit. But it is the actions that affect us, not the motive. Any attempt to block the sharing of information, no matter why, leads to the same methods and the same harshness.

Owners make several kinds of arguments for giving them the power to control how we use information:

* Name calling.

Owners use smear words such as “piracy” and “theft”, as well as expert terminology such as “intellectual property” and “damage”, to suggest a certain line of thinking to the public–a simplistic analogy between programs and physical objects.

Our ideas and intuitions about property for material objects are about whether it is right to take an object away from someone else. They don’t directly apply to making a copy of something. But the owners ask us to apply them anyway.

* Exaggeration.

Owners say that they suffer “harm” or “economic loss” when users copy programs themselves. But the copying has no direct effect on the owner, and it harms no one. The owner can lose only if the person who made the copy would otherwise have paid for one from the owner.

A little thought shows that most such people would not have bought copies. Yet the owners compute their “losses” as if each and every one would have bought a copy. That is exaggeration–to put it kindly.

* The law.

Owners often describe the current state of the law, and the harsh penalties they can threaten us with. Implicit in this approach is the suggestion that today’s law reflects an unquestionable view of morality–yet at the same time, we are urged to regard these penalties as facts of nature that can’t be blamed on anyone.

This line of persuasion isn’t designed to stand up to critical thinking; it’s intended to reinforce a habitual mental pathway.

It’s elemental that laws don’t decide right and wrong. Every American should know that, forty years ago, it was against the law in many states for a black person to sit in the front of a bus; but only racists would say sitting there was wrong.

* Natural rights.

Authors often claim a special connection with programs they have written, and go on to assert that, as a result, their desires and interests concerning the program simply outweigh those of anyone else–or even those of the whole rest of the world. (Typically companies, not authors, hold the copyrights on software, but we are expected to ignore this discrepancy.)

To those who propose this as an ethical axiom–the author is more important than you–I can only say that I, a notable software author myself, call it bunk.

But people in general are only likely to feel any sympathy with the natural rights claims for two reasons.

One reason is an overstretched analogy with material objects. When I cook spaghetti, I do object if someone else takes it and stops me from eating it. In this case, that person and I have the same material interests at stake, and it’s a zero-sum game. The smallest distinction between us is enough to tip the ethical balance.

But whether you run or change a program I wrote affects you directly and me only indirectly. Whether you give a copy to your friend affects you and your friend much more than it affects me. I shouldn’t have the power to tell you not to do these things. No one should.

The second reason is that people have been told that natural rights for authors is the accepted and unquestioned tradition of our society.

As a matter of history, the opposite is true. The idea of natural rights of authors was proposed and decisively rejected when the US Constitution was drawn up. That’s why the Constitution only permits a system of copyright and does not require one; that’s why it says that copyright must be temporary. It also states that the purpose of copyright is to promote progress–not to reward authors. Copyright does reward authors somewhat, and publishers more, but that is intended as a means of modifying their behavior.

The real established tradition of our society is that copyright cuts into the natural rights of the public–and that this can only be justified for the public’s sake.

* Economics.

The final argument made for having owners of software is that this leads to production of more software.

Unlike the others, this argument at least takes a legitimate approach to the subject. It is based on a valid goal–satisfying the users of software. And it is empirically clear that people will produce more of something if they are well paid for doing so.

But the economic argument has a flaw: it is based on the assumption that the difference is only a matter of how much money we have to pay. It assumes that “production of software” is what we want, whether the software has owners or not.

People readily accept this assumption because it accords with our experiences with material objects. Consider a sandwich, for instance. You might well be able to get an equivalent sandwich either free or for a price. If so, the amount you pay is the only difference. Whether or not you have to buy it, the sandwich has the same taste, the same nutritional value, and in either case you can only eat it once. Whether you get the sandwich from an owner or not cannot directly affect anything but the amount of money you have afterwards.

This is true for any kind of material object–whether or not it has an owner does not directly affect what it is, or what you can do with it if you acquire it.

But if a program has an owner, this very much affects what it is, and what you can do with a copy if you buy one. The difference is not just a matter of money. The system of owners of software encourages software owners to produce something–but not what society really needs. And it causes intangible ethical pollution that affects us all.

What does society need? It needs information that is truly available to its citizens–for example, programs that people can read, fix, adapt, and improve, not just operate. But what software owners typically deliver is a black box that we can’t study or change.

Society also needs freedom. When a program has an owner, the users lose freedom to control part of their own lives.

And above all society needs to encourage the spirit of voluntary cooperation in its citizens. When software owners tell us that helping our neighbors in a natural way is “piracy”, they pollute our society’s civic spirit.

This is why we say that free software is a matter of freedom, not price.

The economic argument for owners is erroneous, but the economic issue is real. Some people write useful software for the pleasure of writing it or for admiration and love; but if we want more software than those people write, we need to raise funds.

For ten years now, free software developers have tried various methods of finding funds, with some success. There’s no need to make anyone rich; the median US family income, around $35k, proves to be enough incentive for many jobs that are less satisfying than programming.

For years, until a fellowship made it unnecessary, I made a living from custom enhancements of the free software I had written. Each enhancement was added to the standard released version and thus eventually became available to the general public. Clients paid me so that I would work on the enhancements they wanted, rather than on the features I would otherwise have considered highest priority.

The Free Software Foundation, a tax-exempt charity for free software development, raises funds by selling CD-ROMs, tapes and manuals (all of which users are free to copy and change), as well as from donations. It now has a staff of five programmers, plus three employees who handle mail orders.

Some free software developers make money by selling support services. Cygnus Support, with around 50 employees, estimates that about 15 per cent of its staff activity is free software development–a respectable percentage for a software company.

Companies including Intel, Motorola, Texas Instruments and Analog Devices have combined to fund the continued development of the free GNU compiler for the language C. Meanwhile, the GNU compiler for the Ada language is being funded by the US Air Force, which believes this is the most cost-effective way to get a high quality compiler.

All these examples are small; the free software movement is still small, and still young. But the example of listener-supported radio in this country shows it’s possible to support a large activity without forcing each user to pay.

As a computer user today, you may find yourself using a proprietary program. If your friend asks to make a copy, it would be wrong to refuse. Cooperation is more important than copyright. But underground, closet cooperation does not make for a good society. A person should aspire to live an upright life openly with pride, and this means saying “No” to proprietary software.

You deserve to be able to cooperate openly and freely with other people who use software. You deserve to be able to learn how the software works, and to teach your students with it. You deserve to be able to hire your favorite programmer to fix it when it breaks.

You deserve free software.

Copyright 1994 Richard Stallman
Verbatim copying and redistribution is permitted without royalty as long as this notice is preserved; alteration is not permitted.

Category: Code, Democracy  | Leave a Comment
Saturday, May 20th, 2006 | Author: Kalle

Today I spent 13 hours (15 really, if you count the 2 hour pause in between) writing elisp extensions to Emacs for Skotos interaction. It was wonderful, and I was pleased. And the world smiled upon me…

So I tell Nino, the one person on this planet who actually might be impressed about this. But alas, he’s afk.

So my boss immediately goes into “afk” mode when I IM him the glorious news.

So Sahra starts talking about peacocks in spring when I tell HER the news.

I guess it’s not as big as I think it is. But man, I’ve wanted this for over a year. And now it’s in my grasp. Happiness!

Category: Code, Software  | 3 Comments
Thursday, May 18th, 2006 | Author: Kalle

http://enrogue.com/setp/ (link is broken and won’t come back up)

Sorry, I just had to brag about that one. Way cool. Next is WYSIWYG. :)

Category: Code, Software, Work  | Leave a Comment
Thursday, May 11th, 2006 | Author: Kalle

Sometimes I smile. It can happen for a variety of reasons and in a variety of situations, and is not a unique concept of mine. In fact, most people that I know do smile. Some of them smile quite often, in fact. (I’ve stabbed those that didn’t and hid the bodies. No loss there.) Anyway, one of the times when I smile is when I run into something like this (non-coders, prepare for a disappointment):
http://www.cs.wcupa.edu/~rkline/perl2php/

I love stuff like that.

Category: Code  | 2 Comments