Skip navigation

Monthly Archives: January 2008

//                                      //
//                                      //
// You found this at bobobobo's weblog, //
//        //
//                                      //
// Creation date:  Jan 31/08            //
// Last modified:  Feb 9/08             //
//                                      //

#include <windows.h>

// Function prototypes.
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow );

// Introduction:
// Basic Windows Program!
// This package demonstrates how to build a very basic Windows application
// on a Win O/S system from Windows 3.1 to Windows XP using C++ code.
// * Prerequisites to understanding this program:
//     - Already understand how to create Console applications in C++.
// If you don't know what those are, go learn what
// they are before going on reading this!

// Windows applications in C++ are easy!
// To understand them, you must first see the big
// picture.  Then you can get your hands dirty 
// and get right into the code.

// Big picture.
// Windows apps are much different than console apps.
// A console app, (which you probably are used to)
// has just a single "main" function called main().

// Every Windows app has __2__ functions that are very
// important to it.

// These 2 functions are WinMain and WndProc.  WinMain
// and WndProc really form the Windows' app's heart and soul.
//    A.  WinMain:  Application STARTING POINT.  REPLACES
//                  main() function that you might be used to
//                  from regular C/C++ programs.
//    B.  WndProc:  A function that PROCESSES MESSAGES from
//                  the Windows O/S as they come in.

// BUT what's a MESSAGE???
// The idea of "messages" takes some getting used
// to, but it is really a simple concept.
// The Windows Operating system is like a GOVERNMENT.
// All of the little windows that live inside
// (the Firefox window, the MSWord window,
// and YOUR PROGRAM's window!) are people owned
// by the Windows GOVERNMENT.
// So, whenever the user attempts to interact
// with ANY program window inside that Windows Government,
// either by clicking on your window, or by pressing a key
// while your program has the "input focus" (when
// your window is "selected"),
// the Windows O/S INTERCEPTS that communication FIRST.
// THEN, a fraction of a second later, (almost
// instantly), the Windows O/S SENDS A a "MESSAGE"
// to YOUR Window program that "HEY! THE USER

// THAT is what a MESSAGE is.  Its a notification
// from the Windows O/S that the user has 
// done something to your program's window.

// ONCE your program receives this
// "MESSAGE", your program can THEN execute some code
// in response to that particular MESSAGE.

// The WndProc function will contain ALL of
// your "MESSAGE HANDLING CODE" -- that is,
// the code pieces that you want executed 
// when certain window events happen.

// And in most standard Windows applications, this is
// how things happen.

// Most of a basic, standard Windows application's
// time is spent WAITING for events.

// And that is what a message is!

// There are 2 concepts you must understand intuitively first
// before diving into Windows programming.

// Those concepts are the concept of an INSTANCE,
// and the concept of a HANDLE.

// The first concept is the concept of an INSTANCE of a program.

// What's an INSTANCE?

// An INSTANCE of an application is just one running OCCURRENCE of it.
// If you open up 3 different NOTEPAD.exe windows, then you have
// created __3__ different, separate INSTANCE of the NOTEPAD program
// inside your Windows Kernel.

// If you're familiar with OOP, an easy explanation is this:
    // PROGRAM CODE >> like a C++ class definition.
    // ACTUALLY RUNNING PROGRAM CODE >> like an "instance" of the class, this is an INSTANCE of the program.

// HANDLES pop up EVERYWHERE in Windows programming (and all other
// types of programming as well!)  So I'm hoping to explain the idea
// behind a HANDLE intuitively, so that you have something to "hold onto"
// whenever you see use of HANDLES in program code.

// Think about a POT of boiling water.  Inside that pot is
// some corn on the cob being cooked.

// Now, say you want to ACCESS the pot, so you can dump its
// contents out into the sink and drain the corn.

// How do you do that?  Do you GRAB THE POT DIRECTLY??? NO!!
// That would be stupid.  Instead, you grab the HANDLE TO THE POT.
// Using the HANDLE to the pot, you manipulate the pot, slowly
// dumping out the water and leaving the corn behind.  Then you
// eat the corn and it is delicious.

// Now, in programming, the idea of a HANDLE is much the same.
// A HANDLE to a WINDOW is __NOT__ the window itself in an application
// variable.  Instead, it is a POINTER TO, A REFERENCE TO the
// window itself.

// A HANDLE TO AN INSTANCE in an application variable is NOT
// the application INSTANCE itself.  Rather, it is a POINTER TO
// that application instance.  The application instance exists
// somewhere in the Windows O/S's program memory.  You use the
// programmatic HANDLE that you have as YOUR MEANS TO MANIPULATE
// AND DEAL WITH that application instance.

// The benefits of HANDLES are many!  You'll see as we go on.
// Onto WinMain()!

// In a C++ Windows app, the starting point is WinMain().
int WINAPI WinMain( HINSTANCE hInstance,    // HANDLE TO AN INSTANCE.  This is the "handle" to YOUR PROGRAM ITSELF.  More in the GLOSSARY at the bottom.
                    HINSTANCE hPrevInstance,// USELESS on modern windows (totally ignore hPrevInstance)
                    LPSTR szCmdLine,        // Command line arguments.  Explained near BOTTOM of this file.
                    int iCmdShow )          // Start window maximized, minimized, etc.
    // As we said before, WinMain is the application starting point.
    // A:  WinMain does 2 main things:
    //        If the user has clicked on anything, or pressed any keys while
    //        our window is ACTIVE (our window has the "input focus")
    //        then we are to DISPATCH a MESSAGE to WndProc (make
    //        a function call to WndProc) that tells
    //        WndProc EXACTLY what the user did to our window (clicked?
    //        key pressed?), when it happened, etc.  WndProc then
    //        has the opportunity to EXECUTE SOME CODE in response
    //        to that particular user interaction.
    #pragma region part 1 - STARTUP STUFF
    // A.  Create WNDCLASS structure and initialize it
    // The WNDCLASS structure tells Windows WHAT KIND OF
    // WINDOW we dream of creating.
    // A note:  Use the TEXT() macro whenever you have a
    // string value that gets passed to a Windows
    // function.  Its good and makes life easier.
    WNDCLASS wc;
    wc.cbClsExtra = 0;  // ignore for now
    wc.cbWndExtra = 0;  // ignore for now
    wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );   // I want the window to have a white background
    wc.hCursor = LoadCursor( NULL, IDC_ARROW );            // I want it to have an arrow for a cursor
    wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );        // I want it to have that envelope like icon
    wc.hInstance = hInstance;           // INSTANCE HANDLE -- see the GLOSSARY PART of this file for an explanation of what HINSTANCE is
    wc.lpfnWndProc = WndProc;           // Give name of WndProc function here.
    wc.lpszClassName = TEXT("Philip");  // I have named it Philip.
                                        // You could name it anything
                                        // you want, but you have to
                                        // remember the name for when
                                        // you call CreateWindow().
    wc.lpszMenuName = 0;    // no menu - ignore = CS_HREDRAW | CS_VREDRAW; // Redraw the window
    // on BOTH horizontal resizes (CS_HREDRAW) and
    // vertical resizes (CS_VREDRAW).  There are
    // many more window class styles!

    // B.  Register the WNDCLASS with Windows, THEN
    //     create the window.
    RegisterClass( &wc );   // This kind of "plants" the information
                            // about the Window we "dream"
                            // of creating somewhere inside the Windows O/S...
    // NOW, at this next stage, WE ACTUALLY CREATE
    // the window.  The previous lines of code
    // until this point have only been PREPARATION.

    // When we call the CreateWindow() function, we will
    // make a reference to this WNDCLASS structure (BY ITS
    // NAME -- "Philip"), and the Windows government
    // will grant us our wish and a REAL LIVE WINDOW,
    // with the properties that we specified in the
    // WNDCLASS structure!

    // NOTICE that the value that is returned from
    // CreateWindow is a variable of type HWND.

    // HWND is a "handle to a window" - its a programmatic
    // reference variable to the Window.
    // The HWND is OUR MEANS BY WHICH to manipulate
    // our Window.

    // Read the schpeal near the top of this file if
    // not sure about HANDLES.

    // Most of the time, you would want to save
    // this HWND into a global variable,
    // so you wouldn't lose it later.
    HWND hwnd = CreateWindow(
        TEXT("Philip"),         // THIS IS THE LINK
                                // to the WNDCLASS structure that
                                // we created earlier.

        TEXT("window's title!"),// appears in title of window

        WS_OVERLAPPEDWINDOW,    // STYLE of window.  WS_OVERLAPPEDWINDOW just means
                                // the window we create should have a few common features
                                // like a minimize box, a maximize box, and it should
                                // be resizeable by dragging the "thick frame" around
                                // the window. There are other styles
                                // and they all start with WS_.  Check it out in the
                                // autocomplete by typing WS_ THEN PRESSING CTRL+SPACE
                                // to make the autocomplete window come up.
        10, 10,                 // x, y start coordinates of window
        200, 200,               // width, height of window
        NULL, NULL,             // nothing and nothing (ignore to start out)
        hInstance, NULL );      // hInstance -- (see glossary), nothing

    // Next, SHOW and PAINT the window!
    // You won't see the window if you DO NOT
    // call ShowWindow();
    ShowWindow(hwnd, iCmdShow );
    #pragma endregion

    // first, we create the MSG structure.
    MSG msg;
    // But WTF IS A MESSAGE???
    // A MESSAGE is something that the Windows O/S
    // SENDS your application program when

    // Messages can be anything from "the user
    // has moved your window", to "the user
    // has clicked at pixel location (20, 20)" or,
    // "you need to paint yourself", or, 
    // "you have been maximized".

    // YOUR CHANCE to handle those "messages"
    // that get passed to your window comes
    // IN WNDPROC.
    while( GetMessage( &msg, NULL, 0, 0 ) )
        // GetMessage is a function that will not
        // return until the Windows O/S HAS A message
        // for our program.

        // Since the GetMessage() function call is
        // INSIDE the bracket for the while Loop,
        // this means that our program is essentially
        // "put on hold" or halted until the GetMessage function
        // returns.

        // If and when the user interacts with our
        // application's window, then the GetMessage()
        // function WILL return and the variable
        // msg will be filled with interesting details
        // about exactly what the user did to the window.

        TranslateMessage( &msg );   // translates 
        // the message so WndProc can process it
        // more easily.

        // Next we 'dispatch' the message, or
        // send it off to WndProc for processing.

        // Notice that there is NO EXPLICIT function
        // call to WndProc, but somehow in the bowels
        // of the Windows O/S, calling DispatchMessage
        // WILL result in a call to your WndProc function,
        // WITH the appropriate msg struct passed in
        // as well.
        DispatchMessage( &msg );    // this line RESULTS IN
        // a call to WndProc(), passing the message and
        // the HWND.

    #pragma endregion

    return msg.wParam;    // return from WinMain

