Cash for Clunkers - FAIL

June 24, 2009 14:16 by bjones

Starting in July, you can trade in your old "clunker" for a new car and receive a $3500 or even $4500 voucher. The purpose of this bill is to put more fuel efficient vehicles on the road and get rid of guzzlers. It sounds like a good idea but their oversites have failed to make it a great idea and therefore have failed completely.

What would have made it better?

  • Why just improve gas mileage? Why not improve emissions too? A car from 1990 has a higher emissions standard than a 2010 model. Why not get rid of the 1990 car and get a cleaner burning car on the road?
  • Why not use this as a time to help stimulate the economy and help the failing car manufactures? Since it’s the US tax dollars that are paying for the vouchers, why not have given an extra bonus for buying a GM, Ford or Chrysler?

 

There are so many problems with the implementation that the program is worthless. First, you have to trade in your old car for a new one that improves the combined fuel economy by at least 2 MPG for light duty trucks and 4 MPG for passenger cars. If you improve your truck or car by 5 or 10 MPG, respectively, you will get the full $4,500 voucher. Why is the 2/4/5/10 MPG a problem? Because, in 2008, they changed the way they rate MPGs of cars. Starting in 2008 the EPA changed the rating to be at a faster speed, faster acceleration, air conditioner on and colder outside temperatures. This means that the new car ratings are more accurate but what it really means is that the MPG rating for your "clunker" is going to be inflated and makes it almost impossible to achieve the improvements needed for the voucher.

My dad has a 1993 GMC Sonoma truck. It’s considered a light-duty truck and therefore requires a 2/5 MPG improvement for the vouchers. The best way to describe his 16 year old truck is to call it a clunker. The EPA says it gets a combined 18 MPG. In order for him to qualify for the $3,500 voucher, he will have to buy a vehicle that gets 20MPG or better. Good luck finding that in a truck. After calling the NHTSA, they recommended he buy a sedan or a hybrid truck. Get real! A GMC Sierra Hybrid starts at $39,365 and it’s rated at 21/22 MPG for a combined 21 MPG. The non-hybrid GMC Sierra starts at $20,350 and is rated at 15/21 MPG for a combined 18 MPG. That means a 3 MPG improvement costs $20,000. The improvement in emissions and gas mileage are virtually nil. The improvement over a 18 MPG GMC Sierra and his 1993 GMC Sonoma are a real 3 MPG improvement (real, not over inflated EPA ratings) and a huge improvement in emissions.

The government is not encouraging my dad to buy a new truck. Therefore they are not:

  • Getting rid of a large polluting vehicle
  • Improving real gas mileage
  • Stimulating the economy.  For a bankrupt American car manufacture!



-FAIL-

 

 


Prepoulate a form with data from a DataTable in .net

June 3, 2009 10:42 by bjones

Abstract

A simple .net class that will prepopulate form data on a page.  My requirements were to be able to find a control anywhere on a page (with or without a masterpage) and still be able to control the look of the form.  I did not want to dynamically create the controls because I want to easily control the look of the form without adding any metadata in to the database.

 

Meat and Potatoes

Inevitably when building a website I will have a page (or multiple) that should display information about an item, account, person, etc.  For example, I always have a "My Account" page where I will show the user data we have collected that could be everything from their name and email address to their shoe or ring size.  There could be a dozen or more fields displayed.  Some fields may be read-only (Label) and some may be editable (TextBox).  I start out building the page in the designer with a table and then adding all of my fields as either a TextBox or Label.  Then, I switch to the code behind and poulate a DataTable with the information I need.  The DataTable is always a single row with all that person's data.  I then have to type all the fields names and set their Text value to the DataTable's records.  Rinse and repeat, ice the wrist, rinse and repeat, etc.

In the .aspx page I may have:

<table border="0" cellpadding="10" cellspacing="0">
    <tr>
        <td align="left">First Name</td>
        <td align="left"><asp:Label ID="aFName" runat="server" /></td>
    </tr>
    <tr>
        <td align="left">Last Name</td>
        <td align="left"><asp:Label ID="aLName" runat="server" /></td>
    </tr>
    .
    .
    .
</table>

In the code behind I would then have to do this:

