When you process text with a computer program, sometimes you need to search for a string, and when you search for that string, sometimes you care whether the letters match exactly. That is, are they all the same case? All UPPERCASE, or all lowercase? Or MaYbE tHeY aRe AlL mixED up.
There is a set of standard string functions that come with all C Compilers. strstr(s1, s2) will perform an exact match. But what if you don't need an exact match, you just need the sequence of letters. Then you need stristr (case insensitive string search)! And where, pray tell, do you find stristr? Well, you can write your own, or you can download one from Code Snippets, or you can borrow the one I wrote. My first one used a somewhat crude approach. I copied the two strings into two arrays, forced all the characters in both arrays to be uppercase, and then used the standard strstr function to perform the search.
But then I got to thinking about it and realized it had a fairly serious limitation. It would only work on strings up to a certain length. What if I needed to look for a piece of text in a book? Or maybe even an encyclopedia? We don't want to have make a complete copy of a book just to search for a string. I mean computers are fast, and space is cheap, but we should exercise a little discipline here. So I rewrote it to only use the original strings. I use strchr to locate the first character, if it is there at all, and then do a character by character comparison to see if we have a match.
If I was using Microsoft's Visual C, I could have used stricmp, (case insensitive string compare), but it is also not a C standard, so there's a fine line there. Are we going to stick with standard library functions, or are we going to allow common extensions? Since we are not using hardware assisted scanning, it is going to run a little slower, but since we don't have to make the two copies, we are also saving a little time.
This is the kind of thing programmers do for fun when they aren't working. Both the old and new routines are stored as a Google Doc.
Silicon Forest
If the type is too small, Ctrl+ is your friend
Friday, March 12, 2010
Thursday, March 11, 2010
Gold Tooth Display
I asked her how much material she had ground off during all this and she tells me "microns". A micro is one millionth of a meter. When I worked as a machinist, measuring to the nearest thousandth of an inch was pretty standard. A sheet of copy paper is a couple of thousandths of an inch thick.
So she puts the tooth in and I bite down and it's blatantly obvious that the tooth is not meshing right with the opposite teeth. And it's just microns of material that are causing that? You would think that teeth would have a little more give in them, I mean they aren't mounted solidly to the bone. But I guess not. Of course, if you want to be able to cut something (like meat), you can't leave any space between the two cutting surfaces, i.e. your opposing teeth. Interesting.
But all this is just so I have an excuse to post this:
ZZ Top I'm Bad, I'm Nationwide
I used to really like ZZ Top. I don't listen to them much anymore. I've got all their tunes engraved in my brain. Maybe that's what's wrong with me.
Update January 2017 replaced missing pictures and video, though the video isn't the one I remember. Then again, maybe it's not the video I am remembering, but the image this song paints in my mind.
The Tourist
The Tourist by Olen Steinhauer
Not a great book, but pretty good. Really didn't get a feel for the main character. Maybe he was just too far removed from my world. Got a more positive vibe from his counterpart at Homeland Security. Maybe that's what this book is all about. Nominally it is a tale of a secret black ops group operating within the CIA that is performing assassinations at the behest of a Senator in an attempt to influence world affairs. A nice big fat conspiracy theory, just the way I like 'em.
Our hero, Milo (how's that for a heroic name?), works for this black ops group and is looking for this assassin, the same assassin his boss is running. Of course, he never finds him. Their boss doesn't want him found, but he has to pretend to look for him. Aren't conspiracies grand?
So China is getting a sizable chunk of their oil from Sudan and the Senator doesn't like China. He can't do much, but if he can poke them in the eye with a stick, he'll be happy. There is turmoil in the Sudan. The militant Jihadists are making a fuss. So our Senator sends the assassin over there to kill one of the mullahs. He does, and somehow it is made to look like the President of the country arranged it, which makes the Jihadists spitting mad and the turmoil turns into a full scale civil war. China won't be getting any oil out of Sudan for a while. The Senator is happy. The American Empire is still top dog!
But about that business with Homeland Security. The CIA certainly got tarred with a big brush, but Homeland Security got to be the good guys. Homeland Security, aren't those the guys the comics are always making fun of? Aren't those the guys arresting people without warrants? Now we've got a book portraying them as the good guys, well good relative to the CIA, which we all "know" is old, incompetent and corrupt. I wonder if maybe a directive came down from the top of the publishing empire that said we need some good press for this outfit. Yeah, let's pile one conspiracy on top of another.
Not a great book, but pretty good. Really didn't get a feel for the main character. Maybe he was just too far removed from my world. Got a more positive vibe from his counterpart at Homeland Security. Maybe that's what this book is all about. Nominally it is a tale of a secret black ops group operating within the CIA that is performing assassinations at the behest of a Senator in an attempt to influence world affairs. A nice big fat conspiracy theory, just the way I like 'em.
Our hero, Milo (how's that for a heroic name?), works for this black ops group and is looking for this assassin, the same assassin his boss is running. Of course, he never finds him. Their boss doesn't want him found, but he has to pretend to look for him. Aren't conspiracies grand?
So China is getting a sizable chunk of their oil from Sudan and the Senator doesn't like China. He can't do much, but if he can poke them in the eye with a stick, he'll be happy. There is turmoil in the Sudan. The militant Jihadists are making a fuss. So our Senator sends the assassin over there to kill one of the mullahs. He does, and somehow it is made to look like the President of the country arranged it, which makes the Jihadists spitting mad and the turmoil turns into a full scale civil war. China won't be getting any oil out of Sudan for a while. The Senator is happy. The American Empire is still top dog!
But about that business with Homeland Security. The CIA certainly got tarred with a big brush, but Homeland Security got to be the good guys. Homeland Security, aren't those the guys the comics are always making fun of? Aren't those the guys arresting people without warrants? Now we've got a book portraying them as the good guys, well good relative to the CIA, which we all "know" is old, incompetent and corrupt. I wonder if maybe a directive came down from the top of the publishing empire that said we need some good press for this outfit. Yeah, let's pile one conspiracy on top of another.
Wednesday, March 10, 2010
Paste Special
While I was looking at monitors on NewEgg, I came across their comparison function. They put a great deal of data into their chart, but it was a little hard to deal with, so I thought I would put it in a spreadsheet. So select, copy, paste, apply a little AEDIT magic, and presto we have a CSV file that can be loaded into a spreadsheet. Well, sort of. Google Doc's couldn't handle it, so I pulled out my copy of Calc, the Open Document Spreadsheet program.
Now I have the data in a spreadsheet, but the data is in columns. That is the data for each monitor is in a separate column. Can we put it rows? I've tried this before but I've never had any luck. This time I use the terms "row major order" and "column major order" when I do a search on Google, and it comes back with a link on using Paste Special in Microsoft Excel.
I've seen Paste Special before, but I had always ignored it, figuring it probably had something to do whether to copy formatting information or not, and I just didn't want to learn any more about Excel than I had to. You start down that road and pretty soon you are worrying about whether the shadows under your title fonts are dark enough. Bad, bad, bad.
But here is the Paste Special dialog box and there is one little check box marked Transpose! Just what the doctor ordered. Takes all your columns of data and puts it in rows, and vice versa.
Turns out there was an endless amount of information in the stuff I copied from NewEgg, so it would have taken a spreadsheet with a thousand columns to cover all the possibilities, most of which only applied to one or two monitors. So I abandoned that project. I had enough information for my purposes, and as I bonus I learned how to transpose a spreadsheet. That might actually be useful someday.
Update January 2017 replaced missing image.
Now I have the data in a spreadsheet, but the data is in columns. That is the data for each monitor is in a separate column. Can we put it rows? I've tried this before but I've never had any luck. This time I use the terms "row major order" and "column major order" when I do a search on Google, and it comes back with a link on using Paste Special in Microsoft Excel.
I've seen Paste Special before, but I had always ignored it, figuring it probably had something to do whether to copy formatting information or not, and I just didn't want to learn any more about Excel than I had to. You start down that road and pretty soon you are worrying about whether the shadows under your title fonts are dark enough. Bad, bad, bad.
But here is the Paste Special dialog box and there is one little check box marked Transpose! Just what the doctor ordered. Takes all your columns of data and puts it in rows, and vice versa.
Turns out there was an endless amount of information in the stuff I copied from NewEgg, so it would have taken a spreadsheet with a thousand columns to cover all the possibilities, most of which only applied to one or two monitors. So I abandoned that project. I had enough information for my purposes, and as I bonus I learned how to transpose a spreadsheet. That might actually be useful someday.
Update January 2017 replaced missing image.
Pivot Monitor
PDF files are a pain.
They are a staple of electronics engineering. For every integrated circuit that a company produces, there is a bunch of technical information that goes along with it. Engineers use this information to design electronic circuits. The amount of information required to make use of a chip (an integrated circuit) varies widely. It may just be a single page or it could be hundreds of pages. The information on the processor I have been working with has 28 chapters, each of which is around 50 pages long for a total of over a thousand pages.
The companies that make these chips used to publish "data sheets" about their chips. The data sheets from just one company for one year could easily fill a bookshelf. Now companies put this information into PDF files that you can download from the web. It is nice that companies make technical information available on the web. It saves having a bookshelf full of data sheets, most of which you won't need. On the other hand, these documents arePDF files, and are typically formatted to be a page in a book, i.e. long way up, or, as the Windows printer setup dialog calls it, "portrait orientation".
Portrait orientation does not agree with your typical computer monitor screen, which is wider than it is tall (also called landscape orientation). Adobe Acrobat (a computer program used for viewingPDF files) has two basic settings:
If you choose to have the width of the document fill the width of the screen, the text is much larger and easier to read, but you can no longer see the whole page at a glance. The bottom half is cut off. To see the bottom half of the page, you have to scroll down. If you start scrolling down a screenful at a time, the page breaks start moving into the middle of the screen. I don't want the page breaks in the middle of the screen. I want the page break at the top or the bottom. So I click on Next Page to see the top of the page, and then I scroll down one screen's worth to see the bottom of the page. Then to maintain synchronization, I click Next Page again. So I am constantly shifting back and forth between the scroll bar and the Next Page button. Bah.
But wait, this document is formatted like a printed page, and I have a printer. I could print it! So I did print a couple of chapters. Using the print odd pages only selection on the printer dialog, followed by turning the paper over and loading it back into the printer and then using the print even pages only selection, I was able to produce a two sided copy, which means fewer notebooks full of paper.
When I worked in Beaverton I would occasionally have Kinko's print a copy for me. They could do the double side printing and the three hole punch for no more than a regular copy. Only problem was I had to burn thePDF onto a CD-ROM and then hand carry it over there. They were supposed to have some fancy corporate upload system, but I never got it to work. I did find one copy house that would accept PDF's sent via e-mail, but they managed to screw up the holes punched in edge of the document.
So I'm trying to print my own documents. The first chapter comes out okay, but the next one I manage to botch. Not once, but three times. Printed the second side on top of the first, printed the second page upside down, printed the second page in reverse order. Come on, dude, get it together! Finally get my ducks in a row, and the printer runs out of ink! Hey I just put that cartridge in there! Fine, I'm working, I can afford a new cartridge. Run down to Office Depot and pick up a pair (color and black & white) for $50. Over the next month or so I print 3 more chapters and I am out of ink again. Uh, this is going to get expensive, maybe there's another solution.
Well, yeah, LCD flat panel displays are pretty cheap. You can buy one for about $200. Can I get one that would be tall enough? My current display is 1280 x 1024. 1280 is wide enough, but 1024 is not tall enough. 1280 pixels for an 8 and 1/2 inch wide sheet of paper works out to about 150 pixels per virtual inch. So we would need about 1650 lines to show the whole page, top to bottom, at a resolution that would be readable. Looking on Newegg, there are no monitors with 1650 lines (look under Recommended Resolution in the left hand column). The highest they have is 1600 lines, and those monitors are all over $1,000.
Hey! Here's an idea: how about if we turn the monitor sideways? That would do the trick. Of course there is probably gonna be some glitch with the driver, but that's just software, I'm sure someone has a solution for that. So does anyone make a monitor with a bracket that will allow you to turn it sideways? That took me a couple of days and several inquiries to get an answer. Turns out, yes, but you have to hold your mouth just right when you ask the question, or you won't find nothin'.
Thanks to my friend Marc and Bryan Paulsen of Portrait Displays, I discovered the key to finding displays that can be turned sideways. (Okay, you can turn any display sideways, it's not like they are sensitive to gravity or anything. But I want one with a bracket that supports this kind of thing. I don't want to have to cobble together my own bracket.) The key word, at least inNewEgg-land seems to be Pivot. There are displays the Swivel, displays that Tilt, and displays that Pivot. I understand Tilt to mean the display can be moved around an axis that is horizontal and parallel to the screen. But what's the difference between Swivel and Pivot? Don't they both mean the same thing?
Ah, bucky, now that's what separates us from the brainiacs at NewEgg. They know that Pivot and Swivel mean different things. Actually, they are morons. Pivot and Swivel do mean the same thing. They just chose to have them mean different things and then didn't tell anybody what those secret meanings were. Of course they don't care. For every techo-geek who wants a monitor than can be turned sideways, there are ten thousand slobbering video gamers who just want a bigger, better, wider display. We (the techo-geeks) are lucky that anyone even make displays that Pivot.
So I did some more searching at Newegg. I found four monitors that had a resolution of at least 1650 by 1280 but they were all over $2,000. Their resolution was also almost twice what I needed (2048 x 1536 or 2560 x 1600). If I relax my requirements slightly, we find some that can be purchased by mere mortals:
While I am poking around on NewEgg I discover that one of the Samsung Monitors includes "Magic Rotation S/W (Pivot)". Now that would be a deal!
Update January 2017 replaced missing picture.
They are a staple of electronics engineering. For every integrated circuit that a company produces, there is a bunch of technical information that goes along with it. Engineers use this information to design electronic circuits. The amount of information required to make use of a chip (an integrated circuit) varies widely. It may just be a single page or it could be hundreds of pages. The information on the processor I have been working with has 28 chapters, each of which is around 50 pages long for a total of over a thousand pages.
The companies that make these chips used to publish "data sheets" about their chips. The data sheets from just one company for one year could easily fill a bookshelf. Now companies put this information into PDF files that you can download from the web. It is nice that companies make technical information available on the web. It saves having a bookshelf full of data sheets, most of which you won't need. On the other hand, these documents arePDF files, and are typically formatted to be a page in a book, i.e. long way up, or, as the Windows printer setup dialog calls it, "portrait orientation".
Portrait orientation does not agree with your typical computer monitor screen, which is wider than it is tall (also called landscape orientation). Adobe Acrobat (a computer program used for viewingPDF files) has two basic settings:
- Fill the whole width of the window (or screen) with a page of the document, or
- Fit the whole page on the screen.
If you choose to have the width of the document fill the width of the screen, the text is much larger and easier to read, but you can no longer see the whole page at a glance. The bottom half is cut off. To see the bottom half of the page, you have to scroll down. If you start scrolling down a screenful at a time, the page breaks start moving into the middle of the screen. I don't want the page breaks in the middle of the screen. I want the page break at the top or the bottom. So I click on Next Page to see the top of the page, and then I scroll down one screen's worth to see the bottom of the page. Then to maintain synchronization, I click Next Page again. So I am constantly shifting back and forth between the scroll bar and the Next Page button. Bah.
But wait, this document is formatted like a printed page, and I have a printer. I could print it! So I did print a couple of chapters. Using the print odd pages only selection on the printer dialog, followed by turning the paper over and loading it back into the printer and then using the print even pages only selection, I was able to produce a two sided copy, which means fewer notebooks full of paper.
When I worked in Beaverton I would occasionally have Kinko's print a copy for me. They could do the double side printing and the three hole punch for no more than a regular copy. Only problem was I had to burn thePDF onto a CD-ROM and then hand carry it over there. They were supposed to have some fancy corporate upload system, but I never got it to work. I did find one copy house that would accept PDF's sent via e-mail, but they managed to screw up the holes punched in edge of the document.
So I'm trying to print my own documents. The first chapter comes out okay, but the next one I manage to botch. Not once, but three times. Printed the second side on top of the first, printed the second page upside down, printed the second page in reverse order. Come on, dude, get it together! Finally get my ducks in a row, and the printer runs out of ink! Hey I just put that cartridge in there! Fine, I'm working, I can afford a new cartridge. Run down to Office Depot and pick up a pair (color and black & white) for $50. Over the next month or so I print 3 more chapters and I am out of ink again. Uh, this is going to get expensive, maybe there's another solution.
Well, yeah, LCD flat panel displays are pretty cheap. You can buy one for about $200. Can I get one that would be tall enough? My current display is 1280 x 1024. 1280 is wide enough, but 1024 is not tall enough. 1280 pixels for an 8 and 1/2 inch wide sheet of paper works out to about 150 pixels per virtual inch. So we would need about 1650 lines to show the whole page, top to bottom, at a resolution that would be readable. Looking on Newegg, there are no monitors with 1650 lines (look under Recommended Resolution in the left hand column). The highest they have is 1600 lines, and those monitors are all over $1,000.
Hey! Here's an idea: how about if we turn the monitor sideways? That would do the trick. Of course there is probably gonna be some glitch with the driver, but that's just software, I'm sure someone has a solution for that. So does anyone make a monitor with a bracket that will allow you to turn it sideways? That took me a couple of days and several inquiries to get an answer. Turns out, yes, but you have to hold your mouth just right when you ask the question, or you won't find nothin'.
![]() |
| SAMSUNG 2243WM Black 22" 5ms 16:9 Widescreen LCD Monitor w/Height Adjustments |
Ah, bucky, now that's what separates us from the brainiacs at NewEgg. They know that Pivot and Swivel mean different things. Actually, they are morons. Pivot and Swivel do mean the same thing. They just chose to have them mean different things and then didn't tell anybody what those secret meanings were. Of course they don't care. For every techo-geek who wants a monitor than can be turned sideways, there are ten thousand slobbering video gamers who just want a bigger, better, wider display. We (the techo-geeks) are lucky that anyone even make displays that Pivot.
So I did some more searching at Newegg. I found four monitors that had a resolution of at least 1650 by 1280 but they were all over $2,000. Their resolution was also almost twice what I needed (2048 x 1536 or 2560 x 1600). If I relax my requirements slightly, we find some that can be purchased by mere mortals:
- HP LP2065 with a resolution of 1600 x 1200 for $400
- 5 units with a resolution of 1920 x 1200 for $400 to $600
- 10 units with a resolution of 1680 x 1050 for $200 to $400
- 4 units with a resolution of 1920 x 1080 for around $300
While I am poking around on NewEgg I discover that one of the Samsung Monitors includes "Magic Rotation S/W (Pivot)". Now that would be a deal!
Update January 2017 replaced missing picture.
Monday, March 8, 2010
Anomalous Acceleration of Pioneer 10 and 11
![]() |
| Pioneer Spacecraft |
The difference between how fast Pioneer 11 is going and how fast they think it should be going is about:
8 x 10^{-8} cm/s^2
which is the same as eight hundred picometers per second squared. (A picometer is one trillionth of a meter. Pretty stinking small.) "Per second squared" means this is a change in velocity, or acceleration. This works out to be about two centimeters per second per year (2 cm/s per year), BACK TOWARD THE SUN, so it is slowing down, or decelerating. Pioneers velocity when we last heard from it (1995) was 11.6 km/s.
- 11.6 km/s is 11,600 m/s.
- 2 centimeters is 0.02 meters.
- 11,600 meters divided by .02 meters is 580,000
Update September 2016 replaced missing picture.
Poupée de cire, poupée de son
I'm reading The Tourist by Olen Steinhauer, a modern day tale of espionage, and he mentions this song, so I go look it up. It was a big hit in Europe in 1965. A nice light pop number sung by a pretty girl, but I don't go much for the orchestral music. I can see someone somewhat older than me who had heard it when they were a teenager having an affection for it, but someone younger? I don't think so, but then there is no accounting for taste. Lyrics here.
Poupée de cire, poupée de son is French for Doll of wax, doll of bran (or song). Poupée de son can mean either a doll stuffed with Bran, like a raggedy Ann, or singing doll, one with a string you pull.
Poupée de cire, poupée de son is French for Doll of wax, doll of bran (or song). Poupée de son can mean either a doll stuffed with Bran, like a raggedy Ann, or singing doll, one with a string you pull.
Subscribe to:
Posts (Atom)


