by Various

Welcome again to Stupid Programming Tricks. May is programming month! Actually, every month is programming month. Apparently we can't call it coding, since we're using C rather than assembly code—which is too bad, since “coder” sounds much more sinister and intelligent than “programmer”. Regardless, lately I've been wondering, am I the only Linux user in the world who didn't come from a UNIX background? The truth is, all this networking bother strikes me as a bit dull. What about normal coding? If Linux is going to sit anywhere other than on servers, it's going to have to be a multimedia OS. You may have noticed all of our Stupid Programming Tricks episodes deal with multimedia. Well, there's a method to my general idiocy. Already we can write scrolltexts, slide graphics over backgrounds, play music, synthesize sounds, fork processes and placate gcc. We can also log in as root and ruin our console screens, but that's beside the point.

This month, in honor of programming, we're going to make something neat. Yes, it's time to do something really cool and yet somehow worthy of the title “Stupid Programming Tricks”. To justify such, we must be explicit in doing something with no practical value. Hence, the point. What better way to say “Hello world!” than with a scrolltext? Hark, someone is senile—we have already done scrolltexts. Grrrr. How about a scrolltext that warps like a slithering snake?

Sine scrollers are an epitomal form of the scrolltext, not quite the pinnacle—for that, we'd need text that wraps in three dimensions, casting shadows and twisting like threads of deoxyribonucleic data—but an epitomal form, nonetheless. We're also going to cheat. Well, not really, but instead of doing clever programming tricks to save processor resources, we'll use a simple routine, since with SVGALib, it's the only thing we can do. Sine scrolling is a trick in itself, and I haven't found any tricks to make it less processor-intensive, short of adding new functions to SVGALib or lowering the resolution. It works on the 1MHz C64, and it ran on my 60 MIPS box with digital music in the background, so I reckon your 600 MIPS box won't suffer.

In order to make a sine scroller, we start with the makings of normal scrolltext: a physical screen for the actual display, a virtual screen for drawing and a scroll board to hold a graphic of our scrolltext. In our last scrolltext episode, we just copied the scroll board to the virtual screen and the virtual screen to the physical screen, doing all the scrolling in the scroll board and drawing our text as one graphic the width of the screen. This time, every single pixel-wide vertical strip of text will have a different Y coordinate from its neighbor when it gets drawn to the virtual screen from the scroll board. The only way to do this is to copy a 1x8-pixel strip, 320 times every refresh! That's about 19,200 function calls per second, even at a 60Hz refresh rate. Well, with processors that can handle hundreds of millions of instructions per second, it's not a big deal. My old box, which ran at 60 bogomips before it died last summer, could do a sine scroller with a really big 256-color font, star fields and raster bars in 640x480x256 with digital audio in the background. Remind me to dig that code off the hard drive and cover it some time. Today, we'll just use the standard 8x8 font in one color, to get the hang of the whole sine-scrolling thing.

Sine functions are beautiful. You can use them for anything, literally. A sine function has amplitude, phase, period and shift, and you can play tricks with these. For example, you can plug a sine equation into the amplitude, phase, period or shift on your first sine equation. These techniques are useful not only for making cool patterns; audio synthesis techniques rely heavily on plugging sines into sines. For our scrolltext, we could make a sine equation with a period of, say, 320, an amplitude of 90, and shift it to the exact middle of the screen. However, this would result in an unchanging sine pattern; that is, rather than slithering like a snake, the sine pattern would hold still like a serpentine pipe while the letters contorted through. It looks cool enough this way, but there's no sense of motion. To add motion, we play games with the phase; i.e., we keep cycling the phase so that the sine appears waving, up and down, like a snake.

Now, how steep do you want the sine? Well, that's a function of amplitude and period. Generally, we already have an idea of what amplitude we want (usually either full-screen or just bouncing along the bottom), so we play with our period. If you want a scrolltext that squeezes together and then stretches out, you can use a sine function to modulate the period. Now, we could also plug a sine into the amplitude, to move between flat-lining and squiggling, although it's not so useful.

Finally, you can also plug a sine into the shift in order to give a lot more variety to the scroller as a whole. The result actually looks quite neat, it's rather complex, yet visibly based on sines. There's an aesthetic quality here to be appreciated, the interplay between simplicity and complexity. In honor of sine waves, let's also grind our processors a bit by using sines to cycle the colors of our text; it'll look cool.