LRESULT CALLBACK WndProc(   HWND hwnd,      // "handle" to the window that this message is for
                            UINT message,   // TYPE of message (e.g. WM_PAINT is a message asking to paint the window)
                            WPARAM wparam,  // information about the actual message
                            LPARAM lparam ) // MORE info about the message
    // If WinMain was the heart of the Windows application, then
    // WndProc is the soul.

    // WndProc does just 1 thing:
    //    - Execute some bit of code in response
    //      to user interactions with our windows
    //      application.  

    // The tricky bit about WndProc is that NOWHERE IN THIS APP'S
    // TO WndProc!!!  Does that mean WndProc never
    // gets used???

    // NO!!!  Take a look again, around where
    // we create the WNDCLASS.

    // Notice, how the WNDCLASS has lpfnWndProc = WndProc??
    // THAT is the reference to this function.

    // The WINDOWS O/S PERFORMS the function call to
    // WndProc when we call DispatchMessage().

    switch( message )
    case WM_CREATE:
        // upon creation, let the speaker beep at 50Hz, for 10ms.
        Beep( 50, 10 );
        return 0;

    case WM_PAINT:
            // we would place our Windows painting code here.
            HDC hdc;
            PAINTSTRUCT ps;
            hdc = BeginPaint( hwnd, &ps );

            // draw a circle and a 2 squares
            Ellipse( hdc, 20, 20, 160, 160 );
            Rectangle( hdc, 50, 50, 90, 90 );
            Rectangle( hdc, 100, 50, 140, 90 );
            EndPaint( hwnd, &ps );
        return 0;

    case WM_DESTROY:
        PostQuitMessage( 0 ) ;
        return 0;


    // Now, try going into Visual Studio and
    // press WM_ then press CTRL + SPACE.

    // Or go to

    // See that huge listing?  Those are ALL THE EVENTS
    // that Windows could possibly throw at our application.
    // WOW!  That's a lot of events.  WE don't want to 
    // have to write code for every single one of them!
    // But our WndProc gets called whenever ANY event
    // happens to our application.  What do we do with
    // the events we don't want to handle?
    // Simple.  We will pass the events we DON'T want
    // to handle to DefWindowProc().  DefWindowProc()
    // knows what to do with the events we don't want
    // to handle so that our application remains stable
    // and good.
    return DefWindowProc( hwnd, message, wparam, lparam );

/// GLOSSARY ///
// HINSTANCE:  "Handle" to an instance.  Every running INSTANCE
// of an application has a handle to it that is YOUR MEANS
// by which to manipulate, talk about, or refer to that specific
// application instance as it exists inside the Windows O/S.

// What's an instance again?  If you have 2 copies of the same programming running
// at the same time, then you are running 2 INSTANCES
// of the same program (2 copies of Microsoft Word, for example).
// Each INSTANCE of a program has its own INSTANCE HANDLE and
// hence its PID (ProcessID - unique integer identifier
// for each program that is currently running in the Windows O/S)
// and its own entry in the Window task manager.

// TRY THIS:  Press CTRL+ALT+DEL to bring up the Windows
// Task Manager.
    // Now switch to the PROCESSES tab.
    // Click the "IMAGE NAME" column, so that everything gets organized by name of the process.
    // Now, open NOTEPAD, 3 times.  You should have 3 Notepad windows open.
    // NOW, LOOK AT the Windows Task Manager.  Try to locate __3__ entries
    // that say NOTEPAD.EXE.  Open a fourth notepad.  Open a fifth notepad.
    // every instance of notepad you open gets its own entry in that table.

// Now HINSTANCE is exactly what it sounds like . . its a "handle"
// (a means by which to access or control) the INSTANCE of your
// program.
// The actual INSTANCE of your application lives inside the Windows O/S.
// But you have a HANDLE TO IT, and your HANDLE to it is your means
// by which to manipulate it, refer to it, change it, or delete it.

// HWND:  HANDLE TO A WINDOW.  This is exactly the same in CONCEPT as
//        the INSTANCE HANDLE, but now, this is a handle TO THE WINDOW ITSELF.
//        The HANDLE TO THE WINDOW is your means by which to change
//        manipulate, or refer to the window that belongs to your program.
//        A single INSTANCE of an application can have MULTIPLE window
//        handles associated with it.  THAT IS WHY when you CREATE A WINDOW,
//        using the CreateWindow() function, you MUST PASS the hInstance
//        parameter.  That is so that Windows knows which application
//        INSTANCE is attached to which WINDOW.
// HDC:  HANDLE TO A DEVICE CONTEXT.  Hmm.  I'm not going to explain this
//       in detail here, because we're not really using the HDC much
//       in this example.  Perhaps at a later time.

// Everyone knows starting Windows Programming can be a bit hard.
// There are a few things I'd like to highlight here.
// Now you might be wondering, "ok, if WinMain is the application
// starting point, WHERE / WHEN / HOW does WinMain accept
// To understand this, you must start to see your "Windows program"
// as really just a FUNCTION that Windows will call, when it is
// time to start up your application.
// So where do the values of hInstance, hPrevInstance, szCmdLine
// and iCmdShow come from?
// These parameters are PASSED BY the Windows O/S AT APPLICATION START TIME.
// So all of hInstance, hPrevInstance (which is always passed as NULL)
// szCmdLine and iCmdShow are passed by the Windows O/S
// to your application.

// Understanding what szCmdLine is and does:
// Do me a favor.
// Open the Windows command prompt (go to START->Run,
// then type "cmd" in the box that appears there.)
// You should see a black console window, like the one that your basic console C++ 
// apps run in.  In the black window, type in:
//          explorer
// then press enter.

// What should happen is your windows file explorer should pop up.

// Now go back to the command prompt and type in
//          explorer "C:\Program Files"

// Notice now that the Windows disk explorer now opens in the folder "C:\Program Files"
// In the above example, "C:\Program Files" is a command line argument that modifies
// the behaviour of the disk explorer upon its launch.

// So the explorer.exe program is a Windows program.
// And szCmdLine WOULD BE WHERE YOU TAKE that extra string
// that is passed to the program at the time the program is
// launched.

// You won't necessarily use this at all in your programming!
// But, it is good to know.

// If you want to know more about Windows Programming
// in this CLASSIC C++ way, then you should pick
// up a copy of Charles Petzold's "Programming Windows,
// 5th Edition"
// On Amazon:

// "The Petzold" is THE reference that all the game
// books out there (some of which are pretty good!)
// draw on when they write their Win32 chapter (its
// obvious from the way they've written them!)

// What's annoying is, a lot of the people who write
// those books though, never acknowledge Petzold or
// mention where they derived their Win32 understanding
// from.

// So, the Petzold is where I got my initial understanding
// anyway, and its really good.  Check it out
// from your library if you haven't the $.

// More refs:
// MSDN:  "About messages and message queues"

// MORE Closing notes:
// This is sometimes called "EVENT DRIVEN
// PROGRAMMING" -- the idea is that your
// program is entirely driven by EVENTS.
// If there are no events, then your
// Windows program DOES NOTHING.

// Note that this is NOT the case with GAMES!
// GAMES CAN'T WAIT!  Games must be fast.
// For games, you would use DirectInput,
// and things like that, and you WOULD NOT
// be WAITING for messages.  Instead,
// you want to be DIRECTLY listening
// at the keyboard and mouse for user 
// interaction with those DEVICES.

// You MIGHT HAVE been wondering about
// the apparent RETURN TYPE of WinMain and
// WndProc.

// Looking at those function prototypes, we have:


int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow );
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );


// For example, a question you might have might be:
// WHY is the return type of WinMain "int WINAPI"?
// That is so weird.

// The short answer, is ITS NOT!!

// The return type of WinMain is just INT.

// The second word after the return type
// (WINAPI) is called the CALLING CONVENTION of
// the function.

// In case you're still interested, check out
// these links:

// A MSDN basic window example:

// MSDN root page for a lot of windows stuff

     ____   __   __      __   __  ___
    / _  \ /  / /  /    /  /  \ \/  /
   / _/ / /  / /  /    /  /    \   /
  / _/ \ /  / /  /__  /  /__   /  /
 /_____//__/ /______//______/ /__/


Check out the Visual Studio project files [updated Feb 9 / 08] hosted by esnips! (Thanks esnips!)

(donation should be to

HANDLES in Windows programming

HANDLES pop up EVERYWHERE in Windows programming. So I’m hoping to explain the idea behind a HANDLE intuitively, so that you have something to “hold onto” whenever you see use of HANDLES in program code.

Think about a POT of boiling water. Inside that pot is some corn on the cob being cooked.

Now, say you want to ACCESS the pot, so you can dump its contents out into the sink and drain the corn.

How do you do that? Do you GRAB THE POT DIRECTLY??? NO!! That would be stupid and your hand would burn. Instead, you grab the HANDLE TO THE POT. Using the HANDLE to the pot, you manipulate the pot, slowly dumping out the water and leaving the corn behind. Then you eat the corn and it is delicious.

Now, in programming, the idea of a HANDLE is much the same. In your program code, say you have a variable like:

HWND hwnd = CreateWindow( . . . ) ;

HWND is a “handle to a window”. A HANDLE to a WINDOW is __NOT__ the window itself inside the variable hwnd. Instead, it is a A REFERENCE TO the window itself. The window exists somewhere in the Windows O/S, and the idea is that you use the hwnd reference as a programmatic HANDLE that you have as YOUR MEANS TO MANIPULATE AND DEAL WITH that window.

Look at this code:

MoveWindow( hwnd, 50, 50, 200, 200, true ); // move the window referred to by
// hwnd, to x, y location (50, 50) and being 200×200 pixels in size.

With handles, you don’t have to deal with that hot pot directly (you wouldn’t know how to!) Instead, you use the Win API functions (like MoveWindow()) and PASS YOUR HANDLE TO YOUR WINDOW AS YOUR MEANS TO REFER TO AND MANIPULATE THAT WINDOW.

The same understanding applies to HINSTANCES, and any other type of handle. Remember, a HANDLE is YOUR MEANS TO MANIPULATE AND REFER TO the object in question.

bremelanotide is a great record with a strange name.

rhythm, polished sound, great melodies, self-categorized as “nerdcore”.

favs: #1: “post-collegiate shuffle” – great chorus, good rap. chorus is catchy.
#2: “balloon flight”

Exposure is really just being able to say “I’ve heard of that.” Exposure to ideas, exposure to available technologies, exposure to culture are all extremely important.

I think its being “exposed” that really makes a person seem mature, intelligent, and experienced. Staying exposed all the time is quite hard, so I suppose you have to be mature, intelligent and experienced to be exposed.

Some people will hide their sources of exposure. They do this so that they can maintain their lead by keeping others NOT on the same page as they are. They can then update others and in that process, they remain superior.

Isn’t exposure really experience? I don’t know.

Just a thought.

sheena melwani is posting a bunch of covers to youtube.

they are quite good. She was interviewed by Cat Spencer and its kind of funny to see the person being interviewed on the radio.

How do I downgrade from Windows Vista to Win XP Pro?

There are a few important points that you must realize before you jump in and buy a brand spanking new copy of Vista, expecting to be able to use your “downgrade rights” to downgrade to XP Pro:

  1. YOU MUST have purchased an OEM version of Windows Vista BUSINESS or Windows Vista ULTIMATE (NOT ANY OF THE HOME EDITIONS) to be able to downgrade. AND IT HAS TO BE THE OEM VERSION (more on that later).
  2. YOU MUST ALREADY HAVE A LICENSED COPY OF WINDOWS XP PRO. This one might not sound fair, but apparently it is.
  3. MICROSOFT IS MEAN ABOUT DOWNGRADES: They will NOT provide you with a Windows XP disc to do your downgrade when you buy Vista — they expect you to already have one.
  4. Microsoft WILL NOT provide to you an XP KEY __and__ a Vista key when you buy Vista.

The idea behind the “downgrade rights” is as follows:

Say you’re a business and you have machines humming along, running Windows XP.

Suddenly, your company makes a couple of bucks and you, as manager, wanna blow them on some brand spankin’ new machines.

So you decide: 50 machines. Intel core 2 duo’s, 4 gigs of ram per each, and a couple of WD 500GB hard disk drives on all. You top that off by cramming in wickedly fast NVIDIA cards, because employees stay late sometimes to play games over the lan at work, you know, to boost company morale and all.

Now, time to decide on the O/S.

You know that Vista stinks right now. But you also know that in time, there will be some essential piece of software that you just have to have that will require you to use Vista.

So you don’t want to go and buy 50 XP licenses when you know the impending doom — the time to upgrade to VISTA — will surely come sometime in the next couple of years.


That’s right sir. You can BUY Vista now, but hold off using it UNTIL you are forced to.

If you have a machine that’s running XP Pro and you want to buy another new machine, then you can buy that new machine with an OEM version of Vista Business or Vista Ultimate, THEN USE THE SAME LICENSE AS THE OLD COMPUTER TO KEEP USING XP PRO ON THE NEW COMPUTER.

So that’s the key: You only get the Vista key, and you have to use an already existing, legitimate XP key to install the downgrade. AND you have to already have the CD. SOME OEM vendors will GIVE you an XP oem cd when you buy a computer with Vista, but you have to ask for it, usually.

If you don’t know what OEM means, OEM means “ORIGINAL EQUIPMENT MANUFACTURER”.

Good def from a “fuel definitions” page (hey, you find good things everywhere!):

OEM: Original Equipment Manufacturer. Provide the original product design and materials for its assembly and manufacture. OEMs are directly responsible for manufacturing and modifying the products, making them commercially available, and providing the warranty.

In short the OEM version is a cheap unpackaged version of Vista and it looks like this. WINDOWS VISTA BUSINESS OEM – NOTICE HOW ITS UGLY:

Windows Vista Business OEM
Click to see on amazon

Vista Business retail
Click to see on amazon

The “retail” edition is what is referred to as the “FPP” – Fully Packaged Product.

Explain to who you’re buying your new computer from that you want the downgrade rights. They should know to give you a proper copy of the OEM.

Unfortunately, some of the reps I have spoken to seem to be in the dark about the details. Be patient and make sure they understand you want to downgrade rights before you make the purchase, and keep at them until they guarantee you that you can get the downgrade rights.

What about the docs MS provides?

If you read the official documents from MS, pdf marketingese type sheet and the downgrade rights chart, they pretty much say what I’ve been saying above, except they’re a lot less clear.

Essentially all that says is “ya can buy vista now and use YOUR OLD COPY OF XP on yer new computa, which is somethin’ we’s usually don’t allow, son. Bacause when ya install XP on a machine, it gets married to that machine. An’ so you’re askin’ that old copy of XP to fornicate with yer new machine, which is usually illegal. But if ya do things right, and buy the right version of our new but struggling O/S, we can make it happen.”

This is a great article that fully explains it as well.

From the article:

So what downgrades does Microsoft allow? Owners of the OEM editions of Vista Business and Vista Ultimate can downgrade to Windows XP Professional, including Tablet PC Edition and x64 Edition. Only the OEM editions qualify for a downgrade, so if you purchased a new PC with either Business or Ultimate preinstalled, you’re in like Flynn.

Those who aren’t: All users of Vista Home Basic and Vista Home Premium, and anyone who upgraded to Vista using a retail edition of any of the operating system’s SKUs. You are, as they say, SOL.

Interesting and useful . .

In both C and C++, a struct is laid out flat in memory, just like an array is.

‘Course, this means that you can treat a struct as an array, without ever using a union.

The next example shows how.

#include <iostream>
using namespace std;

struct Vertex
    float x,y,z;

int main()
    Vertex v;
    v.x = 2.0f, v.y = 1.0f, v.z = 5.0f;
    // print each member of the struct
    printf( "v:  %f %f %f\n", v.x, v.y, v.z );

    // now treat as an array
    float * arr = &(v.x);    // get the address of v.x
    // since v is laid out flat in memory, just like an array
    // this will work out fine

    // struct Vertex laid out flat in memory, like
    // this, so accessing it as an array is no problem
    // ___________________
    // |     |     |     |
    // | 2.0 | 1.0 | 5.0 |
    // |_____|_____|_____|
    //    x     y     z

    for( int i = 0; i < 3; i++ )
        printf( "v[%d]:  %f\n", i, arr[i] );

Incidently, this is the same way you would access a C++ STL vector’s internals as a regular C++ array.

Something like:

#include <iostream>
#include <vector>
using namespace std;

int main()
    vector<int> v;
    v.push_back( 2 );
    v.push_back( 5 );
    v.push_back( 7 );

    // now normally, you may think
    // its fine to just go through
    // the elements of v like this:
    printf("Using [] operator on v:\n");
    for( int i = 0; i < v.size(); i++ )
        printf("v[%d]:  %d\n", i, v[i] );
    // And it IS fine, mostly.

    // However, sometimes you're working with a 
    // C API that wants a REGULAR int * pointer
    // to an array, and won't accept an STL
    // vector.

    // What's one to do?  Stop using STL vectors??
    // No!! :).

    // You can get a regular (type *) C-style array
    // pointer to the internals of any STL vector:

    int * internalsPointer = &v[0];

    int length = v.size();
    printf("\n\nUsing internalsPointer\n");
    for( int i = 0; i < length; i++ )
        printf("v[%d]:  %d\n", i, internalsPointer[i] );

    // Its good if you need to pass the
    // vector's internals to a function that wants
    // a C-style array (e.g. OpenGL's vertex
    // array funcs).

Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib

This happens if you’re compile/run a Windows app that has a WinMain function, but you chose “Console Application” INSTEAD of
“Windows Application” when you were creating the new project.

You fix this by right clicking on your PROJECT name, then picking the PROPERTIES dialog:
Project Property pages

Then change the subsystem to WINDOWS:


to prevent that from happening, make sure you pick WINDOWS APPLICATION at the point where Visual Studio asks you whether you want a console app or a windows app!:



Note that there IS a huge difference between d3dx9.lib and d3d9.lib.

Getting error LNK2019: unresolved external symbol _D3DXVec3Normalize@8 referenced in function?

Do this

  1. In visual studio 2005, Go to TOOLS->OPTIONS.

    In that window that comes up, in the left hand side of the window, pick “PROJECTS AND SOLUTIONS” -> VC++ DIRECTORIES from the tree.

    d3d linker error fix

    ALSO do this:
    d3d include

  2. In every code file, include a line at the top that says:

    #pragma comment(lib, "d3dx9.lib")   // d3dx9.lib contains actual code for D3DX functions (like D3DXVec3Normalize)


Although d3dx9.h contains the function prototypes and signatures for the D3DX functions, it DOES NOT contain the actual implementation code.

The implementation code is provided IN “d3dx9.lib” which is why you have to LINK it to the executable at compile time.

what kind of cpu do i have?

have you wondered about the details of your cpu?

use cpu-z to find out

Let me also add

How do I measure the temperature of my CPU?


open source hardware!

The definitive “tom’s hardware” website (check out their CPU/GPU comparison charts)

I like looking at this NVIDIA GPU’s comparison chart on wikipedia

Similar list for ATI GPU’s for all your hardware browsing and bargain finding needs

article on nvidia’s 7900, also talks about how NVIDIA doesn’t manufacture their own stuff, instead companies like BFG, XFX, PNY and eVGA do it.

This is sort of like a survey question, sparked by a curious discussion.

I don’t expect very many people to actually answer it — but it would be interesting if people did.

But it came to me, so I thought I’d post it nonetheless.

1. Best friend, same sex
2. Best friend, opposite sex
3. Any friend, same sex
4. Any friend, opposite sex
5. Mother
6. Father
7. Sibling (brother)
8. Sibling (sister)
9. Anyone really (No restrictions)

Jan 27

@ 9:18pm, google says in response to the question

1 Canadian dollar = 0.994233 U.S. dollars

Value of Canadian dollar in US dollars, Jan 27/08

Yet, and continue to have wildly different prices when it comes to the same exact books.


I’m sure there are quite a few more factors in determining prices than I am aware, but come on. $10 more to buy the exact same book, with the same isbn, when the difference between the Canadian and US dollars differ by LESS THAN A CENT??

It seems these prices are appropriate for a couple of years ago, not today.

Why are we paying so much more?

Canadian flag

Understanding va_list

Writing your own function that uses a va_list is really easy!

But first, let’s identify what a va_list is.

Think about the printf() C function.

printf(“Hello there! I like the numbers %d, %d and %d\n\n\n”, 1, 3, 7);

Obviously the output of that function call would be:

Hello there! I like the numbers 1, 3 and 7

But the key point here is, the printf() function can accept a VARYING NUMBER OF ARGUMENTS. That’s because it uses a va_list.

If you look at the signature for printf(), it looks like this:

int printf( char * format, … );

So the argument list for printf() has 2 main things:

  1. char * format – a regular string
  2. and a second special argument, … (3 dots, just like that)
  3. … is called an “ellipsis”, and it means, in plain English: “any number of optional arguments can go here.”

    So somehow, in the innermost bowels of printf(), is some sticky code that somehow retrieves each one of the the list of args you’re passing in, in the place of the “…”.

    Cool! So is it possible for us to write our functions that have their own sticky code that can process a set of VARIABLE ARGUMENTS???

    YES YOU CAN. And its actually simple!

    An example:

    #include <stdio.h>
    #include <stdarg.h>
    int addThemAll( int numargs, ... )
        // So this function can accept a variable number
        // of arguments.  No (practically speaking) limits.
        // RULES you must know in order to be able to use "..." in one of your
        // own functions:
        // 1)  The ... MUST appear exactly as ... 
        // It cannot be "..." (with the quotes),
        //     '...', or anything else weird.
        // 2)  The ... __MUST GO LAST__ IN THE ARGUMENT LIST
        //     THAT COMES BEFORE THE ...
        // We'll be using these macros here:
         va_list    va_start    va_end    va_arg
        // All of the above va_* things are actually special MACROS,
        // exclusively defined for us to use when working with
        // _V_ariable _A_rgument lists.
        // FIRST, we create a POINTER that will be used
        // to point to the first element of the VARIABLE
        // ARGUMENT LIST.
        va_list listPointer;
        // Currently, listPointer is UNINITIALIZED, however,
        // SO, now we make listPointer point to
        // the first argument in the list
        va_start( listPointer, numargs );
        // Notice that numargs is the LAST MANDATORY ARGUMENT
        // that the addThemAll() function takes.
        // By "LAST MANDATORY ARGUMENT", I mean 'numargs'
        // is the last argument to the addThemAll() function
        // JUST BEFORE the "..."
        // NEXT, we're going to start to actually retrieve
        // the values from the va_list itself.
        // FROM THE va_list.  In this example, I'm assuming
        // they're all ints, but you could always pass a format
        // string that lets you know the types.
        int sum = 0;
        for( int i = 0 ; i < numargs; i++ )
            // GET an arg.  YOU MUST KNOW
            // IT FROM THE va_list.
            int arg = va_arg( listPointer, int );
            printf( "    The %dth arg is %d\n", i, arg );
            sum += arg;
        printf("END OF ARGUMENT LIST\n\n");
        // FINALLY, we clean up by saying
        // va_end().  Don't forget to do this
        // BEFORE the addThemAll() function returns!
        va_end( listPointer );
        printf("The total sum was %d\n\n", sum);
        return sum;
    int main()
        // Try it out.
        printf("Calling 'addThemAll( 3, 104, 29, 46 );' . . .\n");
        addThemAll( 3, 104, 29, 46 );
        printf("Calling 'addThemAll( 8,   1, 2, 3, 4, 5, 6, 7, 8 );' . . .\n");
        addThemAll( 8,   1, 2, 3, 4, 5, 6, 7, 8 );
        return 0;

    Download Visual Studio project files.

    (donation should be to

No, its not a joke!

Open Inventor

really old but good article on DirectX

You know what’s annoying?

URLs like

“bb509638.aspx” is completely meaningless to me as a page name.

Kim swift is cool.

Her presentation is good. At the beginning, she’s got great confidence, but then she does get a tad quivery.

She’s entertaining to listen to and funny. People didn’t laugh at the right moments though. The audience seemed a bit dead really, and they also cough a lot.

I find when a speaker opens with a really good joke that everyone can laugh at, to break the ice at the very beginning, then people will laugh readily at the right points throughout.

Nonetheless, she makes quite a few good points in her pres.

Timestamps for highlights:

  • 6:40: students have advantage when making class project they should use: you can take a high risk innovation for your project, and have the execution fail (it was a bad idea after all), but its not always possible to try high risk projects once in a company
  • 9:00: Design simplicity – pick one core piece of gameplay and iterate on it. “one piece of gameplay used in a whole different bunch of permutations.” – e.g: the portal
  • 11:30: Design Democracy.
    * All designers on team.
  • 13:40: Getting to Valve.
    * Here she summarizes the story of how the Valve team picked up the Narbacular team.
  • 14:40: Valve Lessons
  • 18:00: Coworkers will determine your growth
    * True that.
  • 19:20: Playtesting
    * Playtesting rigor – not rigorous testing doesn’t yield value

Here’s a link to the original narbacular drop demo. I really liked it when I played it. When you first open narbacular, its like WOW. This is brilliant.

So to sum, Kim swift. If she were available at taverns in DOTA maps, I would use her.

If you haven’t yet heard Harvey Danger’s newest album “Little by Little…”, they’ve made it available for free download – ah generous.

I think the new album tries to be a bit too mature.

To be honest, I was quite put off by the opening lyrics of the first song on “Little by Little…”

Wine women and song,
I tried them all it did not take me long
To figure I’d unlocked the door to happiness
I figured wrong with a capital “R”

That just doesn’t resonate as much as

I’m not sick, but I’m not well

BTW, check this out great lip dub by the same group that runs Vimeo, CollegeHumor, Busted Tees, and Defunker.

What’s the difference between a STRUCT and a UNION in C++?

Here’s an example!

A C++ struct will make sure to allocate space for each and every member in the struct.

For instance, if we had

struct VertexStruct
    float x,y,z;

When you create one, using a line of code like:

VertexStruct vertexstruct;

This is what VertexStruct object will look like in memory.

 |     |     |     |
 |     |     |     |
    x     y     z

So if we do

vertexstruct.x = 50;
vertexstruct.y = 10;
vertexstruct.z = 2;

We get this picture in memory:

 |     |     |     |
 | 50  | 10  |  2  |
    x     y     z

This is natural and completely what you’d expect.

Contrast STRUCT vs UNION

Now, CONTRAST THAT with a UNION. A UNION uses the SAME EXACT PIECE OF MEMORY for __ALL__ of the members inside of it.

This is kind of counter-intuitive and weird.

An example:

union VertexUnion
    float x,y,z;

When you create one, using a line of code like:

VertexUnion vertexunion;

You get this picture in memory:

 |     |
 |     |

The above union effectively provides 3 ways by which to access that same single piece of memory (x, y and z).

So if you wrote code like:

vertexunion.x = 10;
vertexunion.y = 2;
vertexunion.z = 5;

You get this picture in memory:

 |     |
 |  5  |

(Last x, y and z all refer to the same piece of memory. Since the last value assigned there is 5, ALL OF x, y and z have the exact same value).


* Note that the sizeof( any_union ) ends up being the sizeof( largest_member_in_union ).

Download the Visual Studio 2005 project files quick demo.

Demo is hosted by esnips! (they’re awesome!)

I heard that wordpress was giving members 3 gb of space. . . however, i didn’t realize we’re still limited to just image files and ms-word docs.

Hmm. We need to serve up other file types. For instance, I’m wanting to serve up a few .zip packages that contain MS Visual Studio projects. These packages are in the KB, and if .doc files can be served up from the blog, shouldn’t code packages be too?

There are a number of options though

!!! My pick (I am moving to, Jan 1/09. I’ll still use esnips, but mediafire looks really neat.)

ugh.. microsoft skydrive. I really DO NOT like how it downloads through a script request. its annoying!!

links like

I like 4shared.

Other fileupload hosts


Download links like
1 – 99 day storage period
Upload seems to be a tad slow, but I only uploaded a small testfile


Links like
– Longevity: 30 minute expiry
– Comments: Doesn’t meet my needs here, but i can see how this would be useful for distributing a smaller file quickly among 5 or 6 friends quickly and easily.

links like
Too many “hoops” to jump through to get to final download. Limited unless you have premium.

links like
pretty good

links like is stupid because it requires a captcha

WOW. This one is really glossy. Links like CLICK TO DOWNLOAD!. NO LOGIN REQUIRED TO UPLOAD! Really neat! (Tested Thurs Jan 1 / 09) !!! NEW PICK Jan 1 /09


I’m still looking for a file host that will give me a direct link that I can just post to my blog, without requiring redirection.

The closest thing to this that i’ve found is hfs, which allows you to easily set a folder to see the public internet.

It also does a good job of getting around routers, you just have to port forward.

The best thing would be . . .

Of course, the best thing would be if wordpress actually allowed users to upload other types of files. Although there’s potential for abuse, I want/need to upload code packages (.zip files that contain .cpp files).

WordPress COULD allow .zip archives up to a maximum of say, 8MB or so. Code packages will be something in the KB, so they won’t cause traffic problems.

I didn’t know that

some cool stuff

1 2 3

Ha ha ha. Check out the Google trends for “jobs.”

Google trends for jobs

Drops during the Christmas season, then goes back up to normal level.

Look at the Google trends for “winners” (the store):

Google trends for “winners” Jan 23 / 08

People search for bargain styles right after the holiday break, going into spring, when their old styles aren’t good enough anymore, but they haven’t the money to spend on anything really good.

Here’s a great link to the purple math site (a great site).

Matlab plot syntax is easy to use but apparently easy to forget.

Here I’m plotting the line y = x2 from x = -20 to +20.

% generate x, y vectors
x = -20:0.01:20;   % x goes from -20 to 20 in steps of 0.01
y = x.^2;            % generate y

y = x^2

Hmm the plot would be easier to see if it had grid lines drawn in.

% generate x, y vectors
x = -20:0.01:20;   % x goes from -20 to 20 in steps of 0.01
y = x.^2;            % generate y
grid on;

Hmm, I want to zoom the plot in so it shows from -2 to +2 of the x-axis and from -1 to +3 of the y-axis.

% generate x, y vectors
x = -20:0.01:20;   % x goes from -20 to 20 in steps of 0.01
y = x.^2;            % generate y
grid on;
axis( [-2, 2, -1, 3] );  % NOTICE this goes AFTER the plot() command
% axis( [ xmin, xmax, ymin, ymax ] ) ;
% you must have the [], the axis function takes ONE argument with vector type, not 4 different arguments.

Finer control

We can get much finer control over our matlab plots by ACQUIRING THE HANDLE to the axes.

The axes exist as an object in memory somewhere inside the MATLAB “machine”. The ‘handle’ to the axes is YOUR POINTER that you can use to make changes to that axes object, even though the MATLAB program isn’t fully under your control. You have control over PARTS of MATLAB THROUGH these handles you can get.

This is easy.

So howdya get the handle?

% generate x, y vectors
x = -20:0.01:20;   % x goes from -20 to 20 in steps of 0.01
y = x.^2;            % generate y

HANDLE = gca;  % "get current axis handle" . . gives you "handle" to the axes that belong to the plot you JUST made.
% Remember, a HANDLE to the axes are just a programmatic "means to control" the axes.

% now try this
get( HANDLE );

%% wow!  you'll see a huge listing here like
%	ActivePositionProperty = outerposition
%	ALim = [0 1]
%	ALimMode = auto
%	AmbientLightColor = [1 1 1]
%	Box = on

% You can customize any of these by choosing something, then SETTING the property using the SET function.

% e.g. let's change the background color to dark blue, and the axes color to 
set( HANDLE, 'Color', [0,0.1,0.2] ); %background color to dark blue

How do you change the color of the matlab plot itself?

% generate x, y vectors
x = -20:0.01:20;   % x goes from -20 to 20 in steps of 0.01
y = x.^2;            % generate y
plothandle = plot(x,y);

% now try this
get( plothandle ) ;
%lists all properties you can change of the PLOT itself

set( plothandle, 'Color', [ 1, 0.5, 0 ] );  % plot color to orange
set ( plothandle, 'LineWidth', 1.5 );   % make matlab plot line wider

altered colored matlab plot . . the altered beast if you will

All the stuff in this section uses code like:

set( HANDLE, 'PropertyName', PropertyValue ) ;

Note that if you use gca, you will be modifying THE WHOLE PLOT. If you use the plothandle = plot(x,y), then you will be modifying ONLY THAT LAST PLOT WHICH YOU CREATED.

So, to do things like MODIFY THE AXIS LABELS, you’d do something like this:

x = 0:0.01:2*pi ;
y = sin( x ) ;
hold off ; % REPLACE last plot with the new one I'm
% about to draw (if any already existed onscreen)

h = plot( x, y ) ; % SAVE THE HANDLE so we can
% modify the plot lines
set( h, 'Color', [1,0,0] ) ; % change color of the
% sin(x) plot to (100% red, 0% green, 0% blue)
set( h, 'LineWidth', 1.5 ) ;
hold on ;  % keep the last plot on while we
% put a new plot
y = cos( x ) ;
h = plot( x, y ) ; %SAVE THE HANDLE to the cos(x) plot
% so we can change its color below

set( h, 'Color', [0,0,1] ) ;%cos(x) plot (0% r, 0% g, 100% b )
set( h, 'LineWidth', 1.5 ) ;%widen pen width
axis( [ 0, 2*pi, -2, 2 ] ) ;% ZOOM TO 
% [ xmin, xmax, ymin, ymax ]

set( gca, 'XTick', 0: pi/2 : 2*pi ); % make the ticks on
% the x-axis get labelled:  
% so from 0 TO 2*pi IN STEPS OF (pi/2).

set( gca, 'XTickLabel', { 'ZEER', 'pi/2', 'pi', '3PI/2', '2*pi' } ) ; %
% labels are 'ZEER', then pi/2, then pi, then 3*pi/2..
% notice these are simply TEXT labels, they are not computed
% or interpretted in any way (they are blindly pasted onto
% the plot axis) so, if you don't supply enough labels
% then MATLAB will wrap back to your first label, like an IDIOT!!

set( gca, 'Color', [0.25,0.9,0.7] ) ; % change color of
% the entire axis i.e the background-color

// ref (bad link)
ref (new link)

some very cool cg stuff

wild assortment of artistic cg tutorials

CG References & Tutorials

remind me to read the blog of the scribbling woman

Cg is cool, but how do you set it up?

If you’re getting errors like

fatal error C1083: Cannot open include file: ‘Cg/cg.h’: No such file or directory


error LNK2019: unresolved external symbol __imp__cgGLLoadProgram referenced in function _main myCgProgram.obj

you probably don’t have your Visual Studio environment variables set up properly.

Below is a quick explanation of why the error occurs, then simple steps to follow to fix it.

WHY does fatal error C1083: Cannot open include file: ‘Cg/cg.h’: No such file or directory happen, even though I’ve installed the Cg Toolkit?

  • COMPILER ERROR: (“FATAL ERROR”) Cannot include ‘Cg/cg.h’. Happens because Visual Studio CAN’T FIND “Cg.h” because you didn’t tell Visual Studio WHERE to find it. I explain how to tell Visual Studio where to find “Cg.h” later on, in the “DO THIS” section near the bottom of this page.

WHY do I get a linker error?

  • LINKER ERROR: The list of about 50,000 errors that come up saying something about “unresolved external symbol”. This happens because Visual Studio doesn’t know where to find the Cg library files (cg.lib and cgGL.lib)
  • Now if you’re impatient for the answers to fix this ASAP, just skip down to the “DO THIS” section.

    But why do the NVIDIA examples work while the new projects I create don’t?

    We’re going to first examine what Nvidia did to get theirs to work, then we’re going to show how to make yours work easily.

    Open one of the projects that generous Nvidia gives you when you install the Cg toolkit (in the “Cg Toolkit” -> “Explore Cg Toolkit” directory from your start menu)

    Once you have that open, do this:

    Project Property pages

    You get this dialog:


    Now click “C/C++” -> General:

    Additional include directory

    NOTICE under “Additional Include Directories” they’ve ADDED

    $(CG_INC_PATH);c:\Program Files\NVIDIA Corporation\Cg\include

    Ok? NOTICED that? THAT is how NVIDIA is telling Visual Studio where to find “Cg.h” and that will get rid of the FATAL ERROR. However, there’s an easier way that I’ll explain in the “DO THIS” section below.

    NEXT, click “Linker->General”.

    Additional library for linker

    NOTICE there that they have ADDED under “Additional Library Directories”

    $(CG_LIB_PATH);c:\Program Files\NVIDIA Corporation\Cg\lib

    THAT is how NVIDIA tells Cg how to find the library files, which is the first step to fixing the linker errors.

    FINALLY, let’s NOTICE one last thing. Under “Linker->Input”:

    Additional dependencies

    NOTICE under “Additional Dependencies” they’ve added:

    cg.lib cgGL.lib

    So how to fix?

    Well you could go and for every single one of your Visual Studio projects that use Cg, make the same changes that I’ve just shown you pictorally above.

    But that’s painstaking and annoying to do for every project.

    There’s a way to do this that’s better.

    Do this

    To make that part of your default settings in Visual Studio, you have to do the following. Open the Tools->Options menu in Visual Studio:

    Options menu in Visual Studio

    You get window:

    Options dialog in Visual Studio 2005

    On the left hand side of the window, choose “Projects and Solutions”, then choose “VC++ Directories”

    Now do this:

    Add include dirs to env variables

    Next, do this:

    Add lib dirs

    FINALLY, YOU MUST ADD the following 2 lines of code

    #pragma comment( lib, "cg.lib" )
    #pragma comment( lib, "cgGL.lib" )

    ANYWHERE in your C program (I usually put them just after #include <Cg/cg.h>).

    Those 2 #pragmas work to do the same thing as the

    cg.lib cgGL.lib

    addition under “additional dependencies”.

    What about using the CGC compiler?

    How do you use the cgc compiler?

    Its actually easy.

    1. Set up cgc environment variable. To do this, see “Adding the Cg Compiler Environment Variable” here
    2. Open up the command line in windows by pressing WINDOWS_KEY+R to get the RUN dialog, then type in “cmd”.

      You get this black window.

      Then, try this.

      cgc -help

      To compile a cg program in general using cgc that has filename and entry function vertexShaderFunction():

      cgc -entry vertexShaderFunction -o vertexShader.vp
     – name of vertex shader program to compile

      -entry vertexShaderFunction – tells cg the name of the vertex shader function. if you don’t specify the entry function name, then cg looks for an entry function named main(). If there is no main() function in and you don’t specify the entry function, then the compilation fails.

      -o vertexShader.vp – the output file. If you open this after compilation, you’ll see all the assembly language that will be sent to the graphics card. Aren’t you glad you don’t have to write that!

    3. and this

Lots of people know you have to use &gt; in your HTML to get the > sign.

However, it appears that lots of people don’t know you can get superscripts and subscripts by using the <sup> and <sub> tags.

You can also get the ≤ sign by using &le; in your HTML.

I love this page.

more HTML entities than you thought existed.

And a unicode character reference for bloggers.

The process of determining the set of pixels covered by a geometric primitive.
Think “frame” as in “single frame of a movie.” The framebuffer is the 2D array of pixels that stores a complete “frame” that the viewer will see on the next refresh cycle of the monitor. Continuously updated, somewhere around 60 times per second.

In a “dumb” framebuffer, the CPU has to update all the pixels. In modern programs, the job of updating of pixel values in the framebuffer is left entirely to the GPU. That frees up the CPU to do other things (AI, process game logic, etc).

Look really closely at your monitor. You’ll find that its really made up of thousands and thousands of tiny squares. Each of these tiny squares is called a “pixel”. “Pixel” stands for “picture element.” An average laptop monitor today has something like 1024×768 pixels on it.
A fragment is a “piece” of a pixel. Every final pixel that you see on your screen might be the result of blending together many different FRAGMENTS. That’s how you get cool looking images.

For instance, say you’re drawing a complex image from a computer game.

Imagine we’re looking through a water fall at some rocks.

We generate the pixels that should be shown on the monitor, we’ll actually TWO FRAGMENTS for each pixel. One fragment for the WATER at each pixel (which is partly see through), and other fragment for the color of the rock.

At a later stage, we will “blend” the fragments that resulted from drawing the water (which, like I said, are going to be partly see through) and the fragments from drawing the rock to form a single final PIXEL at each little square of the monitor. Every pixel in the end will just have regular RGB color values, even though FRAGMENTS can have some transclucency.


Understanding epsilon-delta proofs

First, get and read this. Really good.

before you even START with epsilon-delta . . .

| x – 3 | < 1;

SAYS in English “x is within 1 unit of 3.”

You have to be fluent with that idea before starting ε-delta; proofs.

Let’s look at a picture of this inequality on the real number line:

x lies here

So for example, if x = 2.8:

| 2.8 - 3 | < 1
| -0.2 | < 1
0.2 < 1    ===   TRUE

Now let’s try for x = 3.5.

| 3.5 - 3 | < 1
| 0.5 | < 1
0.5 < 1   ===   TRUE

So, | x – 3 | < 1 MEANS x must be within 1 unit of 3 on the real number line.

To be able to understand epsilon-delta at all, you have to get into the habit of looking at an inequality like

| x – 10 | < 5

And immediately just say in a snap “That inequality says that x is within 5 units of 10”

| x – 0.4 | < 0.00001

And say “That inequality says that x is within 0.00001 units of 0.4.”

In general, for any inequality with the format:

| x – c | < a

That says in plain english that “x is within a units of c.”

Epsilon-delta proofs are actually easy.

The meat of epsilon-delta proofs

The meat of epsilon-delta proofs is just this idea.

0 < | x – c | < δ

| f(x) – L | < ε

Epsilon-delta says:

AS WE RESTRICT x to being within δ units of c, then, as a result of that restriction, f(x) becomes restricted to being within ε units of L.

If the above statement is true, then and only then can we say

lim   f(x) = L

So, here’s the “definition of a limit”, but with more explanation in English words:

The limit:

lim f(x) = L

exists if and only if

when we restrict x to be within δ units of c,

0 < | x – c | < δ

then, as a consequence of that restriction, we in effect are restricting f(x) to be within ε units of L.

| f(x) – L | < ε

If that happens, then we know that the limit of f(x) as x -> c is equal to L.

Ok, but how do you do an epsilon-delta proof?

So here’s an example of how this stuff works.

Use epsilon-delta to "show" that

lim  3x - 3  =  12

I know what you’re thinking. “Can’t we just do this:”

lim  3x - 3

= 15 - 3

= 12

but nooooooo! That’s not good enough for epsilon-stupid. You must “show” it.

Use epsilon-delta to "show" that

lim  3x - 3  =  12

So, what we use the “definition of a limit” as stated at the top of this page (you should memorize it really for use on tests (YES they DO ALWAYS put epsilon-delta on tests . . )

The limit above exists if and only if for each ε > 0, there exists a δ > 0 such that:

    0 < | x - c | < δ            [ c = 5 though, plug in: ]
    0 < | x - 5 | < δ

      | f(x) - L | < ε         [ f(x)= 3x - 3, and L = 12, plug in: ]
      | ( 3x - 3 ) - 12 | < ε

So read that in English as:

“IF x is within δ units of 5 . . . ”

“. . . THEN ( 3x – 3 ) is within ε units of 12.”

The key to epsilon-delta proofs is you have to relate epsilon and delta.

You have to argue that IF 0 < | x – 5 | < δ ( x is within δ units of 5 ), THEN we can conclude that | ( 3x – 3 ) – 12 | < ε (THEN ( 3x – 3 ) is within ε units of 12 ).

HMM! Hopefully, this is starting to make some sense. Here is how you proceed.

Let’s work with the THEN part (the | f(x) – L | statement), and break it down a bit:

      | ( 3x - 3 ) - 12 | < ε
      | 3x - 15 | < ε

Let’s FACTOR (because we love to factor)

      | (3)(x - 5) | < ε
     3| (x - 5) | < ε
      | (x - 5) | < ε/3;

That looks familiar! Suddenly, the | f(x) – L | < ε looks a lot like the | x – c | < δ statement.


We can relate the epsilon statement and the delta statement ( 0 < | x – c | < δ ) in this way:

CHOOSE δ = ε/3. (Get used to the idea of “CHOOSING” δ)

Then, we go:

      | x - 5 | < ε/3   [ CHOOSE δ = ε/3 ]

      | x - 5 | < δ

WOW!!!!! How marvellous. It will seem very very strange to you that in the middle of this “mathematical rigor”, we end up going and “choosing” δ = ε/3. You’ll see that this “choice” doesn’t really hurt the “rigor” of what we’re doing though. . . just keep at it.

Next we have to show that this “δ” we’ve chosen ( δ = ε/3 ) “WORKS”.

So we go back to the original statement:

    0 < | x - c | < δ            [ c = 5, chose δ = ε/3 ]
    0 < | x - 5 | < ε/3;

      | f(x) - L | < ε         [ f(x)= 3x - 3, and L = 12, plug in: ]
      | ( 3x - 3 ) - 12 | < ε
      | 3x - 15 | < ε
     3| x - 5 | < ε
      | x - 5 | < ε/3

Wonder of wonders! It “WORKS”, because the statement has now changed from:

“IF x is within δ units of 5 . . . THEN ( 3x – 3 ) is within ε units of 12.”

“IF x is within ε/3 units of 5, THEN x is within ε/3 units of 5.”

Which cannot be argued against.

Remember, its not stupid. Its “rigorous”.

(donation should be to

*This list is being expanded

  • The period . operator.

    You put the . in front of an operator like ^ or * to get “element by element” operation behavior. Its best explained by example.

    Say you have a row matrix called ‘x’ that has 10000 values in it.

    You want a plot of y = x2, so you need to create another row vector to save values of y to put those values in.

    Instead of writing a loop like:

    for( i = 1:length(x) )
    y(i) = x(i)^2;

    Just use the special . notation and write:

    x = -3:0.01:3;
    y = x.^(2);

    Here, .^ means to raise every element of x to the power of 2, not to try to raise the ENTIRE matrix to the power 2 (which clearly generates an error).

    matlab docs ref

In plotting a simple cube root function y = x1/3, you expect to see a graph like this:
Real cube root graph

But when you do

x = -3:0.01:3;
y = x.^(1/3);

You get:
Complex cube root graph


“Pete wanted it that way.”

No, but really. Why is the plot of the cube root complex-valued, and not real-valued?

You should know that there are in fact __3__ cube roots for any number.

For instance, -3 has 1 real, and 2 COMPLEX cube roots:

The three cube roots of -3 are:

  • 0.7211 + 1.2490i
  • 0.7211 – 1.2490i
  • -1.44224

They look like this in the complex plane. Notice that they are separated by 120 degrees.

roots of -3

When you multiply those cube roots together, you get -3 again:

(0.7211 + 1.249i)*(0.7211 - 1.249i)*(-1.44224)
= (2.08)(-1.44224)
= -3

When you do:

x = -3:0.01:3;
y = x.^(1/3);

Matlab is putting the first cube root inside y (values like 0.7211 + 1.2490i as the cube root of -3), hence giving y complex values.

Howdya get it to give you just the real ones? Use Matlab’s nthroot function. For example, try:

x = -3:0.01:3;
y = nthroot( x, 3 );

just see this.

y = nthroot(X, n) returns the real nth root of the elements of X. Both X and n must be real and n must be a scalar. If X has negative entries, n must be an odd integer.


nthroot(-2, 3)
returns the real cube root of -2.

ans =


You can find the slope of a curve

m = lim(x->c) f(x) - f(c)
                 x - c

this guy howard richman.

makes this page that’s supposed to outline a few principles for studying.

I think he’s got it all wrong. His “rules” will leave you in the gutter, not at the top of your class.

Here’s a summary of his points, and my problems in bold below each.

  1. Study in Short, Frequent Sessions.
    It has been proven that short bursts of concentration repeated frequently are much more effective than one long session. So, even if you only have 10 minutes, DO IT. Take a break. Then study another 10 minutes. This “distributed learning” approach is highly efficient because it honors the way the brain likes to work. The brain needs recovery and recharging time for “protein synthesis.” The rest periods are when your brain assimilates your effort. They are a powerful tool which many teachers do not acknowledge. To sit and study for hours and hours is not only boring, it creates fatigue, stress, and distraction. You cannot learn if you are fatigued, stressed, and distracted!

    No!! Studying for 10 minutes is usually enough to just get started. If you take a break too often, you’ll never get into the ‘zone’, which is when you actually study for one or two hours on end, without being distracted from your work.
    When you’re in the zone, its like watching a good movie, believe it or not. You’re engaged in what you’re doing. Interruption, in this case, is pretty much going to cut back progress (do you like to pause a good movie in the middle, and take a 10 minute break? Not if you’re really into the movie!)

  2. Take Guilt-Free Days of Rest.
    This follows the same principle as above, but on a longer, daily time cycle. The reason for resting is to refresh oneself. However, if you feel guilty (“I really should be studying”) then your precious rest period has been used to create more stress. The brain will not absorb new data if it is stressed. On days off from studying, really enjoy yourself and do not feel bad about not studying.

    Depends just how often these full days off occur. Frequent days off are bad news.

    Somebody under tight deadlines should only very rarely give himself a taste of full freedom from work. Its just too sweet — it can be hard to get back into the swing of things if you’ve taken too much time off. Full days off can make you lazy or extra further behind the next day you do get back to work.

    Sometimes if you need some time off, a block of 5-10 hours does the trick, without making you fall behind as much or making you as lazy or reluctant to get back to work.

  3. Honor Your Emotional State.
    Do not study if you are tired, angry, distracted, or in a hurry. When the brain is relaxed, it is like a sponge and it naturally absorbs data without effort. If you are emotionally stressed, your brain literally repels data. Forcing yourself to sit and study when your mind is on other things is a complete waste of time!

    NO. Again FATAL. People use this as an excuse not to study. Soon, they run out of time and the test is the next day. They were too “emotionally stressed” to sit down and study in the entire WEEK that was before, and now they’re emotionally stressed and in a bind!

    Once you sit down and begin to study, sometimes you can totally forget your problems.

  4. Review the Same Day.
    When you learn something new, try to go over the points the same day. If you wait a few days and then make efforts to review the material, it will seem much less familiar. However, a quick review later in the day will tend to cement the information into your brain so that the next “official” study session, you will recognize it and it will seem easy.

    This is a good tip. But most people are too damn lazy to do this one.

  5. Observe the Natural Learning Sequence.
    Think of the activities you did when you were in nursery school. Using your whole arm, you probably performed the song that goes: “Put your right hand in, Put your right hand out.” Then, in kindergarten, using your hand, you might have been asked to draw lines or circles with crayons. Later, in first grade, now holding the pencil with your fingers, you drew smaller lines and circles to create letters. Believe it or not, this natural learning sequence, moving from large to small, coarse to fine, still remains effective even though we are now older. When you study, if you try first to grasp the big picture and then fill in the details, you often have a more likely chance of success.

    What? Big picture, then details, sure. Crayons and circles? :).

  6. Use Exaggeration.
    Why does a baseball batter warm up by swinging two or three bats? Why do runners sometimes strap lead weights to their legs? In both cases, exaggeration during practice makes the final result seem easy. This concept can be applied to studying anything. For example, if you are studying spelling, exaggerate the sound of the letters to help to remember them. So for studying purposes, “naive” would be pronounced “NAY-IVY.” By getting used to this exaggerated pronunciation, the correct spelling seems obvious.

    Ok. I kind of agree with this one.

  7. Prepare Your Study Environment.

    If you require certain elements in your environment to help you study, try to always make these a priority. For example, do you need special lighting, silence, music, privacy, available snacks, etc.? Pay attention to what works for you and repeat it each time you study for best success.

    Is this studying or hibernation?

  8. Respect “Brain Fade.”

    It is normal for the brain to have an attrition rate and to forget things. This does not mean that you are stupid! Instead of getting mad about this fact, you should expect it and deal with it accordingly. See your brain as depositing layers of knowledge. As you place more information on top, the lower levels become older and less available to your immediate recall. The trick here is simply to review. Since we can anticipate the eventual fading of our memory, creating a review aspect to our study session will solve the problem. Once every two or three study sessions, simply review older material that you will be still needing to remember. Often, a quick overview is sufficient. Sometimes, a complete detailed study session of the older material is required. “Brain fade” is completely normal. (Unless you are gifted with a photographic memory, which is extremely rare.)

    Yeah yeah. Happens. Is this a “study tip” or should it just say “be patient with yourself”?

  9. Create a Study Routine.
    Generally, if you schedule certain times of the day to study, you will get into a routine and accomplish more. If you just “fit it in” during your day, chances are that there will never be any time. An effective way to do this is to literally mark it down in your datebook calendar as if you have an appointment, like going to the doctor. For example: “Tuesday 3-4:30 P.M. — Study.”

    Good point, but you should take that one step further. You should write exactly what you’re going to study, and what you’re supposed to finish in that 3-4:30pm time block.

    So you’d write something like: “Tuesday 3-4:30 PM — Problems 1-22 and 25-40 on page 108 of Math book”

  10. Set Reasonable Goals.

    One of the main reasons people do not reach their goals is because they set them too high. If you set goals that are manageable, even if they seem too simple, you get in the habit of accomplishing them and gradually you can set higher goals. Also, recognize the difference between long-term and short-term goals. Set your vision on the long-term dream, but your day-to-day activity should be focused exclusively on the short-term, enabling steps.

    Meh. More than anything this reminds me of Homer’s advice to his son: “aim low.”

    Sometimes people with great potential settle for mediocrity because mediocrity was their goal.

    Setting goals that SEEM unachievable at first may enable you to hit a higher target than if you set your goals low and just achieve them.

    I guess the most important thing is to not get discouraged too much if you miss your high goals.

    Something that may work for you is a tiered goal system: Set some unrealistically high goals and say “This would be really good if I could do this.” Then set the “realistic” or “fallback” goal and say: “but more likely, I’m going to only be able to do this.”

  11. Avoid the Frustration Enemy.
    Ironically, the quicker the person’s nervous system, the faster they learn. Yet, this fast nervous system also works overtime in being self-critical. So they are the ones who always think they aren’t going fast enough! In contrast, the “Type B,” less intense person who learns slower yet is more self-accepting, ends up ultimately learning the material in a shorter period of time. This is because he/she doesn’t waste energy blocking, getting upset, and thinking that they’re not good enough — they simply keep moving forward at a slower (but un-blocked) pace.

    Hmm. That’s an interesting point.

These tips were prepared by Howard Richman and are offered for free as a courtesy.

Why thank you, generous Howard.

wow! this company provides (expensive) lectures you can buy.

they seem to use the same guys over and over again (for music anyway), but its interesting though.


a great site, at first blush here, i’m seeing recordings are quite a bit less than perfect. there are chairs creaking and coughs in the background. i’ll try looking for a few more recordings before giving up on it.

I originally got the reference to musopen from this article about music for studying

somaFM radio

weird and cool sigur-ros


This list is being expanded

Interesting article:

Machines that can determine a person’s intent based on a few factors.

Summative paragraph from article below.

Current research focuses on three key areas. The first is recognition of gestures and so-called “microfacial expressions” — a poker player might call them “tells” — that flash across a person’s face in about one third of a second. Some researchers say micro expressions can betray a person when he is trying to deceive.

The second area is analysis of variations in speech, such as pitch and loudness, for indicators of untruthfulness.

The third is measurement of physiological characteristics such as blood pressure, pulse, skin moisture and respiration that have been associated with polygraphs, or lie detectors.

How to complete the square

Usually you have to complete the square when you’re trying to draw a graph of a parabola that has an equation like:

x2 + 5x + 3 = 0

You only know where the vertex of the parabola goes if you can get it in the form

(x – a)2 + C = 0

The cool thing about “completing the square” is when you do it, you actually will always be able to get any polynomial into that (x – a)2 + C = 0 form.

How to complete the square

Working with our example x2 + 5x + 3 = 0

1 >> Take the 5 (from the 5x term) and divide it by 2.


2 >> Square it.


= 25

3 >> Add AND subtract that squared number from the original polynomial

Now, all you have to do is take that value you just got (25/4) and ADD AND SUBTRACT 25/4 FROM THE ORIGINAL x2 + 5x + 3 = 0.

Here is how you do it (pay special attention to WHERE I’m putting the 25/4):

x2 + 5x + 3 = 0

x2 + 5x + 25/4 - 25/4 + 3 = 0

Now the important thing to realize is that what I’ve just written is completely 100%-ly MATHEMATICALLY EQUAL to the original

x2 + 5x + 25/4 - 25/4 + 3 = x2 + 5x + 3

OK?? Make sure you know that.

4 >> “complete the square”

Next, what you do is, you just write this:

x2 + 5x + 25/4 - 25/4 + 3 = 0

(x + 5/2)2 - 25/4 + 3 = 0

(x + 5/2)2 - 13/4 = 0

Notice the 5/2 value . . . we’ve seen that before (go look where).

And that’s how its done.

We can check that the answer we’ve written is correct by multiplying back out. We should get the original polynomial when we’re done:

(x + 5/2)2 - 13/4 = 0

(x + 5/2)(x + 5/2) - 13/4 = 0

x2 + 2(5/2)x + (5/2)2 - 13/4 = 0

x2 + 5x + 25/4 - 13/4 = 0

x2 + 5x + 12/4 = 0

x2 + 5x + 3 = 0

And that’s the same as the original polynomial.

Ok, that was a specific example. What doing this to polynomials in general?

Just apply the pattern. In general, if you have

x2 + Bx + C = 0

You complete the square by doing this:

x2 + Bx + C = 0

( x + (B/2) )2 - (B/2)2 + C = 0

Note also that if you have a polynomial of the form

Ax2 + Bx + C = 0

You change it to being in the form:

A(x2 + (B/A)x) + C = 0

So for example, given

5x2 + 7x + 10 = 0

5( x2 + (7/5)x ) + 10 = 0

5( x + (7/10) 2 - (7/10)2 ) + 10 = 0

5( x + (7/10) )2 - 49/100 ) + 10 = 0

5( x + (7/10) )2 - (5)(49)/100 + 10 = 0

5( x + (7/10) )2 + 151/20 = 0

Check its correct by multiplying back out.

5( x + (7/10) )2 + 151/20 = 0

5( x2 + 2(7/10)x + 49/100 ) + 151/20 = 0

5x2 + 7x + 49/20 + 151/20 = 0

5x2 + 7x + 10 = 0

Which is the same as the original.

Say you have 2 lines in the plane. You are given their slopes.

The angle between 2 lines in the 2D cartesian plane is given by:

tan( a ) = | (m2 – m1) / (1 + m1m2) |

If the lines are perpendicular, then

m1m2 = -1

and so

(1 + m1m2) = 0

then a = 90 degrees and the lines are perpendicular.

cool conic sections thing

anyone tried “rappelz”?

Hmm. It looks interesting

Functions in math can be one of the most confusing topics for the newbie.

I remember struggling this was a totally dreaded topic in high school.

So here’s an explanation that might help with that.

A function is like a vending machine. It takes inputs, and it spits out outputs.

Picture a vending machine like this one:

Vending machine

Surely you’ve seen one of these beastly contraptions sometime.

Ok, now notice how the vending machine has INPUTS: which are just the buttons on the keypad.

Now, to get an output out of the vending machine, what you do is, you put in the correct amount of money ($1), then you input the correct keycode.

So assume that the blue Crunch bar is what I want. It costs $1 and the keycode for it is D3.

So the INPUT is the keycode D3. The OUTPUT is the CRUNCH BAR. The idea of a FUNCTION is that a FUNCTION is something that takes your INPUT, and spits out some OUTPUT, depending on the value you inputted.

So the vending machine IS a FUNCTION. It takes your INPUT (keys pressed), and depending on what keys you pressed, it gives a different OUTPUT (some kind of candy bar).

So::::: Remember this: A FUNCTION is what RELATES the INPUT VALUE to the OUTPUTTED VALUE.

So somewhere inside that vending machine, is a FUNCTION that looks at the keys you INPUTTED and then OUTPUTS the correct chocolate bar or bag of chips or whatever.

But what about MATH functions?

Math functions are easy. Let’s do this by example. Say I have a function:

f(x) = 3x + 5

You have to get used to the notation. Whenever you see something like that, then the whole thing in the box just above this line is called a MATHEMATICAL FUNCTION.

Now, that MATHEMATICAL FUNCTION is really just like our vending machine, if you think about it. The mathematical function has an INPUT (the value of x!), and it has an OUTPUT (the value of f(x)!)

Input? Output?? wtf?

f(x) = 3x + 5

Just watch what I’m doing here and try to follow along.

I am going to find the OUTPUT of the function f(x) when the INPUT is 2.

f(2) = 3(2) + 5
f(2) = 6 + 5
f(2) = 11

Therefore, the OUTPUT of the function f(x) is 11 when the INPUT is 2.

Let’s take it one line at a time.

The first thing you do, is you take the formula

f(x) = 3x + 5

Now, you are asked to find the OUTPUT of the function f(x) when the INPUT is 2.

INPUT IS 2 just means that you have to take the original formula

f(x) = 3x + 5


f(2) = 3(2) + 5

Then you can just see that its plain old math as usual from here. 3 times 2 plus 5 is 11.

f(2) = 6 + 5
f(2) = 11

Domain and Range

Take another look at the vending machine up top.

Notice that the vending machine has keys A to J and then number keys 0 to 9.

If you’ve ever used one of these things, then you know the vending machine only accepts inputs such as A1, A2, D2, or D5, or E9. So the vending machine only accepts your INPUT if you punch in a LETTER, then a NUMBER. You can’t punch in AA, for example. The vending machine wouldn’t understand that because it has no candy bar that it knows to give you for AA.

That is exactly the idea of DOMAIN. The DOMAIN of a FUNCTION IS the set of all INPUTS that the function UNDERSTANDS and CAN give you an OUTPUT for.

What’s the range then? The RANGE is the set of all possible OUTPUTS of the FUNCTION.

So the range of the vending machine above is SOMETHING LIKE:

{ Lays, Ruffles, Fritos, Cirspys, Rold Gold, Crunch, Snickers, Butterfingers . . . } (it goes on but you get the picture)

So looking again at another MATHEMATICAL FUNCTION, let’s find the domain and range of it:

f(x) = 1/x2

What you have to do to determine the DOMAIN of f(x) is just think. Are there any INPUT values of x that I can choose for which f(x) will not have a proper value?

In fact, for f(x) = 1/x, the DOMAIN is {x | x is an element of the set of ALL REAL NUMBERS, x != 0}

x cannot be zero, because 1/0 is undefined (+infinity).

the RANGE is going to be the set of all values that f(x) can take on. Think about what I mean by “take on”. . I mean the set of all possible values that f(x) can have as a result as we give it different values of x.

The range can be harder to know. For the vending machine example, its really easy to know what the range is. You just look through the glass and see the set of all outputs that the vending machine can produce.

For a MATHEMATICAL FUNCTION, the analysis is a bit tougher.


f(x) = 1/x2

We know that as x takes on values from (-minus infinity, plus infinity), f(x) takes on values from just above 0 (when x is extremely large in magnitude), to positive infinity (when x is extremely small in magnitude).


Range = { y | y > 0, y is an element of the real numbers }

Hmm. You might be a bit confused at this point.

It will eventually make sense. Toss the ideas around in your head and you will get it.


Remember, a function is a vending machine.

I’m currently reading Tuesdays with Morrie. I think its fantastic.

Massive wisdom. For those who don’t know, the book is a series of conversations that Mitch Albom has with his friend and mentor Morrie Schwartz as Morrie is suffering a fatal disease.

Here are some quotes from the book that I particularly liked:

Know you’re going to die, and be prepared for it at any time.

Don’t cling to things, because everything is impermanent

If you want the experience of having complete responsibility for another human being, and to learn how to love and bond in the deepest way, then you should have children.

Albom also says that America has become a “Persian Bazaar of self-help”. ha ha ha.

A few more quotes: p 127:

Devote yourself to loving others, devote yourself to your community around you, and devote yourself to creating something that gives you purpose and meaning.

You notice there’s nothing in there about a salary.

pg 127:

Mitch, if you’re trying to show off for people at the top, forget it. They will look down at you anyhow. And if you’re trying to show off for people at the bottom, forget it. They will only envy you. Status will get you nowhere. Only an open heart will allow you to float equally between everyone.

pg 149:

Is there some kind of rule to know if a marriage is going to work?

Morrie smiled. “Things are not that simple, Mitch.”
I know.
“Still,” he said, “there are a few rules I know to be true about love and marriage: If you don’t respect the other person, you’re gonna have a lot of trouble. If you don’t know how to compromise, you’re gonna have a lot of trouble. If you can’t talk openly about what goes on between you, you’re gonna have a lot of trouble. And if you don’t have a common set of values in life, you’re gonna have a lot of trouble. Your values must be alike.

And the biggest one of those values, Mitch?

Your belief in the importance of your marriage.

People are only mean when they’re threatened,” he said later that day, “and that’s what our culture does. That’s what our economy does. Even people who have jobs in our economy are threatened, because they worry about losing them. And when you get threatened, you start looking out only for yourself. You start making money a god. It is all part of this culture.

i’m thinking about there will be blood again tonight.

There’s one moment in particular that I’m still thinking about.

That is the moment when when Paul Sunday is trying to hack a deal with Daniel Plainview. Plainview says that in order to complete this deal, Paul has to proclaim “i am a false prophet; god is a superstition.”

So the camera cuts to a frontal angle. Paul’s face fills the screen as he makes the proclaimation repeatedly, louder and louder, at the encouragement of Plainsview.

Sheesh. Talk about subliminal.

I remember moments from films when I was a child that planted images in my mind that I simply could not forget. That image is planted in my mind and you simply cannot forget it.

here’s a cute book

this is cool

I thought the movie was fantastic.

I think the critics overreacted (with positive enthsiasm), however.

The short of it is I was thoroughly entertained. Daniel Day-Lewis is fantastic. Maybe I’ll write more later, maybe not.

thought this was cool.

all about the triangle

mathematical fallacies

this superstition index is fun to read.

Ryan Porter is a gossip column writer for msn.

However, I was wondering, who is Ryan Porter??? I did a Google image search and came up with this image of some college kid named Ryan Porter standing next to a fantastic looking girl named Kelly MacDonald.

Ryan Porter’s writing is quite good, but I wonder who is really is.

ha ha ha. this is kind of amusing.

check out google trends for the words “i wish”

Google wish graph

it seems there’s a spike in “wishing” through google near christmas time. i remember when it was candles on a cake, an eyelash you stick down your shirt, a dandelion you blow the little white things off of, a pond into which you throw a penny. crossing your fingers. a wishbone.


Look at this moronic quotation from Salas, Hille and Etgen’s “Calculus: One and Several variables”:

Choose any point P, P != O, in the plane. Let l1 be the line through P parallel to the y-axis and l2 the line through P parallel to the x-axis. Let a be the coordinate of the point of intersection of l1 and the x-axis, and let b be the coordinate of the point of intersection of l2 and the y-axis. Then P is identified with the ordered pair of real numbers (a, b).

I mean, come on. All they’re describing there is how you find a point by an ordered pair in the cartesian plane.

This is some of the worst writing I have ever seen. It is written like a C program where variable declarations are all at the top of the program. “Let l1 be, a be, let b be”… really. People don’t read like computers.

There is a much more human way of writing this, and they haven’t got it.

The strange thing is in their introduction to the text, they promise:

“The mathematical statements are careful and precise; the basic concepts and important points are not obscured by excess verbiage”

To be fair, there are quite a few places where I’ve said to myself “Yes, well done there. That is well stated.” But at other times . . . . they’re not writing for people. They’re writing for themselves and defining things with a degree of rigor that just makes the writing harder to read while imparting no additional understanding to the reader.