Monday, December 29, 2008

another drawing

Dolphin, kinda.

Sunday, December 28, 2008

Got scanner to work, sorta

Got scanner to work... not well though. Getting some really weird periodic vertical stripes.


Wrote a program to workaround those. I simply divide all pixel in column by nth brightest pixel in that column, assuming that each column has some area of white paper. In other words, renormalize.

Processed scan:

Friday, December 26, 2008

Drawing.

Got a new hobby, pencil drawing.

Select few drawings:











Tuesday, December 2, 2008

AI chronicles #2

AI chronicles moved to separate blog, http://aistories.blogspot.com/

Friday, November 28, 2008

AI chronicles #1

I decided to start writing short fiction, mostly for fun.
You can read it there: http://aistories.blogspot.com/

Saturday, November 15, 2008

Hyperion nuclear.

Hyperion nuclear batteries are all over news lately...
Looks rather fishy to me.
According to Britannica, about 15% of heat in nuclear reactor core come from decay of fission products. Unlike fission, decay can not be controlled. For 25MW thermal, that is some 3.75 MW. And for 50MW thermal (which you need to get 25MW electric from turbines), that's 7.5MW Quite non-trivial amount of heat for a hot-tub sized thing, surely enough to melt it down.
I'm yet to see any mention of multiple redundant coolant pumps, or anything similar. Just that talk how it can not meltdown, which is pure bullshit.

Thursday, October 30, 2008

Making neat user interfaces.

I did grow increasingly dissatisfied with existing user interface libraries such as wxWidgets or Java Swing.
What i would rather like to see is a system where widgets are made from combinations of uniform basic building blocks. Like on websites, using HTML, CSS, and Javascript. I'd use that in my software, if not fact that HTML was never designed for that kind of use, and is too heavyweight while lacking in many things that you need for user interfaces.
So I decided to make my own. Sounds like typical yet another unusable reinvented wheel's story, doesn't it? ;)
Theres screenshot of very early version of that thing in action
On screenshot you can see: the style for that thing, the code that builds the UI, and image of button texture, that is used to make button borders (it is cut in 4 parts for corners, and stretched for edges).
You can think of it as of html-like + css-like system, rendered using OpenGL, yes, with full hardware acceleration.

Any widget is built from simple basic visual elements, Alignment (a thing that aligns whatever you put inside however you please, also handles padding), Grid (similar to tables in html), Box (similar to div in html), text labels of course (todo, editable text labels), combined with non-graphical "logic" object which handles various events and updates visual elements.
For example, a scrollbar could be a Grid, with 2 boxes for arrow buttons, and 3 boxes for space above scroll button, scroll button itself, and space below. Combined with logic object that handles movement of scrollbar and calculates scrollbar position.

Parameters are mostly supplied in a css-like way - you specify the stylesheet that gets applied to your user interface. That allows for easy and consistent styling. You could style the scroll bar same way as you could style buttons, or any other kind of boxes.

I'm still in phase of working on the underlying system and designing it, so at the moment i'm not building any widgets themselves yet (other than basic buttons to test event propagation).
The pretty looks are all defined with styling.

Thursday, October 16, 2008

Installing flash player 10 for 64 bit firefox (mandriva linux).

Need to write that down before I forget how I did it...
Step zero: look if real 64 bit flash player beta or something was released, if it finally was, you of course don't need that guide. Also, if you're using 32 bit firefox, you don't need guide either.

Installation:
Using package manager, install:
nspluginwrapper
libcurl for i586 architecture
libnss3 for i586 architecture
(the rpm package from adobe does not list dependencies correctly)
Then install the flash player 10 from rpm you can download from official adobe website here
I used flash-plugin-10.0.12.36-release.i386.rpm
Install it, by doubleclicking on it, choosing to install, and entering password.
As root, do:
nspluginwrapper -i nspluginwrapper -i /usr/lib/flash-plugin/libflashplayer.so
restart firefox, test if it worked.

Thursday, July 24, 2008

TopCoder match.

I've been rather busy lately and sort of losing interest in blogging again...
but finally i have something cool to brag about.

I've tried out topcoder.com for first time, and I got second place on a contest there.
TopCoder is a freelancing website that also runs various sorts of programming competitions. The contest that i did was about image recognition.
Given an image (binary, 0s and 1s), which contains 2 different textures in 2 separate regions of image(different textures as in say one squary blobs and other diagonal blobs), your program must identify the regions, and return image with ones for one region and zeroes for other region. For more info see problem description.
The program is run on many such images (500 for "provisional score" and 2000 for final tests) , and is scored by how accurately those are recognized.

This being first time i ever participated in programming contest, i did a lot of mistakes in overall design - at start i tried to write it in same style as i'd do at job (broken down into classes etc), however it was futile - i had no time for proper design, had to cut corners, and it got ugly anyway, plus i wasted time at start trying to make it nice.
#1 solution has average accuracy 97%, mine has average accuracy about 96.6% , or 0.4% from #1. (on my own tests with 10 000 cases) After contest end i discovered a tiny (doable in 2 lines, or 4..6 if as optional thing) change in my code that improves my score to same as #1.
Also, amazingly, top 3 algorithms are very different.
I'm gonna try another contest there soon if i have time, should hopefully do better.

Sunday, June 22, 2008

Firefox 3 bug.


Just installed Firefox 3 on Mandriva.
Got a bug: incorrect rendering of cursor and stuff in text input boxes (sometimes on text boxes on the webpages too). I guess it works with some fonts, but not all.
What the f* . Looks like off-byone bugs - in programming, thats a mark of a "n00b".

Tuesday, June 17, 2008

More photos








Saturday, June 7, 2008

Biking: photos.

Some photos i took when biking to the park and around city:



(the halo is from prev. week)