aFName.Text = dt.Rows[0]["aFName"].ToString();
aLName.Text = dt.Rows[0]["aLName"].ToString();
aEmail.Text = dt.Rows[0]["aEmail"].ToString();
aDisplayName.Text = dt.Rows[0]["aDisplayName"].ToString();
aCellPhone.Text = dt.Rows[0]["aCellPhone"].ToString();
aSignUpDate.Text = dt.Rows[0]["aSignUpDate"].ToString();
atDesc.Text = dt.Rows[0]["atDesc"].ToString();
.
.
.

 

This is an inefficient use of time and caffeine.  Since I do this all the time, I decided to write a class that does this in a more efficient way.  When you create the page design you have to name the controls the exact same name (case sensitive) as the column in your DataTable.  We loop through the DataTable and do a FindControl to then populate the data.  This worked fine until I created a page with a MasterPage - ugh!  FindControl isn't recursive so I hunted online and found a recursive FindControl and included it in my class.  Now it works on all pages.  I have cut my time (not caffeine intake) down considerably.  Now I can use that found time to blog :)

 

Here's the class (webhelper.cs):

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Form functions
/// </summary>
public class webhelper
{
    /// <summary>
    /// Finds a control recursively.  Works in a page that has a masterpage, otherwise FindControl will return a null.
    /// </summary>
    /// <param name="root">Parent to search for - use "this"</param>
    /// <param name="id">Name of control you are searching for</param>
    /// <returns>Control - control you are searching for or a null if it's not found</returns>
    public static Control FindControlRecursive(Control root, string id)
    {
        if (root.ID == id)
        {
            return root;
        }

        foreach (Control c in root.Controls)
        {
            Control t = FindControlRecursive(c, id);
            if (t != null)
            {
                return t;
            }
        }

        return null;
    }

    /// <summary>
    /// Will pre-populate textbox and labels on a page with information from the first row of the DataTable. 
    /// Common use would be an account information page where you only have one row returned.
    /// TextBox and Label ID's must match the column name in the DataTable.
    /// </summary>
    /// <param name="root">Send "this" as the page root.</param>
    /// <param name="dt">DataTable with a single row.  If there are multiple rows it will only prepopulate the form with the first row.</param>
    public static void populateForm(Control root, DataTable dt)
    {
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            Control c = FindControlRecursive(root, dt.Columns[i].ToString());
            if (c != null)
            {
                if (c.GetType() == typeof(TextBox))
                {
                    TextBox myBox = (TextBox)c;
                    myBox.Text = dt.Rows[0][i].ToString();
                }
                else if (c.GetType() == typeof(Label))
                {
                    Label myLabel = (Label)c;
                    myLabel.Text = dt.Rows[0][i].ToString();
                }
            }
        }


    }
}
[/code]

 

And here is how you use it on a page (dt has been defined as a DataTable and is populated with account information):

webhelper.populateForm(this, dt);

 

Wow, what an improvement in typing, huh?  In a future blog I'll show you how to do the same thing for saving the page.

You can download the class here.

 


Sending email through GMail (or Google apps) with C#

May 29, 2009 10:18 by bjones

I have a couple of websites I've built that use GoDaddy hosting.  Instead of paying GoDaddy for their email service for my domains, I use Google Apps. It's free, they keep increasing the amount of storage (7GBs as of this blog) and I like the search feature.  In addition, I don't want to have my emails bounce as SPAM because I'm relaying it off GoDaddy's open relay so I'm bouncing it off of smtp.google.com.  Don't forget to add an SPF record (maybe I'll make that part 2 of this article).

I've been using System.Net.Mail to bounce email off a local SMTP host but had to go back to System.Web.Mail in order to authenticate for Google (my tin foil hat personality would suggest that Microsoft deprecated System.Web.Mail and left out authentication on System.Net.Mail to stop us from using Gmail). 

Below is a function I use to send email through GMail in my C# web apps.  The original code was written by Alex Sanchez for bouncing it off your local (or remote) mail server without authentication; I bastardized it to add authentication.


I have a typo in the Param section for the inFrom.  I couldn't figure out how to excape a < or > so I had to leave them out.  Make sure you use this format for your inFrom: "Name To Display" <email@domain.com>.  

Here you go: 

