First 100 users
Femtoblogger has just been rolled out to a corporate community of 150 users. Let the bug reports and feature requests roll.
Femtoblogger has just been rolled out to a corporate community of 150 users. Let the bug reports and feature requests roll.
Perhaps it isn’t fair, firefox 2 is the oldest of the browsers I am supporting, but could they make the editable html interface any less user friendly?
The editable region has to be in an IFRAME, I’d rather not restrict people to a fixed region of screen, but ok. Now the user clicks in the IFRAME to edit, but it won’t place the insertion point unless they happen to click on an element, so if you click in the bottom of the IFRAME you get no insertion point. That makes me create a special onfocus handler to place the insertion point someplace to get them started. Then in one final gesture of hostility, the insertion point placing code doesn’t work on an empty IFRAME, so I have to insert a nonbreaking space to open up a line for the insertion point (because a normal space gets an insertion point about 2 pixels tall.) All told, most of a day wasted to support bad decisions from the firefox coders. They should have tried to use it after they coded it.
I recently needed to install 10 motion detecting cameras on 5 doorways. My first thought was to use ethernet cameras, but at \$300 each that gets expensive. My second plan was to use Linksys WRTSL54GS units running OpenWrt and cheap web cameras with the ‘motion’ package. That would sort of work, but it takes far more CPU than those little boxes have.
The problem is that all that JPEG decoding, motion detection on 640x480 pixels, and JPEG encoding is just too much computation. Fortunately we can be simpler.
Many cheap web cameras have JPEG encoders built in and deliver their images as JPEGs, though sometimes missing a critical table. By keeping a copy of the original camera data it is possible to avoid the JPEG encoding step and just insert the missing data table.
We can do better though. We can avoid most of the decoding and also reduce the data for motion detection by a factor of 64. The key is that luminance of JPEG files is encoded in 8x8 pixel blocks. Each 8x8 pixel block has 64 coefficients which are used to regenerate the 64 pixels of data (more on these coefficients later). The first coefficient is the ‘DC’ coefficient, the average luminosity of the 8x8 block. This is outstanding for motion detection! We get a low pass filter, a factor of 64 data reduction, and all we have to do is not perform a bunch of multiplication and addition in the decoding process.
With a process like the following the tiny router hardware can each support two cameras at 640x480, color, 10 frames per second, motion detection on 5 frames per second.
Astute readers will notice that I can only afford to motion check every other frame with the two camera setup. I’m not happy about this. Essentially all of the CPU time is used in the Huffman decoding of the JPEG data. A long time ago in the age when Vax 8530s roamed my world and I was busy trying to move X-rays and MRIs to radiologists I wrote a state machine based Huffman decoder that could process 3mbits/second of input data, the fastest we could get over Ethernet at the time. Those were 4 MIP machines, these little routers are something like 200MHz. Each camera is generating about 4mbits/second. I have high hopes that this will be doable.
I have other fish to fry and probably won’t get around to the faster huffman code anytime soon. After I run these things for a week or so I’ll release the code in case anyone else wants to read it or use it. I attached the man page in case you wanted to peek at it.
Update: Looks like I have an evil twin in Alexander K. Seewald who has written autofocus software using the AC coefficients. I like his Huffman decoder. I must benchmark it against the slow one I’m currently using to see the range of differences.
When writing daemons there is always the question of “How will I check on the status as it runs?“. Solutions include:
I add one more:
libmicrohttpd is just the thing for embedding an HTTP server in your daemon. It adds about 25k to your code, a couple lines to start it and then a dispatching function you write to handle the requests.
It has three models, the least obtrusive of which it is to just let it make some threads and live in its own threads. The others are useful if you can’t tolerate threads, but you have to cooperate to get select() calls made.
I don’t think you’d want to let it take a slashdotting, so either keep it behind a firewall or check the incoming IPs.
It seems to be solid and well written, but I did notice that it raises a SIGPIPE that kills the host application when a connection closes in the middle of a request. (3 word fix in the source. Add MSG_NOSIGNAL to the SEND() calls) That was found in the first minutes of testing, so it doesn’t get the “bullet proof - use and forget” stamp of trust. Maybe after 6 months of daily use it can earn that.
openload, which is called openwebload at sourceforge, is a simple URL load tester. Just the right sized tool for checking if your spiffy new web page is efficient enough to be tolerated.
\$ openload localhost 10 URL: http://localhost:80/ Clients: 10 MaTps
355.11, Tps 355.11, Resp Time 0.015, Err 0%, Count 511 MaTps 339.50, Tps
199.00, Resp Time 0.051, Err 0%, Count 711 MaTps 343.72, Tps 381.68,
Resp Time 0.032, Err 0%, Count 1111 MaTps 382.04, Tps 727.00, Resp Time
0.020, Err 0%, Count 1838 MaTps 398.54, Tps 547.00, Resp Time 0.018, Err
0%, Count 2385 MaTps 425.78, Tps 670.90, Resp Time 0.014, Err 0%, Count
3072
<You press enter to stop the run>
Total TPS: 452.90 Avg. Response time: 0.021 sec. Max Response time:
0.769 sec
There is a Debian package.
Update: I couldn’t leave it alone. The attached patch will add bits/second reports. It is also worth noting that you can add ”-l number” to sample for a certain number of seconds, and a “-o csv” to put out a CSV line of the data at the end for easier scripting. Perhaps it needs a man page too.
Update: If you are an especially trusting sort of person you could install the Debian package attached and not have to build it yourself.
Update: Best wait on this. There is something odd going on with openload that is giving unstable results for bytes transfered. More diagnosis required.
I, like most people, started using Javascript without first learning it. That was sort of fine back when all we did was stick a little statement in an onclick. When you find yourself writing more than 60 lines of JavaScript it is time to actually learn the language.
The development folk at Yahoo have a Yahoo! UI Library: YUI Theater with some videos to straighten out your understanding of JavaScript, wrap yellow warning tape around the broken corners of the language, and generally get you in shape to write real software in JavaScript.
I recommend these:
That is about 3 hours of video. If improving your productivity and product quality isn’t worth three hours, you might try the 40 minute “JavaScript: The Good Stuff”.
A list of things that I might add to femtoblogger:
ifstat - A little like a vmstat for network interfaces. This is pretty handy for a quick look at network saturation without have to break out some massive GUIfied tool with a hideous interface.
asbestos:\~# ifstat -b -i eth0,eth1,eth2,eth3
eth0 eth1 eth2
eth3
Kbps in Kbps out Kbps in Kbps out Kbps in Kbps out Kbps in
Kbps out
13.44 19.06 914.15 953.60 0.00 0.00
0.00 0.00
9.73 10.71 632.22 630.49 300.84 286.86
5.27 4.72
21.01 23.73 211.98 226.27 0.00 0.00
0.00 0.00
2.23 3.33 260.78 281.29 293.32 315.72
5.80 4.72
3.47 6.03 180.47 227.07 0.00 0.00
0.00 0.00
There is a debian package. And note that “-b” option to report in bits/second instead of bytes. What kind of person measures network use in bytes per second?
And in the same vein: iostat is hiding over in the systat package on debian. Use it too.
In this category I make notes of useful linux tools and utilities that are perhaps newer than 1997. If, like me, you tend to use your existing knowledge to get the job done, this list might be useful to see some of the things developed in the past 10 years.
Femtoblogger now shows on IE7. Not too bad. It only took 2 hours to work out the layout problems.
The most severe is that max-width: 600px in the CSS file brings up a bug when used inside a table cell. The cell gets expanded as if there was no max-width so the table ends up expanding to fill the screen. All the articles were cowering against the lefthand border of the screen with the nav stuff still on the right. (Firefox does this too but only if you are clicking a link in a table cell. There went 120 minutes of my life for that one.)
My ultimate solution was to make IE use a width: 600px instead. There is now an IE only CSS file that is loaded after the real one and has a rule to patch that up. Thankfully the IE blokes must have known they were being a menace to society and they built a special comment hack into their HTML parser to let people cope.
<!--[if IE]>
<link rel=stylesheet type=text/css href=femtoblogger-ie.css>
<![endif]-->
… it would have been nice to have something similar in CSS, that would save a file and a download.
You can read more about this hack at CSS Hacks- The good, the bad, and the ugly- Conditional comments
Thanks
Steve
sgulick (at) wildlandsecurity.org