(I'll add more photos to this post as i prepare them with gimp)

Tuesday, June 3, 2008

Installing Mandriva; adding new Western Digital HDD

I spent half weekend biking and other half installing Mandriva Linux (version 2008 "One" , spring) on my "server box", the one i replaced capacitors on. Also, on monday I got new SATA hard drive.

The biking deserves its own blog post with photos, though i didnt see or photo anything particularly interesting. Thats the thing with biking, you make bigger distance, but do much less photographing.

So i'll blog about Mandriva and new hard drive.

Installation was very smooth. However there is several nasty quirks in mandriva:
1: Mandatory reboot after fsck. Severety: VERY high. Fix: VERY trivial.
When i disconnected one of hard drives to troubleshoot some hardware issue, and tried to boot, it tried to fsck partitions on removed disk, fsck failed, and it asked for admin password or ctrl-d for continue. After ctrl-d it just reboots. After exiting admin mode, it reboots. Happens in failsafe startup as well. Very annoying.

Advantage of reboot after fsck, if any, seems very, very dubious. Linux only needs reboot when you modify the kernel. It is not windows which needs reboot after everything, and not OS X which needs reboots after many big installs.
Linux always did configure things the right way. So on Linux you normally have to reboot only when it is real, physical necessity, i.e. only after you change kernel.

Disadvantage is extremely massive for newbies: it makes system impossible to boot after one drive has been removed or failed. If course there is workaround - when it asks to repair manually, enter root password, then edit /etc/fstab . Or try init 3 .
Editing is very tricky when you do not have any normal console editor (i made a copy of fstab then used grep to filter out lines that i didnt want) and thats far beyond newbie. Especially when [s]he has 1 pc or no internet, and cannot get online to ask.
Negates the "linux is more reliable than windoze" entirely.
Solution is trivial: locating the idiotic commit that added this reboot behavior, and removing it.

2: It didn't detect my ram size properly, not even with explicit kernel option. I have 1280MB on this machine, thats 1024+256 MB. Mandriva's kernel detected 884mb = 1024-128-12 . I have AGP aperture size set to 128mb, so that might be it. Definately a bug, old ubuntu detected size correctly regardless of AGP aperture size.
Thats no big issue for me, I will rebuild kernel anyway, or install vanilla kernel. But would be bad for newbie.

Some linux tips, while i remember:
Mount drives with noatime,nodiratime option. That disables updating of access times on files (the time when file was last read). It gives much faster, less energy consumption system. In some cases, it gives >2x speedup.
Without this option, when you read file, the access time has to be written to disk. And it has to be written even if file is in buffer. That can more than double overhead for reading lot of tiny files.
I never need access times, and do not have any applications that uses them. Maybe back in seventies and eighties, access times did correspond to user accessing the file and were useful for cleanup and pinpointing unused files, but today, having all sorts of applications that read lot of files automatically and dont disable access time update, and having really cheap hard drives (i got 500gb for 75 Euro), access times are entirely meaningless.
More on access times: http://kerneltrap.org/node/14148

Now about the hard drive. I got western digital wd5000aaks drive (internal), 500GB , SATA2 capable, 3 years warranty.
Minor quirks>:
To connect it to old SATA (also known as SATA 1500 or SATA 150) controller, i had to add jumper (a tiny connector thingy) between jumper pins 5 and 6 . OEM package does not include jumper. You can ask for jumper (and bolts to install drive, too) at shop, any self respecting shop has surplus of those and will provide for free.
For pin numbering, consult label on hard drive. Its second column from the left when label is up and connectors are to the left of jumper slot. (the pin numbering starts from the right, dunno why) . BTW, my label didnt have print about the sata1.
NOTE: if you have different hard drive, do NOT connect jumper based on this blog post. Google for your specific hard drive!

By funny coincidence, some girl i know got same hard drive on same day. Besides jumper, she had to enable SATA in BIOS (some BIOSes have it disabled by default). Search for it in BIOS, check "integrated peripherals" section first.

Thursday, May 29, 2008

SolderNPlay technology...

My PC was becoming more and more crashy lately (I use Linux, normally once its up and running, it never crashes by itself), and was getting progressively worse, to the point that i had to disable all power saving features (apm, acpi, and hlt) as temporary remedy. When it crashed today, it was one crash too many, so i took pc apart and inspected motherboard more closely...
Not surprisingly, I found 5 suspicious-looking electrolytic capacitors near CPU.

3300uF 6.3v , 10mm diameter, slightly swelled tops (only visible when you take motherboard out from case, and look from side), manufactured by "OST ".
Same crapacitors removed from board:
(timeline: i bought replacement first, then removed bad caps)

Thats a common problem. Good article on the issue. With little googling i found OST="Taiwan Ostor Corporation", known crapacitor manufacturer.
Rule of thumb: if you have a chance to look at motherboard before buying, don't buy one with capacitors manufactured by unknown brands. Big Japanese-brand capacitors are good.

With more googling, i found this immensely useful page with list of suppliers:
http://www.badcaps.net/forum/showthread.php?t=613
, found closest shop (I am in Lithuania by the way, and that was http://www.lemona.lt/ . Very nice shop in Vilnius, with nice people). Bought replacement capacitors (with big manufacturer, Matsushita), unsoldered old ones, and soldered in replacements. Solder-n-play technology.

Took about two and half hours from crash to end of repair, including finding local shop and walking there. Sorry, no photos of finished board yet. My camera ran out of charge and I simply couldn't wait to check my fix :-). I can photo it later.

BTW. Interestingly, bad caps also feel very lightweight for their size. I think all the electrolyte have evaporated. I shall do autopsy...

Some guidelines on repair, for those who came here from google search:

Before you start:
Check your skills. I used to build various nice devices back in school days, and repaired relatively low tech things like radio and tv.
I wouldn't recommend capacitor repair to someone holding soldering iron for first time, unless its "repair or toss away" situation... Also, if you have some hi-tech device that you don't mind breaking irreparably, you can practice soldering and unsoldering capacitors on it.

Finding what to replace: Look for any capacitors whose tops look even a tiniest big swollen or a tiniest bit leaky. If one capacitor is bad, its good idea to replace all capacitors with same specs. Those are very likely to be bad too but not visibly so.
The problem with testing electronics by looks is that, often, failed capacitors look same as good ones.

Buying replacement: Replacement must have same or higher max voltage, same or higher capacitance (if higher, by reasonable amount of course, say, 2x should be allright. Higher values will increase charging time on startup), same or lower ESR (effective serial resistance), must fit in available space. At least 105 degrees Celsius max temperature (you will overheat leads while soldering; also higher max temperature translates into longer lifetime at your pc's temperature).
Choose big, known Japanese brand manufacturer. Even though they too make it in China, they usually use proper chemistry, unlike small companies.

What you need:
Steady hand.
Replacement capacitors. (get them before unsoldering anything)
Small wire cutter.
Soldering wire, alloy (the one i used is 70% tin 30% lead , if i recall correctly).
Soldering resin (or use soldering wire with resin core).
Soldering iron, any reasonable sized one will do. Something to keep iron on.
Optionally, solder sucker aka desoldering pump.
When you remove bad capacitor, the hole fills with soldering alloy, and you cant insert new one. You have to heat up the hole while trying to push through capacitor from other side. Which is difficult with thick multi-layer boards. I did that without soldering pump, but it was pain in the ass. I did heat up the hole from one side with tip of soldering iron, while pushing capacitor leads into hole from other side.

Grounding:
It really doesn't matter if you use properly grounded equipment or not, all that matters is that everything is at same potential (otherwise motherboard may be ruined).
Connect the soldering iron to common "ground" on the motherboard, using wire. You can unscrew a little screws on any port (parallel port, or serial, for instance) and use it to attach wire. Actually you can see that on photo above. After you connect, check with multimeter that tip of soldering iron got small or zero resistance to "ground" pins in power connector on motherboard, and that resistance between soldering iron tip and soldering iron mains is infinite.
This will save motherboard from being ruined by things like tiny leakage current from mains to the soldering iron. Connect yourself to that common ground. Ideally through resistor (in case your soldering iron begins to leak mains onto tip as you work).

Soldering:
If you are not familiar with basics of soldering, read tutorials and practice first, dont try to replace capacitors as your first soldering experience. Its not easy.
Don't forget about polarity(!). It is very important. If you wire polarized capacitor backwards, it will blow very soon. Theoretical physics types forget it all the time.
Avoid pushing soldering iron hard and at all cost avoid slipping soldering iron over board. Computer boards typically have hundreds of hair-thin tracks everywhere, and if you accidentally cut one, it'll be very difficult to fix.

Tuesday, May 27, 2008

A comment on so called "quantum cryptography"

I've been reading a lot about cryptography lately, and naturally, came across many "quantum cryptography" related discussions. Both proponents and opponents miss something really obvious. "Quantum cryptography" is a kind of *physical security*, not really a kind of cryptography.
Lets simply compare quantum cryptography(QC) hardware & maintenance of said hardware with one time pads (OTP) that you buy from someone. You can see that all the risks of one time pads apply to quantum cryptography. Attacker can copy pads, you say?* Attacker can modify quantum hardware on the way to you just as well, with modifications ranging from smart changes like removal of filters and other protection so that attacker could send pulses along the cable and deduce state from reflection, to trivial replacement of firmware with one that doesn't care about quantum stuff and just uses some stream cipher with key that attacker knows. Bad crypto looks exactly like good crypto.
(*which requires opening hard drive in the cleanroom if its single-read hard drive.)

In both cases security boils down to physical security and trust in potentially malicious third party. Physical objects have to be physically produced and delivered (QC hardware or those hard disks with one time pads) which you need to physically protect from attacker (there's really a lot of ways how QC hardware could be modified to make it insecure). In both cases you need to trust manufacturer that it isn't complete snake oil. In both cases you rely on armored truck delivery. 
With quantum cryptography theres far more extra risks though. Man in the middle for instance. Or flawed implementations. Working with single photons is hard, naturally you can expect that almost all working solutions use many-photon pulses that can be trivially eavesdropped on. Keep in mind that the crypto hardware manufacturer is not just some neutral third party. Its a company which would any time choose to use cheap fake stuff over real if they can get away with it. So far, crypto hardware manufacturers can get away with anything.

The crucial difference: quantum crypto is thousands times more expensive to deploy and maintain than one time pads. 

Quantum cryptography is indeed just fiction now. It does not solve any existing real problems, and it could not improve security comparing to normal one time pads. It is really interesting academic thing, but not a solution to any existing problems.

Standard, mathematical cryptography, with (for example) Diffie-Hellman key exchange, public/private keys,  and things like that is far more secure than either QC or OTP. Source code is not a black box with high precision optics (or snake oil) inside, it can be reviewed. You can even do key exchange entirely "by hand" using email and Mathematica or similar package, if you don't trust cryptographic libraries. You can use really bigass exponent sizes if you worry about new methods. 
(And if one is worried that general math functions in Mathematica have backdoors, well, better to put on tinfoil hat, disconnect from internet, and make computer starting from sand, with own software).

Snail photos





Not really technology related in any way... photos of a tiny snail i found on groceries. Its sitting on glass. To get the exposure right i had to put several layers of paper over camera's flash, and take a lot of photos to get few good ones. After photographing i released snail in park. No gastropoda has been harmed during production of this blog post :-)