Source Code To That Drum Tabs Program I Wrote A Long Time Ago

Way back in 2009 I wrote a quick program to let you build out any drum tabs to play in a rockband style.  To this day (over a year later) I still get people asking if it is released or if they can buy or or anything along those lines.  Well the short answer is it looks like I’m not going to bother finishing it.  But I will release the source code and a compiled exe for free.  (I just upgraded it to Visual Studio 2010 and tested it in C# Express so you can get working on it w/o having to have the full Visual Studio Library.)

  1. Download Visual Studio C# 2010 Express
    http://www.microsoft.com/express/Downloads/#2010-Visual-CS
  2. Download John Hasson Trum Tabs
    http://dl.dropbox.com/u/6423641/Drumtabs.rar
  3. Enjoy. — Beware.. There are bugs and it is not finished.
    You will need to get the mp3’s yourself.. but at least you can get started with it.

What Does Clickfraud Look Like?

It looks like this.  (Note: it is not always this obvious… a simple rule is that your clicks curve should match your sales curve… — there are always exceptions to this rule)

image

Obviously I should not be buying their traffic during the evenings…

Hint (it is mostly Yahoo Traffic)…

How To Use Amazon EC2 for offloading CPU intensive tasks

I’ve got some processes that I use to test historical data. I like to optimize them till they are running very fast (as can be expected)…. Normally this will suffice, but on this test I’ve got several variables to test — essentially I am looking at about 200 days of processing to get my results; but I don’t want to wait 200 days.

So.. the solution [a solution] in cases like this is to use something like EC2. There are other solutions, use a bunch of old laptops, or a ec2 competitor, but since all my code is in C# w/ MSSQL server, ec2 is my first choice.

Step 1 (since I am doing this on a small windows instance) the code must be converted to a service. This is so you can launch an instance and have your code start right up. A few things to watch out for: You can’t just throw a timer control on the service and expect it to work, you actually have to write one.

private Timer oTimer;
private int _interval = 1000;
private string currentTask = ""; // Lazy way of making sure I don't step on my own toes...

protected override void OnStart(string[] args)
{
TimerCallback timerDelegate = new TimerCallback(OnTimedEvent);

// create timer and attach our method delegate to it
oTimer = new Timer(timerDelegate, null, 1000, _interval);
}

private void OnTimedEvent(Object state)
{

if (currentTask == "")
{
currentTask = "Working";

//Do your processes

currentTask = "";

}

Don’t forget dependencies (in my case I had to add a dependency for MSSQL$SQLEXPRESS (so it won’t start will the database server is up and running) — I also added a test in the code to make sure I could connect just in case, since in one of my realworld tests I had some racing issues.

Ok… service is all fine and dandy.  You have tested your EC2 instance (windows small w/ sql express is cheapest for this situation at $0.12 per hour). Make sure that you have it set to automatic, and that there are no weird issues on reboot to keep your service from starting how you want.

In this case I have them all communicating with a central Non EC2 database server to track which server is doing what tests and to store the results.  This allows me to start 5, 20, 100, etc instances at once and to just let them run.  [Actually amazon limits you to 20 instances, unless you get special approval -- which doesn't seem hard to get, I just haven't done it yet, since I don't know if I will actually need it]

Now that you have your serer all updated (windows update, and starting it starts up your service and the logging and tracking works, etc.. it is time to make this into an AMI (instance that you can use to start up as many servers as you want)

I left mine at the default size of 30 gigs, but if I were to do it over again, I would research how to lower the size to say 8 or 10 gigs (of the original hard disk) since I don’t need that much space, and I bet amazon is charging me for all that space even though I am not using it.  Amazon ec2 has changed quite a bit over the past 12 months.  I personally use a combination of elasticfox and the AWS web console to manage my instances.  elastic fox doesn’t have a “start” option for a shut down instance, but AWS does, and there are a few other quirks…

Anyways, I would recommend shutting down the server first, then using AWS to make an EBS AMI Instance (right click on your instance).  This is less hassle then doing it via S3 if you really havent bothered to setup S3 yet (like me).

This will take a while (30-60 minutes).  I didn’t keep track, but I know it took more then 20 minutes.  Once that is done, it is just a matter of starting 20 instances of your private AMI.

Then sit back and wait while the results come in.

In N Out opened today in American Fork

Opening day the line is long but moving very fast 2 doubles 1 animal double and some fries

In n Out (its not as far as is looks)

Line is kinda long… but moves way fast.. :)

Almost can pay…. lame… they don’t take AMEX.  I am pretty sure I remember them taking amex in california..

~ $12 later I have had 2 hamburgers, 2 boxes of fries and introduced my spouse to In-N-Out with her own burger.

A good lunch :)

Faster Tablet PC w/ More Ram :)

Memory America made my laptop faster :)

Over a year ago I decided I wanted a 10″ iPod touch.  Well since those didn’t exist I went for the next best thing.  A second hand tablet pc that used to be used in a morgue.  (The weird formaldehyde smell went away after a few weeks)

Enter the HP TC1100.. a great little machine.  Perfect for… well a tablet pc..

Here is the back… before I opened up the memory slot with my super amazingly complex “tiny phillips” screwdriver.

It is open…   the anticipation.. oh the sweet anticipation.

It is in… thats it?  I used the 1 Gig “off brand” memory for my tc1100 here.

Put the back back on and turn it on.

Much snappier response time for just about everything.

Need To Get Your Adwords Campaigns Over to Yahoo Search or MSN adCenter Quickly?

This is an internal tool we’ve been using for a while, with the mass adwords account banning going on I figured people would have a need of this. It runs entirely on your local computer ( windows, linux, or mac), nothing is sent to a server somewhere. It does cool things like KWI from google to yahoo or msn and replacing text during the conversion.

Download link here
http://www.johnhasson.com/index.php/jah-adwords-to-yahoo-or-msn/

Edit/Update
12/11/2009
Yahoo match types are done “correctly” (as correct as you can going from google to yahoo). Broad = Advance, Phrase & Exact = Standard.

Transparent And Glass Console In C#

I’ve got some processes that I run quite a bit that run in C# console applications. Here is how I make them trasnparent (and give them a slight vista glass effect)
(If you use just the glass code writing behind will usually b too blurry to read, but if you combine transparency w/ glass the writing it still slightly glowy/blury but easily readable)

GlassTransparent


using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace GlassExample
{
    class Program
    {
        [DllImport("user32.dll")]
        static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey,
           byte bAlpha, uint dwFlags);

        [DllImport("user32.dll")]
        static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern System.UInt32 GetWindowLong(IntPtr hWnd, int nIndex);

        public const int GWL_EXSTYLE = -20;
        public const int WS_EX_LAYERED = 0x80000;
        public const int LWA_ALPHA = 0x2;
        public const int LWA_COLORKEY = 0x1;

        [StructLayout(LayoutKind.Sequential)]
        public struct DWM_BLURBEHIND
        {
            public DwmBlurBehindDwFlags dwFlags;
            public bool fEnable;
            public IntPtr hRgnBlur;
            public bool fTransitionOnMaximized;
        }

        [Flags()]
        public enum DwmBlurBehindDwFlags : uint
        {
            DWM_BB_ENABLE = 0x1,
            DWM_BB_BLURREGION = 0x2,
            DWM_BB_TRANSITIONONMAXIMIZED = 0x4
        }

        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);

        static void EnableBlurBehind()
        {
            IntPtr Handle = Process.GetCurrentProcess().MainWindowHandle;
            DWM_BLURBEHIND blur = new DWM_BLURBEHIND();
            blur.dwFlags = DwmBlurBehindDwFlags.DWM_BB_ENABLE;// +DwmBlurBehindDwFlags.DWM_BB_TRANSITIONONMAXIMIZED;
            blur.fEnable = true;
            //blur.hRgnBlur = 0;
            blur.fTransitionOnMaximized = true;// DwmBlurBehindDwFlags.DWM_BB_TRANSITIONONMAXIMIZED;

            DwmEnableBlurBehindWindow(Handle, ref blur);
        }

        static void MakeTransparent(byte pct)
        {
            IntPtr Handle = Process.GetCurrentProcess().MainWindowHandle;
            int newDwLong = ((int)GetWindowLong(Handle, GWL_EXSTYLE)) ^ WS_EX_LAYERED;
            SetWindowLong(Handle, GWL_EXSTYLE, newDwLong);
            SetLayeredWindowAttributes(Handle, 0, pct, LWA_ALPHA);
        }

        static void Main(string[] args)
        {
            EnableBlurBehind();
            MakeTransparent(170);  //0 to 255

            Console.WriteLine("Test");

            Console.ReadKey();

        }

    }
}

(There is zero error checking here… this will probably crash on XP, caveat emptor, etc)

1,990 Pages?! Nope, thats just white space and double spacing.

Don’t get me wrong, the new healthcare bill is definitely long, but lately (past several months) people seem to be claiming that the length of a bill is proportional to how bad it is.

Any legislative formatted document will be about 4 times its actual length.

For reference, here is the original HR 3962 1990 page proposed health bill pdf. (Original source of HR 3962)

Here it is cleaned up as a plain text file (just the content of the bill)

And here it is as a 519 page word doc.

It is pretty easy to find things you don’t like in this bill, even though I actually would like national health coverage I can find plenty in here that make me not want to support it in its current state. (Also easy to find things you do like if you look hard enough ;) ) Hint, grab the text version and load it up in your favorite text editor and start searching. My guess is they filled it with so much that is obviously controversial (govt funded abortions, etc) on purpose, so they can take it out as a negotiation tactic.

Drum/Guitar Tabs In Rockband Style

I had a pretty productive Saturday. 

After some tweaking this late afternoon I have it about 99% done..

All that is left is to add a leader into the songs (so it doesn’t start right away).  You can get any TAB off the internet and sync it up with your mp3 file for the song.  And tada… now you can use your elite rockband skills to play the real thing. 

You have to manually edit the actual start and end seconds for the tabs [and fix the tabs since alot of them arent perfect matches for the CD version of the songs] — This is why on some songs there is a noticeable offset

This took me about a day to write (mostly Saturday), and then a late afternoon to find and edit the tab files so that it would read them.

 

I started with 21 Guns by Greenday as I debugged the program.  Parts of the Tabs are perfect, but alot of them need quite a bit of manual editing.  (I think the tabs were from the music video and not the CD)

 

Then I Did Red Hot Chili Peppers (Under the bridge) Mostly because my wife really wants to learn to play it.

 

Then I was thinking… well she actually wants to play it on guitar… 15 minutes later (with no editing of the source code, just the data/tab file {thats very cool if u know anything about coding :) }) – she can now use her elite rockband 2 skills to play the guitar… or at least practice till she can play it :)   [I took out some of the fancy stuff in the tab till she gets the basics down]

And finally I did Weezer – Buddy Holly.  It syncs up perfectly.

I’ve also done Lenny Kravitz… but the drum tabs I found were off quite..

Long story short… you can pick just about any song and from 15 minutes to an hour (depends on the quality of the tab file) have a tweaked tab file ready to play and practice rockband style.

Office Evolution

My office environment seems to change about ever 3-4 months.  This is my latest arrangement.  8 monitors, 5 computers linked via Synergy and a cheap drum kit.

This is what my office currently looks likeM01A0427

 

These are old pictures
M01A0310 M01A0311  M01A0312

And this one is even older
M01A0289