Gmail Bug? Or Chrome? Either way – Google.

August 16th, 2010  |  Published in ASP.NET

The WIERDEST things are happening to me today.  I had a meeting with the web security guy and nobody ended up yelling.  I made a phone call to my wife with a reported 0 bar reception on my phone and now I find some strange happenings in my Gmail.  I opened a chat window and highlighted the text area and continued to highlight moving down and I got this strange whitespace to open up underneath the mail area.  Yes, I blurred out my email.  I wouldn’t trust you people with a rusty nickel.

GmailBug

No Bars In No Places

August 16th, 2010  |  Published in Rants, iPhone

This is me trying to call my wife from my desk.  In the middle of Nashville.  I have done this no less than 10,000 times over the past 3 years.  Interestingly enough though, the call still goes through.  Hmmmm…..

NoBarsNoPlaces

Jailbreak Your iPhone From Safari Right Now

August 4th, 2010  |  Published in ASP.NET

How about instead of shelling out an additional $200 for iPhone 4 and thusly forfeiting your unlimited data by re-upping your contract with AT&T, you simply Jailbreak your 3G or 3GS and enjoy a brand new iPhone experience!

It’s fun and easy kids.  Here’s how:

On your phone, open Safari and browse to http://www.jailbreakme.com.  Once you get there, slide the slider over to “Jailbreak” and in about 3 minutes, your phone will be free.  I mean really free.  Free to do multitasking with ProSwitcher and Backgrounder.  Free to shoot hi-res native video.  Free to play flash video.  Free to be all that it can be – and so much more.

I know Jailbreaking sounds sketchy, but look, the library of congress has already ruled that it is perfectly legal.  On top of that, I can tell you from experience that having the basic set of jailbreak tools (like multitasking and video) will genuinely reinvent your iPhone experience.

An Open Letter To Steve Jobs

July 6th, 2010  |  Published in ASP.NET  |  4 Comments

From: Me
To: Steve Jobs

Dear Mr. Jobs

Your iOS 4 bricked my 3G. Thanks for that.

Sincerely,

Me

Looping through SharePoint List Items In A Workflow

April 21st, 2010  |  Published in SharePoint

Sometimes you need to have a workflow that loops through all the items in a list and then matches them on some criteria and performs an action.  Considering the following all-to-often occurring scenario…

You setup a list of tasks, or some sort of tracking list and assigned tasks go uncompleted because people don’t mark them as complete.  This will happen to you if you use SharePoint.  Death, taxes and incomplete SharePoint tasks are 3 things that are unavoidable in life.

You need a way to remind them that they have an open task assigned to them.

The problem is that SharePoint does not support a workflow that runs against the entire list.  Workflows run against a single item.  Whichever item initiated them.

The key to solving this without cracking open Visual Studio is to resign yourself to working with a single object at a time.  Instead of a workflow that runs AGAINST all list objects, we are going to create a workflow (2 actually) that runs FOR each list object. 

The idea here is recursion.  Recursion is a programming principle that simply means a function or method that calls itself.  Simple.  What we need is a workflow that calls itself.  The workflow should just run non-stop until a condition is satisfied and then an action is taken.

This is not possible anymore as of SP 2 – which is a good thing because you don’t always want endless looping in your workflow.  As of SP 2, a workflow can no longer initiate itself.

We can get the same effect using 2 workflows.  Here is the logic..

  1. We have a field in our list item that the user never sees called “BeingProcessed”.  It’s a Yes/No field that defaults to “No”.
  2. We have 1 workflow that initiates manually, on create and on change.
  3. We have a second workflow that initiates only on change

Here is the kicker – both workflows are going to do EXACTLY the same thing.  Here is the workflow logic in psuedo code…

if the BeingProcessed field of the current item is “No” and our other condition is satisified (for instance, the modified date is 2 days old and the task is still open), we are going to set the BeingProcessed flag to Yes, send an email to the assignee asking them to please close the task, and then we are going to set the BeingProcessed back to No.

else if the BeingProcess field is “No” and our other condition is not satisified, we are simply going to set the BeingProcessed field to “Yes” and then sleep for a certain amount of time (lets say 24 hours).  After that, we are going to set the BeingProcessed back to “No”.