[code:c#]

/// <summary>
/// Sends email using Gmail or Email for Google apps.
/// </summary>
/// <param name="inFrom">From email addresses - format is: "Name To Display" email@domain.com </param>
/// <param name="inTo">To email addresses</param>
/// <param name="inSubject">Subject line</param>
/// <param name="inBody">Body of email in html markup or plain text</param>
/// <param name="inAttachmentPaths">String array of attachment paths on webserver</param>
/// <param name="isHTMLFormat">1 = HTML Format, 2 = plain text</param>
/// <param name="gmailAccountName">Account name for Gmail.  If you are using Email for Google Apps, you need to supply full email: email@domain.com</param>
/// <param name="gmailPassword">Password for your gmail account</param>
public static void SendEmailViaGmail(string inFrom, string inTo, string inSubject, string inBody, string[] inAttachmentPaths, Boolean isHTMLFormat, string gmailAccountName, string gmailPassword)
{
    System.Web.Mail.MailMessage myMailMessage = null;
   
    // Build email message
    myMailMessage = new System.Web.Mail.MailMessage();
    myMailMessage.From = inFrom;  // Format is: "Name To Display" <email@domain.com>
    myMailMessage.To = inTo;
    myMailMessage.Subject = inSubject;
    myMailMessage.Body = inBody; 
   
    if (isHTMLFormat)  // I send in plain text for SMS messages, HTML for the rest of the world
    {
        myMailMessage.BodyFormat = MailFormat.Html;
    }
    else
    {
        myMailMessage.BodyFormat = MailFormat.Text;
    }
   
   
    // Add attachments
    if (inAttachmentPaths != null)
        for (int i = 0; i < inAttachmentPaths.Length; i++)
            myMailMessage.Attachments.Add(new Attachment(inAttachmentPaths[i]));
   
   
    //  Authenticate
    myMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
    // Username for gmail - email@domain.com for email for Google Apps
    myMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", gmailAccountName);
    // Password for gmail account
    myMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", gmailPassword);
    // Google says to use 465 or 587.  I don't get an answer on 587 and 465 works - YMMV
    myMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
    // STARTTLS
    myMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", true);
   
   
   
   
    // assign outgoing gmail server
    SmtpMail.SmtpServer = "smtp.gmail.com";
    SmtpMail.Send(myMailMessage);
}


Fizzbin

May 1, 2009 15:56 by bjones
This post is only for geeks - you know the guys that live to sit in front of two (or three or better yet, four!) monitors pouring over a stack trace to find out why "is null" and "= null" aren't the same. Or for you sysadmins spending 2 days checking 5,000 cable drops to find out who created a loopback with the $5 linksys hub that brought down your entire network. If you fit one of these categories then fizzbin to you!

Imagine this scenario: You spent the last 16 straight hours working on a 52 node Beowulf cluster and you decide to go home while the final node is coming up. "I'll check it at home," you think to yourself. You get home, down a bottle of bawls and fire up your Macbook to find out that your internet connection is down. You get an IP, ping to your router but nothing further. Dang it, sun spots are wreaking habit again so you pick up the phone and call your ISP. Level 1 support gets on and starts asking you if you turned on your computer and is there a light on your modem? There is no need to talk to level 1 but they won't transfer you until you pretend to disconnect your wireless router and plug your computer (that you lied and said was XP so they would help) directly in to the cable modem. Reboot, wait, unplug cables, wait, unplug modems, wait, etc...

It's time to put an end to this frustration. Yes, my Mom needs to go through each step but, we geeks don't. Scott Hanselman has come up with an ingenious way for us to wink at the support tech on the other end of the phone and get us on to some real troubleshooting on their end. Fizzbin! It's a secret codeword that we can use to get past the mundane troubleshooting. It's so simple to use, just say "fizzbin" and the level 1 techie will know that you've already done everything she is going to asking you. And everything her level 2 techie is going to ask you so you both stop wasting each other's time. It will only work if we all know it, so pass it on!

Fizzbin to you!

Stop the racism surrounding the H1N1 virus (swine flu)

May 1, 2009 13:07 by bjones
Michael Savage, a talk show host, said to avoid "contact anywhere with an illegal alien... and that starts with restaurants... don't know if they wipe their behinds with their hands!" Wait, seriously? I guess I have it all wrong, only illegal aliens don’t wash their hands. And only illegal aliens can spread the disease.

Frankly, I'm appalled with the racism surrounding the H1N1 virus! I think people are scared of the virus and they are too emotionally stunted to express themselves so the only thing they can do is conjure up hatred. People are using this outbreak as a way to promote their racist agenda. I mean, who is going to complain about a racist comment here or there about the supposed dirty people that gave us this flu?

Hispanic people are not dirty, they are not sub-Human and they are not all illegal aliens. Let people know this kind of racism disguised as stupidity is unacceptable (here is a list of stations that stream Michaels Savage's radio show).

When need to work together to get past the H1N1 virus, not against each other.
Tags: ,
Categories: op ed
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Walmart won't compete with Walmart?

April 22, 2009 17:58 by bjones

Our cable internet has been going down about 6-7 times a day.  It's incredibly frustrating now that Cherish and I are both working from home.  Today COX came out to look and said the signal was strong and there was nothing wrong with the connection.  The tech recommending buying a new cable modem.  I looked online for his recommended Motorola Surfboard and found that Bestbuy had it for $79.99 and Walmart had it for $49.99.  No-brainer, right?  Wrong!

I got to Walmart and More...

Tags:
Categories: op ed
Actions: E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

Safe And Legal Alternative To A Cell Phone Jammer

March 25, 2009 21:03 by bjones

We've all been in a movie theater, business meeting, fancy restaurant or even taking a test in school when someone's cell phone rings... and they answer it! I can't think of anything more frustrating than the ringer of a cell phone or shouting a conversation into a phone in an inopportune moment.

Restaurant owners, movie theaters and even schools are so frustrated with the problem that they buy illegal cell phone jammers for their establishments. Not only are they risking thousands of dollars in fines and a year in jail but they put every person in range of the jammer in danger of not being able to make an emergency call if necessary. The jammers also extend well past their intended area and disrupt emergency service’s communication. As a parent, I would be upset to hear that my child’s school was implementing such a dangerous device to combat the problem.

Soon there will be a safe, legal and elegant alternative: Zone of Silence. Zone of Silence is not a cell phone jammer and does not disrupt the cell phone signals in any way. Instead, it sets up a zone of a configurable size that communicates with software on the phone to limit functionality. A zone can be configured to control one or more of the following:

  • Inbound calls
  • Outbound calls
  • Inbound text
  • Outbound text
  • Ringer volume
  • Maximum screen brightness
  • Whether or not the camera can take a picture
  • And more!


911 emergency calls are always allowed.

The device can be configured to allow certain cell phone and numbers to not be restricted. Further, it can be configured to allow incoming calls from a certain number to a certain number. For example, a school can put in the student’s cell phone number and link it to their parents’ cell phone numbers so that the parents and students can still call and/or text eachother even if calls and texts are being blocked.

ZoS is safe because it allows 911 calls at any time without any intervention from the owner of the ZoS Device or the cell phone owner. It can also be turned off remotely by ZoS in the event of a natural or other disaster.

ZoS is legal because it doesn’t block or broadcast on regulated frequencies. It communicates with the phones over wi-fi and Bluetooth; both part of an unregulated spectrum.

ZoS is elegant because it allows such granular control of the phone functionalities and allows the ZoS Device owner to designate unrestricted phones. Unlike a cell phone jammer, it notifies the recipient that they have missed a call or text so that they walk outside the zone to return it.

The possible uses of Zone of Silence are endless! Schools can block inbound and outbound calls and text messages for students while allowing the teacher’s phone to be unrestricted. Theaters can block all calls, set the ringer to vibrate mode, allow text messages but set the maximum screen brightness to 50% so that the phone doesn’t annoy the other paying customers. Restaurants can block all calls and all text messages so that the patron will be notified of the missed call or text and they can walk outside the zone to return it. High security buildings can use ZoS Devices to block everything including the camera. Gyms can even install the ZoS Devices inside their locker rooms to stop the camera from taking pictures while still allowing all other features to function normally,

As Zone of Silence says: Own your zone.

Visit Zone of Silence to read more and fill out information on the Contact Us page to stay informed of progress.


AIG Bonus - Outrageous!

March 16, 2009 11:50 by bjones

AIG is going to pay out $165 million in bonus after 1) taking $170 billion tax payers dollars and 2) losing $61.7 billion in 2008 Q4, the largest in corporate history.  People should be angry about this!  It's appauling for a company to lose money and pay bonuses at the same time.  How do I get a contractual obligation that if my company loses $61.7 billion a quater that I get a bonus?  This is just another example of corporate greed putting themselves before anyone else.

I think the Obama administration should stop payment on the checks and put a retroactive law in place saying that any company talking bailout money is not allowed to pay cash bonuses to their employees or executives until over dollar is paid back.  Since tax payers as a whole own 80% of the company, we should all be allowed to cast a vote for the board and CEO to get rid of these crooks!


Tags: , ,
Categories: op ed | Rant
Actions: E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed