Older blog entries for mchirico (starting at number 62)

4 Oct 2006 (updated 4 Oct 2006 at 01:17 UTC) »
nconway's problem

Well, my guess is S1(w) > S2(w), since with the simple string "aaaa" there are two occurrences of the substring "aaa". The first is from position 0 to position 2. The second is from position 1 to position 3. There is overlap.

Note it is impossible to have two occurrences of substring "abc" using any 4 characters. Therefore, more substrings of "aaa" can also be found in the 10 character string.

The mark of an immature man is that he wants to die nobly for a cause, while the mark of the mature man is that he wants to live humbly for one.

--W. Stekel

6 Mar 2006 (updated 19 Feb 2007 at 02:33 UTC) »
How to Trade in Stocks

It's been said that Jesse Lauriston Livermore was the greatest stock market operator in history - the only operator who ever made and lost four stock market fortunes. He did it all on a ``small bankroll, a stock ticker and a telephone.''[1]

Jesse Livermore stock picking techniques are still applicable today. In fact, if you do a careful read, you'll see that some well-know authors have actually stolen his techniques. Livermore's techniques worked well for him, when he followed them. Unfortunately, he got emotionally wrapped up in the marketed and departed from his rules. He died by suicide in 1940.

    ``It is the human frailty with we all possess in some degree that becomes the investor's and speculator's greatest enemy and will eventually, if not safeguarded, bring about his downfall.''[1]

Livermore had a number of rules: Never by on a tip alone; Stocks reaching new highs tend to go higher; Never trade in stocks under $15. Have an exit strategy before you buy, etc.

Stock Prices

There's a program stock.tar.gz that grabs current stock price data from yahoo finance. Below is an example usage getting the stock price for Redhat. By the way take a look at this price. It's starting to hit new highs, and it volume follows through on the new high it could be a good buy. Oh, first rule: Never buy on a tip alone.


            $ stock rhat
          
"RHAT",29.01,"3/3/2006","4:00pm",+0.76,28.10,29.28,28.00,3339778

This program[1] can do multiple stocks and or indexes as well. See the man page on the program for more help. The source is very simple using socket, bind, connect. It can easily be adjusted for scraping other pages, sending mail (you'll have to change the port), or other desired tasks.

Email Alerts

I use Gmail; but, but it's a custom setup with the local MTA (Postfix) and Fetchmail. The advantage here is being able to run any standard shell scripts for sending out mail, on your home system, where you might not have a dedicated IP address.

References

    [1] How to Trade in Stocks: the Livermore Formula for Combining Time Element and Price. By Jesse L. Livermore. Copyright 1940. ISBN: 0-934380-20-1
    [4] stock.tar.gz Direct download. This is a simple GPL socket, bind, connect, C program.
4 Mar 2006 (updated 5 Mar 2006 at 04:54 UTC) »
Xen and FC5

Xen is cooking up nice on Fedora Core 5. I didn't have any problem installing this on a Dell OptiPlex GX520, Pentium 4 (3.00 GHz), with 1G of RAM, Broadcom NetXtreme BCM5751 Gigabit Ethernet PCI Express, Linksys Gigabit Network Adapter (Model No. EG1032,rev 10).

It was actually only a matter of minutes before I had everything running, which I think is the best way to learn about Xen. That is, first have a running system with multiple guest systems. And, for each guest account have networking functional. One quick note, it certainly helps if you have 1G of RAM, so that each guest account can use the minimum default of 256MB. Take a look at the FC5 Xen Quick Start Instructions for how it's all done.

What's missing in these instructions is how to ssh into a guest xm and run kde remotely. I'll detail here what worked for me.


Xen and remote KDE

From the computer you are sitting at, with a monitor,keyboard and KDE or Gnome loaded and running, you'll connect via ssh to the Xen guest system. But before you can do this, walk through the step 1, with the computer in front of you.

    Step 1. Allow magic cookies; otherwise, you may get the following error:
               Xlib: connection to ":1.0" refused by server
               Xlib: No protocol specified

To enable magic cookies from the shell, issue the following commands.

   $ MCOOKIE=$(mcookie)
   $ xauth add $(hostname)/unix:1 MIT-MAGIC-COOKIE-1 $MCOOKIE
   $ xauth add localhost/unix:1 MIT-MAGIC-COOKIE-1 $MCOOKIE

    Step 2. Create a new xterm. This will immediate take you to vt12. To get back to your main KDE session type ctl-alt-F7. To go back, again, to vt12 type ctl-alt-F12.

    $ xinit -- :1 vt12

    Step 3. From vg12 type in the user and domain. The example below assumes the guest vm is vm0.domain.com, and the user to login in with is root.
    $ ssh -Y -l root vm0.domain.com

    Step 4. Once you're logged into the guest system, all you have to do is start KDE.
    $ startkde

I didn't have to change anything for KDE, but Gnome takes a few tweaks.

Reference

You may want to reference Linux Tips (TIP 195)

Now, in my opinion, it's instructive to look at the FC4 Xen Quick Start, and hack away the working Xen configuration. The FC4 documentation goes into the mechanics of the process.

Recommended Reading

"Higher Order Perl: transforming Programs with Programs", by Mark Jason Dominus.

Mark put a lot of time into this book, and it shows. It was 5 years in the making, with free versions passed out for review. Examples can be found here (scroll down the page) .

Mark plans to take the book public, in Wiki form.

I would agree that "writing functions that modify other functions" is a very powerful programming technique found in Lisp, Mathematica, Java, and C++ to name a few languages, but it's not generally associated with Perl. Well, Mark will open your eyes here. The book is fun to read. It has depth; however, it is not written like a text book. Compare it to hacking with friends rather than sitting in a CS class.

Leap Second Log Entries

That's it. The leap second was added. You'll see it in your logs.

Dec 31 18:59:59 squeezel kernel: Clock: inserting leap second 23:59:60 UTC
Dec 31 18:59:59 livingroom kernel: Clock: inserting leap second 23:59:60 UTC
Leap Second of 2005

The last time we had a leap second was 1998. This is exciting! We're going to have another one.

For me this will occur Dec 31, 7:00pm EST. Unlike the New Year, the whole planet experiences this transition at once, when the UTC clock ticks 23:59:60.

Below, is what the last leap second looked like in 1998

        Date        Time       TAI  NTP Leap        NTP Seconds
 1.  Dec 31 98    23:59:59     31    01           3,124,137,599
 2.  Dec 31 98    23:59:60     31    01           3,124,137,600
 3.  Jan 01 98    00:00:00     32    00           3,124,137,600
 4.  Jan 01 99    00:00:01     33    00           3,124,137,601

By the way, this is the 23rd leap second. Yes, I know what you're thinking. The number 23 is interesting because it's the first intersection of Pi and e.

   Pi = 3.141592653589793-23-84
   e  = 2.718281828459045-23-53

Also, the earth is tilted at 23.5 degrees...hmm there's that number again. Ramsey Theory? Maybe, probably.

C++ Network Programming: boost asio

Wouldn't it be nice to have all the network interfaces, in modern C++, for Linux, Windows, OS X and Solaris?

asio is under review for Boost inclusion, with SSL support and the future possibility for rawsockets.

It is a good C++ learning execise reviewing this library. There is active discussion now on the developers mailing list.

9 Dec 2005 (updated 9 Dec 2005 at 03:20 UTC) »
Highly Recommended Reading

Below are two highly recommended C++ books.

Effective C++ Third Edition: 55 Specific Ways in Improve Your Programs and Designs, by Scott Meyers

C++ Common Knowledge: Essential Intermediate Programming, by Stephen C. Dewhurst.

I've repeatedly gone through all examples. My copies are less then a year old; yet, with repeated daily readings and dog eared pages, my books are beginning to show some wear. In my opinion, you won't go wrong with these two books. One of the books requred a few minor, technical corrections; but, these corrections can be found on the author's errata page.

Postfix 2nd Instance for Sender-based Routing: Multiple Gmail and Comcast Accounts

Sender-based routing allows delivery actions on email to be made based on the sending address. This makes it possible for each Gmail and or Comcast account to have separate authentication rules. In summary, your home Postfix system can support Gmail and Comcast accounts for all of your family and friends. This tutorial walks you through an example using Gmail and Comcast, but the setup is similar for any ISP specific emails.

53 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!