What does this do?

It causes 1 workflow to either take an action or sleep for 24 hours and then wakeup and change the item which causes the SECOND workflow to kick off and do exactly the same thing, initiating the first workflow after it completes by also updating the item.  What we then get is a single workflow that is running ALL the time on a given item until certain conditions are met.  It seems heavy handed, but all we are doing is a quick check and then going to sleep for 24 hours.  It’s very light when you think about it.

That’s an easy way to do “looping” without writing a single line of custom code.  ALL of that can be done in SharePoint Designer.

Linq To SQL Procedures Return An Int

April 15th, 2010  |  Published in ASP.NET

I was working with a procedure the other day and I saw something that I see from time to time.  A stored procedure that returns a results set gets mapped to an Int in the DBML declaration of your Linq To Sql mapping.

Why does this happen?

This can happen for 2 reasons.

1.  You are using temp tables in your stored procedure

2.  The user account you are using in your DBML is NOT the dbo for the database.

There are several articles out there that will mention one or the other, but both conditions have to be satisfied before the DBML will spit out a results set as your return type.

The fix for #2 is obvious – grant your user the correct permission and make sure the schema mapping is correct.

The fix for #1 is ugly, but efficient.

Comment out your entire proc after the BEGIN and put in a select that returns the data types that your proc will be returning.  Compile.   Return to Visual Studio and drop the proc from your DBML.  Refresh your data source in the sidebar and drag the proc back out.  It should now map to an ISingleResultType.  Go back to your procedure and remove the single select.  Uncomment out the proc and recompile.  It will now return a set of data to your application as you desired.

I love Linq To SQL and I hope MSFT put some more work into it for 2010.

Relative Paths In ASP.NET MVC

March 16th, 2010  |  Published in ASP.NET

If you have been working with MVC for any amount of time, you have most likely been already confounded by the inability to quickly get the root URL of your application for referencing either javascript files, or ajax method url’s. 

There are many documented workarounds for this, and I am going to cover 2.  The first one you are probably familiar with, but the second is a little trick I stumbled on and perfected a bit myself.  It will help keep your javascript references clean and can be used anywhere in your project.

Lets start with the fundamental problem of referencing a javascript file in your Master Page, or any other page for that matter.

When working in Visual Studio, you know what your path is, and you can alter it as needed to get to the root.  I.E. ../../Content/

This presents the problem that the final resting place for your app is hopefully not going to be on your localhost and you need your project to be able to reference the application root no matter how far down a directory structure you put it.

We can solve this problem by using the Url.Content method to reference javascript.  A reference in the Master Page header than looks like this.

Code Snippet
  1. <script src="<%= Url.Content("~/Content/jQuery/jquery-1.4.1.min.js")%>" type="text/javascript"></script>

That works just fine for including files, but if you have a page where the javascript is getting very lengthy, and you want to break it out, you have this problem again referencing the relative path url from the .js file.  The reason for this is that the .js file is not parsed by the ASP.NET engine, so those server tags never get translated.

While looking for a solution to this problem, I stumbled upon a post on Stack Overflow where someone was trying to do something similar and someone responded with a method of setting a javascript function in the code behind to return your absolute url value. I could see this guy was on to something, but it was a little verbose.

Here is what I came up with to accomplish essentially the same thing.  This would go in the header of your page after your jQuery include (and btw – if you aren’t using jQuery, then disregard this post and go improve your life SIGNIFICANTLY by finding out what it is.)

Code Snippet
  1. // create a function for getting the root path
  2.         $(function() {
  3.             $.url = function(url) {
  4.                 {
  5.                     var path = '<%= Request.ApplicationPath %>'
  6.  
  7.                     if (path != '/')
  8.                         path = path + '/'
  9.                     
  10.                     return path + url;
  11.                 }
  12.             }
  13.         });

You can now reference your root path by using the $.url() function anywhere in your project (provided you did this in the Master Page).  For example, and ajax call becomes…

Code Snippet
  1. $.getJSON($.url('Home/GetInfo'), { employeeNumber: employeeNumber },
  2.                 function(data) {
  3.                     if (!data)
  4.                         alert("Unable to retrieve info");
  5.                 });

Now you have an easy way to always know your root path.  I give credit on this to the author of the Stack Overflow article. It is a crafty way to solve a project wide problem with very few lines of code.  It also makes your javascript cleaner and prettier.  What we might call a “Graceful” solution.

My Thoughts On Winter

February 15th, 2010  |  Published in ASP.NET

This may be inappropriate, but I really feel like it needs to be said…

winter8bn

My Favorite iPhone Tricks You May – Or May Not Know

February 4th, 2010  |  Published in Mac, iPhone

I learn new tricks on my iPhone all the time. Sometimes I assume I’ve stumbled on some unknown nugget of brilliance and then I tell someone else and I realize that pretty much everyone has known about said feature since less than a week after they got their device.

So at the risk of once again claiming discovery on the obvious, here are some of my favorite iPhone tricks and tips that you may – or may not already know…

Saving A Web Site As An App

You can save any website you visit in Safari as an app to your phone.  It puts an icon on one of your home screens and you have a shortcut directly to that site anytime you need it.

Simply click the + button in the toolbar on any web page and select "Add To Home Screen".  The web page is saved as a convenient icon.  Think of it as your ability to make custom apps out of any web page.

photo

Taking Screenshots

You can take a screenshot of whatever is on your iPhone at any moment.  You can then MMS the message, or the next time you connect your iPhone, you can transfer the picture to your computer.  It’s quite useful for lots of things, like writing posts on iPhone tricks for example.

Hold down the sleep button and without releasing, press the home button.  You will hear a camera click and see a flash type effect on the screen.  You can then find your screenshot by going to your photos and looking under camera roll.

Navigate iPod When Phone Is Locked

When you are listening to the iPod on your phone, and you lock your phone to conserve power, you don’t have to unlock the phone to skip or pause a song.  If you have the iPhone headphones, you can use the clicker, but if not, you can always simply double-click the home button whilst the phone is still locked, and you will get a set of music controls that drop down at the top underneath the time.

photo (1)

Alarm

Your phone does in fact have an alarm on it, it’s just not in a quite-so-obvious place.  Under the seemingly useless “Clock” application, pick the alarm icon in the toolbar.  This will allow you to setup alarms with recurrence and change their sound.  An interesting side note is that the alarm will still sound with your phone on vibrate.  This is great because you don’t want phone calls waking you up, but you do want the alarm to.

photo (2)

Already knew about all of these?

I hope at least one of these is new to you.  They were all new to me recently.  The iPhone is such a great device in that it seemingly does everything and does most of it extremely well.  I personally am looking forward to owning an iPad in the near future.

Got A Slow Mac?

January 10th, 2010  |  Published in ASP.NET

Mac people sometimes begin to believe that they are immune to normal PC problems. For the most part, this is very true. However, mac users will of course still experience the occasional setback from time to time. One that seems common to me is the old “My computer is slow” issue. If you have a PC, this is a much more convoluted issue as it could be any number of things from a virus, to a rogue program to a fragged disc. If you have a mac, the solution is likely much more simple.

Two things usually contribute to the slowness you experience on your mac. I’m not talking about slowness that comes from installing Leopard on an emac, or the slowness that comes from running pro tools on an ibook. I mean slowness where your mac is clearly slower than it was when you first had it.

1. Disc permissions
2. A Cluttered Desktop

Often times when your mac slows down, its because the permissions on your disc need to be repaired. This is really easy to do. Go to your disc utility in the Utilities folder in your Applications folder. Select your hard drive (Usually called Macintosh HD) and select “Verify Disc Permissions”. When this action has completed, select “Repair Disc Permissions”.

For some reason that I will never know, if you clutter the desktop of a mac – especially if its a G series mac running Tiger, the whole computer will slow down. Clear off your desktop. Put everything in folders somewhere in your home folder. You computer will look much better anyway after you do this.

After you have done these two things, you are going to do something that PC users do several times a week. Reboot. Don’t panic, it’s not going to become a habit.

Your mac should now be back to its normal speedy state.

BTW – I know I “sound” like an Apple Fanboi, but I’m not. I’m actually a PC. It’s a religious debate. I won’t start on it. Just know that I see the advantages in both systems and I choose PC.