Now it's time for the code. Remember, it's just the same simple procedure as in our last scrolltext episode, only now we're using some sine equations to determine the y value for where our text gets placed, and a loop to draw out the text one 1x8 strip at a time. It's simple conceptually, although if you don't get it, try typing it in rather than downloading it and you'll probably understand exactly what's going on by the time you are done. Sines are some of the most useful things in the world, so even though we're using them for something silly, they have infinite practical use, and I hope this inspires some clever ideas for you!

—Jason Kroll

Listing. Fun With Sines
// gcc -Wall -O2 sine.c -lvgagl -lvga -lm
#include <vga.h> /* vgalib */
#include <vgagl.h> /* advanced */
#include <math.h> /* sines! */
#include <stdlib.h> /* malloc */
#define VGAMODE G320x200x256
GraphicsContext *physical_screen;
GraphicsContext *virtual_screen;
GraphicsContext *scroll_board;
int main(void)
  double a, b, c, d; /* amp, phase, period, shift */
  double aa,bb,cc,dd; /* random values for fun */
  short int p_pos, t_pos; /* pixel & text */
  short int x,y,z; /* y coord, x & z counters */
  char key; /* to wait for keypress */
/* The following text between quotes should be all
   one line. Ignore wrapping */
  char text[] = "....................................Hello happy world and welcome to another episode of Stupid Programming Tricks. This is our scrolltext, well the idea is that you replace this text with your megagreetings list or the number to your pirate BBS. I wrote this one on Conectiva Linux which has the coolest characters but SVGALIB won't print them properly. Please experiment with different values, and try plugging sines into other sines, you can create the most remarkable though often illegible effects. Shout outs to Rigor Mortis (Riggie!), Red Sector, Triad, Fairlight, Quartex, Cynas, DM, RAiD and everyone else who's still alive! Hy3n4 m4s f1n4 out.........................................";
  double textl=sizeof(text); /* text length */
  vga_init(); /* here begin standard inits */
  vga_setmode(VGAMODE); /* we'll allocate our */
  gl_setcontextvga(VGAMODE); /* graphics areas */
  gl_clearscreen(0); /* better clear the screen */
  scroll_board = malloc( (WIDTH/8+1)*8*8*BYTESPERPIXEL);
  scroll_board = gl_allocatecontext(); /* ready */
  a=b=c=d=x=y=0; /* amp, phase, period, shift */
  t_pos=p_pos=0; /* text & pixel position */
  aa=rand()%64+16.0; bb=rand()%64+16.0;
  cc=rand()%64+16.0; dd=rand()%128+128.0;
  /* main loop */
  for (key=0; key==0; key=vga_getkey()) {
    p_pos += 2; /* adjust speed here */
    /* this redraws the text at each new letter */
    while (p_pos > 8) {
      gl_writen(0,0,WIDTH/8, &text[t_pos]);
      t_pos++; /* advance text */
      p_pos-=8; /* reset p_pos */
      if (t_pos >= textl)
         t_pos=0; /* reset t_pos */
    /* These equations produce readable text
     * but please experiment to witness the
     * potential of illegible sine scrolling
    x+=1; /* a counter for more phase shift */
    for (z=0; z<320; z++) {
      a = 24*sin((z+x)/aa)+24;
      b = 64*sin((x)/bb)+32;
      c = cc*sin((z+x)/cc)+128;
      d = (32-a)*sin((x-z)/dd)+124-a;
      y = a*sin((z+b)/c)+d; /* standard format */
      gl_copyboxfromcontext(scroll_board, z+p_pos,
         0, 1, 8, z, y);
    gl_copyscreen(physical_screen); /* update */
    gl_clearscreen(0); /* otherwise it smears */
    vga_waitretrace(); /* hold still a*/
  return 0; /* on principle ;) */
  1. Total number of patented applications listed by the U.S. Patent & Trademark Office as of June 30, 1999: 2,090,902

  2. Percentage of those patents with foreign origins: 43%

  3. Position of Japan among foreign countries holding U.S. patents: #1

  4. Percentage of foreign-origin patents held by Japan: 41%

  5. Position of IBM among U.S. patent holders: #1

  6. Number of patents held by IBM: 20,725

  7. Position of Canon among U.S. patent holders: #2

  8. Number of patents held by Canon: 18,043

  9. Number of Japanese companies among the top ten U.S. patent holders: 6

  10. Number of patents held by Microsoft: 1,167

  11. Number of patents held by Walker Asset Management Corporation (best known for Priceline.com): 36

  12. Number of patents in which the name “Amazon.com” is mentioned: 9

  13. Number of patents held by Amazon.com: 7

  14. Number of patents that mention the word “Linux”: 49

  15. Percentage of those in which Linux is used to demonstrate the patent's purpose: 100%

  16. Revenues from patent licensing in 1990: $15 billion US

  17. Revenues from patent licensing in 1998: $100 billion US

  18. Number of shares of Microsoft stock owned by Bill Gates: 780 million

  19. Number of shares of Microsoft stock owned by Paul Allen: 260 million

  20. Number of shares Bill Gates filed with securities regulators to sell: 300,000

  21. Percentage change in the stock price of RHAT in the five weeks after the antitrust ruling: +218

  22. Number of feet by which Arctic sea ice has thinned since 1976: 4

  23. Number of colonies of Antarctic Adélie penguins that have disappeared since 1988: 11

  • 1-15: United States Patent & Trademark Office

  • 16-17: Upside

  • 18-20: PC Week

  • 21-23: Harper's Magazine


They shine like pearls in the bathwater, these seventeen-word “found haikus” that Don Marti extracted from the Linux HOWTOs. All are syllable counts for words that appear in the CMU pronounciation dictionary.

A super daemonis bloat for those who onlywant one small feature—Werner Hauser, Linux Laptop HOWTO

I suppose you haveto fiddle around a bitto get this working—Werner Hauser, Linux Laptop HOWTO

It only takes auser with a modem tocompromise your LAN—Mark Grennan, Firewall and Proxy Server HOWTO

Examples of smoothrunning existing systemsare also welcome—Stein Gjoen, HOWTO: Multi Disk System Tuning

CD-ROMs have aspiraling track much like anaudio record—Skip Rye, Optical Disk HOWTO

Rest assured that theycan determine that it's thereand will exploit it—Kevin Fenzi & Dave Wreski, Linux Security HOWTO

The one conditionis that credit is givenwhere credit is due—Harvey J. Stein, The UPS HOWTO

-Doc Searls


We have a highly skilled group of patent examiners with a technical background that matches up very well with the kind of technologies they are seeing—and we think we issue patents of an appropriate breadth.

—U.S. Patent & Trademark Office Commissioner Q. Todd Dickinson in IP Worldwide

Amazon.com Patents Enemy-Making Process

—Headline in The Industry Standard

Windows CE is an environment where Microsoft says, “This is what the reference design looks like, and as long as you build this, Windows CE will work on it.” Linux, on the other hand, is an erector set, where we design the reference hardware to meet the problem we're trying to solve and then go to Linux for the piece parts from the bin to build exactly what works.

—John Bork of Intel in an interview with Linux Journal

Open Source developers understand UNIX. This is part of what made it possible to create a better UNIX: Linux. In order to create a better MS Office, Open Source developers need to understand MS Office in as much detail as they understood UNIX. My fear is that the Open Source developer community doesn't understand Office. It can't create what it doesn't understand. What we need are more developers using Windows and Office.

—Larry Augustin, VA Linux Systems, at the New York New Media Association


Web pages use a publishing metaphor—they are pages, after all. We write, open, read and bookmark them. We assume when a page downloads from a server, it's a one-way deal. The HTML describes the page, lays out the print, loads the graphics onto the page and into the cache. There is the presumption of privacy. After all, this is a published page, and reading is a personal, even an intimate, act. At those times when interaction is required, such as when we fill out a form, there's a “submit” button that sends information back to the other end of the line. We're still in control.

Most of us know how cookies work. They carry the potential for evil, but most serious e-commerce sites are careful not to abuse a customer's trust. But the truth is, we are being watched—a lot—and not just by cookies. The following three web sites will be of interest if you are concerned about this issue—and you should be.

It turns out that some companies are including 1x1 transparent GIFs from the web ad agencies on some pages, so you can be tracked on pages where there's no visible ad. Example: http://www.fedex.com/us/tracking/—FedEx's package tracking page. (Who's tracking who?)

Please implement some kind of banner blocking, whether it's Junkbuster, the “webclean” configuration file for Apache proxy, Squid, or just making your name server authoritative for the domain names of the big web advertising agencies.

—Doc Searls


Light travels faster than sound. That's why some people appear bright until you hear them speak:

  • Me fail English? That's unpossible!

  • Engineers never lie; we just approximate the truth.

  • this .sig no verb

  • Windows 2001: “I'm sorry Dave, I can't do that.”

  • Eggs don't grow on trees.

  • Blessed is him who, having nothing to say, abstains from giving us wordy evidence of the fact.

  • Someone had to put all that chaos there!

  • Linux just happens to be one of the best forking kernels out there.

  • Stupidity should be painful.

  • Wouldn't 1/0 approach infinity?

  • militant agnostic: I don't know, and you don't know either.


ISO downloads by Volume:

the Mandrake downflow from Tucows continues to be huge: still #1, though down 4% from January. Corel edged past Red Hat for #2, though both rounded to 17%. That's up 3% for Corel and down 1% for Red Hat. #4 Debian is up 2% and #5 SuSE is down 1%. Slackware was up 1%, Caldera held even, and Stormix showed up for the first time with a 1% wedge of the pie.

Non-ISO by Volume

All by Volume

ISO by Number

Non-ISO by Number


A Real-Time Data Plotting Program by David Watt is an introduction to programming using the QT windowing system in X. Mr. Watt has written a real-time plotter application called RTP and tells us how he did it. This is freely available software, and you can join others in adding enhancements or use it to write your own application.

The Network Block Device by P. T. Breuer, A. Marín Lopez and Arturo García Ares tells us about this system component and how it can be used. Basically, an NBD driver will make a remote resource look as if it is a local device to Linux. Thus, it can be used to construct a cheap and safe real-time mirror.

Shell Functions and Path Variables, Part 3 by Stephen Collyer is the final article in our series to introduce you to path variables and elements. This month, Mr. Collyer talks about the makepath utility, more path-handling functions and a few implementation issues.

Linux Administration for Dummies is a book review by Harvey Friedman who gives us a taste of what this book is about and whether we should buy it.

WordPerfect for Linux Bible is another book review by Ben Crowder. WordPerfect is one of the most common word processors available. If you need help with this application, this book may be a good resource for you.

Python Programming for Beginners by Jacek Artymiak is a great introduction to this popular scripting language. A tutorial with many examples to help you learn the right way to code non-trial applications using Python. Once you've read it, you'll be ready to outsmart the Spanish Inquisition.

Python Conference Report is just that: a report on the conference held in Washington in January. Find out all about it in this article by Andrew M. Kuchling.


During the month of February (and the beginning of March), people were talking about:

  • Microsoft's convenient web-based system on their site that allows vendors to submit invoices. Michael Olson was there and found this message: “Note: Microsoft Invoice is not compatible with Netscape Navigator, Apple MacIntosh computers, or Linux.”

  • Copyleft, a company dedicated to helping further Open Source idealism, and their donation of $10,000 US to support the Electronic Frontier Foundation (EFF). The money is intended to aid the legal defense the EFF is mounting in response to lawsuits by the Motion Picture Association of America (MPAA) and the DVD Copy Control Association (DVD CCA). Show your appreciation: buy a T-shirt. Visit their site at http://www.copyleft.net/.

  • Rumors that Microsoft is considering porting Office to Linux. Arthur Tyde, executive vice president at Linuxcare, was told there are 34 developers working on this very thing at Microsoft.

  • The work done by Penguin Radio, Inc. and Ineva.com work on a Linux-based car radio with the capacity to receive thousands of stations. The radio hooks up with the the Ellipso Satellite Internet service, which uses a unique (and patented) system of satellite orbits to provide global Internet connectivity. This won't happen until 2002. Huff!

  • An e-mail concerning a new ad for Microsoft's Internet Explorer e-mail program. The ad uses “Confutatis Maledictis” from Mozart's Requiem as its theme music. The chorus sings “Confutatis maledictis, flammis acribus addictis.” This translates to “The damned and accursed are convicted to the flames of hell.”

STOP THE PRESSES: The Patent Conversation

As we enjoy great advantages from the inventions of others, we should be glad of an opportunity to serve others by any invention of ours; and this we should do freely and generously. —Benjamin Franklin

Patents are mines. They lay buried in the marketplace, doing nothing until their owners blow them up under an enemy. That's what Amazon.com founder and CEO Jeff Bezos did last fall, when Barnesandnoble.com stepped too close to Amazon's “1-click” patent (No. 5,960,411). Amazon pressed a charge, and a court injunction followed.

The bomb worked. It stopped Barnesandnoble.com from copying Amazon's work on the 1-click feature. It also blew Jeff's clothes off. Time magazine's Man of the Year—the leading entrepreneur of the New Economy—was exposed as an old-fashioned emperor of industry: a hard-ball player, a pointy-haired litigator.

At least, that's the way it appeared to the Open Source world, where captains of industry get the benefit of little doubt in any case. Calling almost immediately for a boycott, the conscience of free software, Richard Stallman, said:

This is an attack against the World Wide Web and against e-commerce in general. The idea in question is that a company can give you something which you can subsequently show them to identify yourself for credit. This is nothing new: a physical credit card does the same job, after all. But the U.S. Patent Office issues patents on obvious and well-known ideas every day. Sometimes the result is a disaster.

Not much happened after that, at least on the surface. Behind the scenes, however, Tim O'Reilly of O'Reilly & Associates began a correspondence with Jeff Bezos.

Then, on February 23, all hell broke loose. The United States Patent & Trademark Office assigned Amazon patent No. 6,029,141 for an “Internet-based customer referral system”. This covered Amazon's popular associates program, by which thousands of sites mount “bookstores” with sales fulfilled by Amazon.com. (To witness the program's popularity, search for the phrase “in association with amazon.com”.) There are many such programs operating on the Web, but Amazon's was the first and easily the most successful.

Amazon had applied for the patent back in 1997, but that didn't cut much ice with the open-source folks. A roar went up, and this time the press joined in. “Loss-making Amazon turns to bullying”, wrote the Irish Times. For the first time in its short life, Amazon.com was getting bad PR. If they hadn't sued Barnesandnoble.com over a different patent, it is unlikely anyone would have cared. In total, Amazon holds only seven patents. By contrast, IBM obtained 2,697 patents in 1998 alone.

Amazon's patents were all applied for prior to the land rush on “business process” and software patents after the floodgates were opened by State Street Bank & Trust Co. vs. Signature Financial Group Inc. On July 23, 1998, the Federal Court of Appeals upheld a lower court ruling that threw out what little discretion remained on the patenting of, well, nearly every marginally original way of doing business, including “processes” conducted by software. The Supreme Court later declined to review the case.

So Amazon stood alone in the spotlight. Yes, other Internet companies had sued to protect patents, but Amazon was the leading e-commerce innovator. Their patent policy mattered.

Enter Tim O'Reilly. In a series of “Ask Tim” columns and open letters, O'Reilly both challenged Bezos and invited him into the growing patent reform movement. A series of private conversations followed, culminating on March 10 with “An open letter from Jeff Bezos on the subject of patents” (http://www.amazon.com/patents/).

Crediting influence by O'Reilly, Bezos declared both his intent not to harm software development and a newfound commitment to patent reform. He did not hedge on his own patent policies, but neither did he appear to push them off the negotiating table. He also included a number of concrete proposals for reforming patent law.

Suddenly, the PR turned around. Columnist Dan Gillmor of the San Jose Mercury News, who had labeled Bezos one of technology's “villains” after the lawsuit against Barnesandnoble.com, wrote, “Bezos has a point on patents...” and “...it's a heartening sign of the Internet's power, and Bezos' management style, that this conversation is taking place at all.”

Will Bezos continue to straddle the fence? He faces a clear choice between his lawyers and his market. As both he and O'Reilly point out (crediting The Cluetrain Manifesto), markets are conversations. If he stops talking, we'll know his choice.

—Doc Searls


Andover.net and T.C.X DataKonsult AB, publisher of the MySQL relational database, announced a joint program to implement database replication in MySQL. Andover will provide financial assistance, source code and technical assistance to the MySQL team. All enhancements will be made available to all users of the product. More detailed information can be obtained at www.andover.net/ and www.mysql.com.

Linux Support Group, LLC announced plans to open its Silicon Valley Support Center in San Jose, CA. The center, modeled after LSG's Delaware-based service center, will help expand relationships to customers throughout the Western region. The support center will offer 24 x 7 technical support, technical training (LSG University) and the LSG Laboratory, which will focus on vendor-neutral product testing, certification and benchmarking.

VA Linux Systems, Inc. introduced the SourceForge CompileFarm—a service that offers open-source developers a convenient way to build and test applications on multiple versions of the Linux and BSD operating systems over the Internet. The CompileFarm will allow testing on Red Hat Linux, Debian GNU/Linux, Caldera and Slackware, as well as FreeBSD, with plans to offer SuSE and other distributions soon. SourceForge is the world's largest open-source development center, hosting over 2,500 open-source projects (http://www.sourceforge.net/).

SuSE Linux AG, Europe's leading Linux distributor, and Qarbon.com launched the “Linux Viewlet Project”. The project will provide Linux users and developers with a free database of Viewlets addressing a wide range of Linux questions. Viewlets, originated by Qarbon.com, are a web innovation that change help files and FAQs into demonstrations that show the user how to perform specific computing tasks. SuSE is the first Linux distribution to offer Viewlets. Qarbon.com encourages individuals to create a wide variety of Viewlets. Authors are compensated. Detailed information can be obtained at http://www.teach2earn.com/linux/.

MontaVista Software Inc., developer of the Hard Hat Linux operating system for embedded computers, announced the appointment of David Warner as chief financial officer. Mr. Warner will be key in addressing sales and distribution of the company's Hard Hat Linux subscriptions in OEM segments, including Internet appliances, communications infrastructure, industrial control and defense.

LinuxVoodoo.com is a free technical support site dedicated to providing a forum to discuss everything Linux. The site offers a searchable database of Linux HOWTO's, a 24-hour response help desk, message boards, links and more.

Gateway has committed to make a $25 million investment in eSoft, Inc., which develops and markets the TEAM Internet Linux software suite. The move is Gateway's first step into the Linux arena. Gateway will provide turn-key Internet access solutions to small businesses and will leverage eSoft's network Internet service solutions to advance its commitment to small business' growing software and Internet connectivity needs. Detailed information can be obtained at www.esoft.com/ or www.gateway.com

Linuxcare, Inc., a provider of comprehensive services for Linux, announced the opening of its third European office, located in Hamburg, Germany. The new office will focus on delivering Linuxcare's services and support expertise to independent software vendors, application vendors, dot-coms and the region's largest companies deploying Linux or other open-source software. Linuxcare will localize its service offerings for German and other European clients, providing complete, vendor-independent Linux solutions to jump-start customers' e-business initiatives.

EMUmail, creators of the EMU web-mail engine, announced a program that would wave the setup fee for Linux-based domain names added to its outsourced e-mail system. EMUmail is extending its premium e-mail outsourcing program to the Linux community in an effort to help propagate Linux awareness through e-mail communication. For more information, visit their web site at http://www.emumail.com/.

Samsung Electro-Mechanics Co, Ltd. and Lineo, Inc., the leading developer of embedded Linux system software, announced a partnership to use Lineo Embedix Linux as the operating system for Samsung's embedded Internet appliances. Samsung will initially use Embedix Linux and Embedix Browser in PDAs and set-top boxes. The partnership also includes joint education, sales and marketing efforts for the Korean and world-wide market.

Eazel, Inc., working with the GNOME development team, unveiled plans to develop products and services which will make the power and reliability of the Linux operating system accessible to mainstream desktop users. Eazel was founded in August 1999 and is led by a group of industry veterans, all of whom were part of the original Apple Macintosh team. Eazel is developing innovative desktop software for Linux which will be integrated with Internet-based services and will be released this summer.

Rumor: Microsoft insurance has been hit with a rash of psychological visits for acute orthinophobia, the fear of birds—penguins!

Quote of the Month: “We don't want to be another Netscape,” Jeff Bezos, Amazon.com in an interview with Tim O'Reilly.

Web site of the Month: Help SETI look for ET. Sign up at http://setiathome.berkely.edu/, then join the Linux JournalReaders' group.

Factoid: LJ Assistant Editor poses nude for cover of Python Supplement.

Factoid: Guido van Rossum's favorite TV show of all time: “Monty Python's Flying Circus”.

Load Disqus comments