Archive for the 'Personal' Category

10
Apr

Successful Unlock of Two AT&T iPhones (iPhone 3G and iPhone 4S)

iTunes Unlock Confirmation

iTunes Unlock Confirmation

Summary (TL;DR)

This is a bit long but the short and sweet is that you have to:

  1. Get AT&T to go to a separate “iPhone Unlock” page before they send the unlocking email. The email is not connected to your IMEI unlock in any way. It’s just instructions.
  2. Put a non-AT&T SIM into the iPhone. T-Mobile prepaid works great for this
  3. Wait for iPhone to display “Needs Activation” message after it finds the foreign network
  4. Connect to iTunes (twice for me) to get the “Congratulations” message. I got an error the first time on each phone after inserting the foreign SIM.
  5. No backup/restore is necessary, contradictory to AT&T instructions.

I was able to get a 3G and 4S unlocked.

The Good News

Last Friday, AT&T announced that they would begin unlocking iPhones that met any of the following conditions if the account was in good standing:

  • iPhone is out of contract (24 months since purchase)
  • iPhone has been upgraded to a new phone with AT&T upgrade
  • iPhone has been purchased with no-commitment pricing
  • iPhone contract has been terminated and ETF has been paid

I have two phones that meet those conditions. One is an iPhone 3G I got when I signed up for AT&T. I then upgraded to an iPhone 4 when it came out in June 2010. I sold the iPhone 4 to an individual on Craigslist and then purchased an iPhone 4S from an individual on Craigslist who represented to me that it was not connected to any contract (no commitment pricing). Therefore, my 3G and 4S should be eligible.

First Try

I contacted AT&T Sunday morning to request an unlock on both. As I expected, they thought I was crazy and told me AT&T doesn’t unlock iPhones. I requested that they check with a supervisor or check online documentation. After a brief hold, they confirmed they were unlocking iPhones, but they’d have to connect me to another department. After waiting on hold with me for about an hour across two times they hung up on me, I got the second department.

They took my IMEIs (the number that identifies a device on a GSM network) to verify eligibility. My 3G passed. My 4S, I was told, would not be eligible since I didn’t have a receipt and it wasn’t connected to any contract on my account. I appealed this and they spoke with a supervisor. AT&T was able to verify the 4S was not connected to any contract and therefore was eligible. The representative sent me a link to this PDF to explain the rest of the unlock and told me that both phones were unlocked.

The gist of the PDF is that you must backup and restore the iPhone to get it to unlock in iTunes. I knew this was not the normal procedure for other countries that do iPhone unlocking, but I didn’t have enough information to question it yet.

I tried with both iPhones, backing up and restoring, and got no message in iTunes confirming an unlock, like other people from other countries have been getting for years. I thought maybe it was unlocked and I just didn’t know, so on Monday, I paid $10 for a T-Mobile pre-paid MicroSIM so I could test it. Both phones said “Activation Required” and when I plugged them into iTunes, it reported that they were unsupported SIMs. In other words, the phones were not unlocked.

Second Try

Peeved, I called AT&T around 8:30pm on Monday night. I had to start over, and the tier 2 person at AT&T this time had no idea what unlocking meant and kept going to her supervisor who informed me I needed to jailbreak to use it on T-Mobile. I eventually got to this supervisor around 10:50pm (yes, those times are right; the hold to get to tier 2 and 3 was excruciating; they kept wanting me to hang up and call back but I refused), he reiterated the thing about T-Mobile and jailbreaking. I told him this is not how GSM unlocking works.

What I kept explaining is that the previous representative read to me from her AT&T system that “After the ASR has verified the IMEI eligibility and submitted it for unlock”, to go to this other page to send me the previously linked PDF. The PDF is not in any way linked to my IMEI. So I kept telling everyone I spoke to that they were missing a step: in order to unlock the phone, they had to give Apple permission to unlock it, and that’s the part that they weren’t doing. The email itself did nothing other than tell me what would happen if they did unlock it.

Resolution

After arguing for about 15 minutes, since he didn’t understand unlocking but was genuinely trying to help me, Johnathan finally found a link in his system for a separate page that was titled “iPhone Unlock”, hosted by Apple. He put my 3G IMEI into this page after logging in and confirmed the IMEI with me.

I connected the iPhone to iTunes; nothing. I backed it up and restored (no data on the 3G so this goes relatively fast); nothing. I put the T-Mobile SIM in, instead of an AT&T SIM and reconnected to iTunes. This time I got an error, and I forgot to take a screenshot, that said: “Unable to activate” or something like that.

iPhone 4s on T-Mobile Screenshot

iPhone 4s on T-Mobile

Success

I disconnected and reconnected, and suddenly I got the image at the top of this post, confirming activation. My iPhone 3G displayed T-Mobile at the top, and I got a text from T-Mobile welcoming me to the network.

Johnathan and I followed the same process with the iPhone 4S, and I got exactly the same results. I didn’t do a backup and restore at all on the 4S. I just put the T-Mobile SIM in after he submitted the unlock to Apple, waited for it to display Activation Required, connected it to iTunes, got that error message, disconnected, and reconnected. I immediately got the “Congratulations” again. A screenshot from the 4S is at the right.

I’m now very happy both phones are unlocked to work on any GSM carrier, even though it took a lot of my time and patience.

25
Mar

Windows Phone Emulator Time Skew When Computer Sleeps

TLDR: If you put your computer to sleep, the Windows Phone emulator might have the wrong time when you resume. Restart the emulator to get it to have the current time in its clock.

I was working on my fork of an OAuth library for Windows Phone this weekend, and I ran across a really weird issue. I’m posting this in case someone else Googles this problem, since I couldn’t find anything.

I have a UNIX epoch timestamp generator (necessary for Twitter) class that looks like this:

    public class TimestampGenerator
    {
        public string Generate()
        {
            var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
            var now = DateTime.UtcNow;

            long stamp = ((now.Ticks - unixEpoch.Ticks) / 10000000);

            return stamp.ToString();
        }
    }

I worked for hours on this on my desktop and everything was working fine. Then, when I did a git pull on my laptop, it was suddenly broken. When I’d make a request to the term.ie example OAuth service, it said my timestamp was expired every time. I set breakpoints and compared it to the current epoch timestamp, and it was definitely wrong. I tried many ways of calculating it (that division is to get to seconds from 100 microsecond increments (ticks); I haven’t benchmarked to see which is faster), but nothing made a difference.

I calculated a time difference of about 102 hours from my current time based on the timestamps. I finally figured out that my emulator could have the wrong time, since I was thinking computer time == emulator time. I killed the emulator, hit F5, and it worked like a charm. Then, I thought about the time difference, and it was about the last time I put my laptop to sleep by closing its lid.

Apparently, when the computer comes out of sleep, the computer clock stops matching the emulator clock; the emulator clock freezes when the computer sleeps and just resumes from where it left off. I’m not sure if this is a bug or not, or if it happens on a regular basis. I may try to reproduce it later, but probably not.

16
Mar

Pretty IPropertyNotifyChanged Declarations for Windows Phone

The Problem

I’ve been doing a bit of WPF/Windows Phone development. Usually INotifyPropertyChanged declarations for properties are really ugly. The big problem is that the INotifyPropertyChanged interface relies on strings, which don’t refactor well.

I’m also using the fantastic MVVM Light Toolkit, which makes life a lot easier when doing Windows Phone development.

MVVM Light has a snippet that you invoke with the shortcut mvvminpc that produces the following:

/// <summary>
/// The <see cref="ScreenName" /> property's name.
/// </summary>
public const string ScreenNamePropertyName = "ScreenName";

private string _screenName = String.Empty;

/// <summary>
/// Sets and gets the ScreenName property.
/// Changes to that property's value raise the PropertyChanged event. 
/// </summary>
public string ScreenName
{
	get
	{
		return _screenName;
	}

	set
	{
		if (_screenName == value)
		{
			return;
		}

		_screenName = value;
		RaisePropertyChanged(ScreenNamePropertyName);
	}
}

That saves quite a bit of work, but it’s still ugly. It still doesn’t refactor well because you have to change that property that corresponds to the string. MVVM Light also includes another snippet with the shortcut mvvminpclambda that gets closer to what I want, but it’s still a large declaration with the equality checking, but instead of using ScreenNamePropertyName (and you get to lose that property), that call looks like:

RaisePropertyChanged(() => ScreenName);

That’s getting there, but it’s still messy. I found a great solution for this problem from Christian Mosers, but it doesn’t compile in Windows Phone Silverlight due to the lambda compile, and it relies on PropertyChangedEventHandler. Also, Christian’s sets the value after the event handler is called. I’m not sure if that’s a mistake, but it seems like it is, and someone else already pointed that out in his comments.

I’ve modified it a bit and now it works, gives me an inpcpretty shortcut, and cleans up my declarations a lot. I tried making it an extension method of the delegate I created, but that doesn’t work. In the end, I made it an extension of the value type T.

The New Code

        private string _screenName = String.Empty;
        public string ScreenName
        {
            get { return _screenName; }
            set { value.ChangeAndNotify(RaisePropertyChanged, ref _screenName, () => ScreenName); }
        }

The Extension Method

namespace System
{
    public static class INotifyPropertyChangedExtensions
    {
        public delegate void OnPropertyNotifyChangedDelegate(string input);

        public static bool ChangeAndNotify<T>(this T value, OnPropertyNotifyChangedDelegate handler,
            ref T field, Expression<Func<T>> memberExpression)
        {
            if (memberExpression == null)
            {
                throw new ArgumentNullException("memberExpression");
            }
            var body = memberExpression.Body as MemberExpression;
            if (body == null)
            {
                throw new ArgumentException("Lambda must return a property.");
            }
            if (EqualityComparer<T>.Default.Equals(field, value))
            {
                return false;
            }

            var vmExpression = body.Expression as ConstantExpression;
            if (vmExpression != null)
            {
                field = value;

                if (handler != null)
                {
                    handler(body.Member.Name);
                }
            }
            return true;
        }
    }
}

The Snippet

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>INPC Property</Title>
      <Author>Chris Benard</Author>
      <Description>A property raising PropertyChanged with a string. The class using this property should inherit GalaSoft.MvvmLight.ObservableObject.</Description>
      <HelpUrl>http://www.galasoft.ch/mvvm</HelpUrl>
      <Shortcut>inpcpretty</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>Type</ID>
          <ToolTip>Property type</ToolTip>
          <Default>bool</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>AttributeName</ID>
          <ToolTip>Attribute name</ToolTip>
          <Default>_myProperty</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>InitialValue</ID>
          <ToolTip>Initial value</ToolTip>
          <Default>false</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>PropertyName</ID>
          <ToolTip>Property name</ToolTip>
          <Default>MyProperty</Default>
          <Function>
          </Function>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[private $Type$ $AttributeName$ = $InitialValue$;
        public $Type$ $PropertyName$
        {
            get { return $AttributeName$; }
            set { value.ChangeAndNotify(RaisePropertyChanged, ref $AttributeName$, () => $PropertyName$); }
        }]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

Conclusion

There is probably a better way to do this, but I’m not that experienced in WPF/Silverlight/Windows Phone yet. If you know of a better way, please let me know.

To use this snippet, click the raw button in the code listing (looks like <>), save the contents as inpcpretty.snippet. Then, in Visual Studio, go to Tools -> Code Snippets Manager. Switch the language to C# and select Import. Choose the .snippet file you saved and you should be in business!

11
Jan

Speaking at the Dallas PHP User Group

On January 11, 2011 I spoke at the Dallas PHP User Group on the topic of the Kohana v3 MVC Framework and Facebook integration. The introductory slides are below. To download the sample code yourself, head on over to the GitHub project page. Scroll to the bottom of the GitHub page to see the instructions on how to install it on your own server. An example site is available for you to view the running code on the Internet.

11
Dec

First Impressions with Google’s Cr-48 Chrome OS Netbook

On December 7, 2010, Google announced their Chrome OS Notebook reference hardware, the Cr-48 (a bit of a chemistry joke). They also announced a pilot program, by which participants would receive a free netbook running the release version of Chrome OS, with the understanding that the user would provide Google feedback about the operating system. I immediately signed up, since I was listening to the live broadcast of the announcement.

When they announced the pilot program, they put a QR code on the screen at 1:20:24 on the applicable slide. I scanned the QR code using my iPhone and it took me to a signup page. After filling in the information it thanked me for my information and said they would follow up or something. I didn’t think I’d actually get a notebook, but on the following Thursday, people all across the United States started receiving Cr-48s; I hoped I would be one of them. By the end of the day, I was very disappointed.

However, late in the afternoon on Friday, December 10, 2010, I went out to the mailbox to check the mail and a Cr-48 was sitting on my porch.

Here is my initial video right after unboxing:

Additionally, I took pictures of the unboxing, in case anyone cares, because I was so excited (click to see the album):

chromeosalbum

 

Initial thoughts

  • The setup process confused me because I kept tapping to click. I didn’t know you needed to press down hard to click the actual trackpad itself. The entire trackpad is a physical button. This is apparently common to Apple notebooks, I have been told. After the setup process, you can change this in settings to allow “tap-to-click”.
  • It boots up from a power-off state really quickly.
  • It came with at least half a charge. Thanks Google!
  • It takes awhile to set up the free Verizon 100MB data. They really need your information first; I assume this is to address DMCA/child pornography type violations, so they can associate an IP with a physical person.
  • It wakes from sleep instantly, just like in the presentation.
  • The keyboard is insanely good, and all the letters are lower case: an odd touch, not that I spend most of my time looking at the keyboard.
  • In the car at night, I did find myself wishing the keyboard was backlit, so I could see some of the new buttons they’ve replaced, like the function keys.
  • It bogs down really hard on internet videos that are not from you-tube. Comedy Central works fine. Hulu and NBC do not work well at all. They get very choppy. None of these are in HD.
  • YouTube has no option to enable HD. I even tried to force it with “hd=1” in the URL and it ignored it, forcing 480p. I knew it wouldn’t be good, but I wanted to test it and they won’t let me.
  • Logging into the netbook logs you into your Google Account. You don’t have to log in anymore for things like YouTube, Gmail, Reader, Voice, and all the other things that Google runs in my life (Latitude, etc).
  • It’s heavier than it looks; I haven’t weighed it yet, but I’m sure that info is already out there.
  • There was nothing I wanted to do on it that I wasn’t able to do with a webapp or a webpage yet. I even set up IRC through IM+ and IRC through Mibbit.
  • The back on the bottom gets a bit warm after extended use.
  • The battery seems to last forever, but takes awhile to charge.
  • You don’t seem to be able to login with Google Apps accounts. My girlfriend could not login, even when I’d added her ID as a valid ID for use with the Netbook in settings.

If anyone has any questions I haven’t addressed, please ask them in the comments and I’ll answer in my next blog post.

10
Apr

Hosting Windows Workflow Foundation in a Console Application without Ugly Code

I’ve been using Windows Workflow Foundation for a small personal project to learn more about it and see what it can do. It’s pretty powerful and I’m looking forward to delving more into it. For my purposes though, I’m hosting the workflow in a console program.

If you look around the internet, you’ll see lots of examples of hosting a sequential workflow in a synchronous manner, even though the WorkflowRuntime only support asynchronous operations. That code usually looks like this (example adapted from wf-training-guide.com to add support for input/output arguments):

static void Main(string[] args)
{
  Dictionary<string, object> inputArguments = new Dictionary<string, object>();
  inputArguments.Add("Argument1", args[0]);
  Dictionary<string, object> outputArguments;
    
  // Create the WF runtime.
  using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
  {
    // Hook into WorkflowCompleted / WorkflowTerminated events.
    AutoResetEvent waitHandle = new AutoResetEvent(false);
    workflowRuntime.WorkflowCompleted
      += delegate(object sender, WorkflowCompletedEventArgs e)
        {
          outputArguments = e.OutputParameters;
          waitHandle.Set();
        };

    workflowRuntime.WorkflowTerminated
      += delegate(object sender, WorkflowTerminatedEventArgs e)
        {
          Console.WriteLine(e.Exception.Message);
          waitHandle.Set();
        };

    // Create an instance of the WF to execute and call Start().
    WorkflowInstance instance =
      workflowRuntime.CreateWorkflow(typeof(WorkflowClass));
    instance.Start();

    waitHandle.WaitOne();
  }
}

Unfortunately, that’s a ton of code to do only a few things:

  1. Take input arguments
  2. Instantiate a WorkflowRuntime
  3. Create a workflow instance
  4. Run the workflow
  5. Handle any exceptions (poorly)
  6. Return output parameters from the workflow
  7. Do all of this in a synchronous manner.

What if we could just call a method similar to this:

var outputArguments = RunWorkflow<WorkflowClass>(arguments, completedEvent, terminatedEvent);

Well, now you can! I’ve written this wrapper class to allow exactly that:

public class WorkflowManager
{
  public static Dictionary<string, object> RunWorkflow<T>(
    Dictionary<string, object> arguments,
    EventHandler<WorkflowCompletedEventArgs> completedEvent,
    EventHandler<WorkflowTerminatedEventArgs> terminatedEvent)
    where T : SequentialWorkflowActivity
  {
    using (WorkflowRuntime runtime = new WorkflowRuntime())
    {
      Dictionary<string, object> returnValue = null;
      Exception ex = null;

      using (AutoResetEvent waitHandle = new AutoResetEvent(false))
      {
        WorkflowInstance instance = runtime.CreateWorkflow(typeof(T), arguments);
        runtime.WorkflowCompleted += (o, e) =>
        {
          EventHandler<WorkflowCompletedEventArgs> temp = completedEvent;
          if (temp != null)
          {
            temp(o, e);
          }

          returnValue = e.OutputParameters;

          waitHandle.Set();
        };

        runtime.WorkflowTerminated += (o, e) =>
        {
          EventHandler<WorkflowTerminatedEventArgs> temp = terminatedEvent;
          if (temp != null)
          {
            temp(o, e);
          }

          ex = e.Exception;

          waitHandle.Set();
        };

        instance.Start();
        waitHandle.WaitOne();
      }

      if (runtime != null)
      {
        runtime.StopRuntime();
      }

      if (ex != null)
      {
        throw ex;
      }

      return returnValue;
    }
  }
}

Now you really can run the above code to execute your workflow in a synchronous manner without all kinds of messy code. Beware creating multiple WorkflowRuntime instances though. If you are managing multiple simultaneous workflows, you’ll need to pass in instance IDs and keep track in the runtime of which one is completing or throwing errors. It’s generally a bad idea to have multiple WorkflowRuntimes.

Enjoy now being able to write:

var outputArguments = RunWorkflow<WorkflowClass>(arguments, completedEvent, terminatedEvent);
03
Mar

Chase Visa Fraud

I just got a call from the Chase fraud computer voice. He told me that somebody had just charged my card about $250 to a clothing website called ASOS.com. He asked if it was me and I kept pressing zero so I could talk to a person. I knew if I said it wasn’t me that they would just close my card and send me a new one in about a week more or less.

I finally got a person (in India of course), and she told me that not only had they charged that to my card, but also $1.00 to Apple’s iTunes store on February 25th. I didn’t even see that show up in my online activity today on Chase’s web site, so I assume they deactivated the charge when they figured out it was fraud. I assume the Apple charge was to test the card for validity.

I told the lady that a week was unacceptable, because I put everything on that Chase Freedom card. I told her I needed it tomorrow. She obliged without any complaint; she said it will be here tomorrow via UPS and I will have to sign for it. I told her that’s no problem since I work from home.

Kudos to Chase for their aggressive, accurate anti-fraud algorithms and their customer service relating to shipping out a card overnight upon request.

03
Mar

Requirements Completed for Master of Business Administration

Those words in the title now appear at the end of my MBA transcript from Louisiana Tech University. I will graduate Saturday, March 6th, 2010 with a Master of Business Administration and a concentration in Information Assurance. There is nothing else left for me to do; school is over! If I hadn’t gotten the two B’s, I’d have a 4.000 average. Unfortunately, the school doesn’t do any cum laude stuff for graduate degrees.

 -----------------------Winter 2010-------------------------
 MGMT595 084  ADMINISTRATIVE POLICY        A    3.00  12.00
 UNIV610 001  GRADUATION - BUS GRAD             0.00
 -----------------------------------------------------------
 
                     AHRS    EHRS    QHRS    QPTS     GPA
      Current         3.00    3.00    3.00   12.00   4.000
      Cumulative     36.00   36.00   36.00  138.00   3.833
 
      Requirements completed for Master of Business
      Administration
 --End of Louisiana Tech University Graduate Transcript------
12
Feb

redgate Releases SQL Search for Free

redgate has released their SQL Search 1.0 for free, and my coworker Stephen sent our team an email letting us know about it. It is a fantastic product that integrates with SSMS and now it’s free. It keeps an index of all the text in every sproc, all the columns in every table, etc, and you can search them all instantly, limiting by type and many other options.

These are the features they list on their page:

  • Find fragments of SQL text within stored procedures, functions, views and more
  • Quickly navigate to objects wherever they happen to be on your servers
  • Find all references to an object
  • Integrates with SSMS

And their “Why use SQL Search?”:

  • Impact Analysis
    You want to rename one of your table columns but aren’t sure what stored procedures reference it. Using SQL Search, you can search for the column name and find all the stored procedures where it is used.
  • Work faster
    Finding anything in the SSMS object tree requires a lot of clicking. Using SQL Search, you can press the shortcut combo, start typing the name, and jump right there.
  • Make your life easier
    You need to find stored procedures you’ve not yet finished writing. Using SQL Search, you can search for stored procedures containing the text ‘TODO’.
  • Increase efficiency, reduce errors
    You are a DBA, and developers keep using ‘SELECT *’ in their views and stored procedures. You want to find all these and replace them with a correct list of columns to improve performance and prevent future bugs. Using SQL Search, you can look for ‘SELECT *’ in the text of stored procedures and views.

If you are a user of SQL Server Management Studio, I highly recommend you check out out. You sure can’t beat the price. Check out the screenshots below as well.

11
Feb

A Lesson in How Not to Conduct Website Security

Louisiana Tech just sent me a “reminder” email with my full username and password in there. That information is everything necessary to logon to the school student portal and get the rest of my personal information, full school transcript, etc.

Not only do I not like them emailing my password, I don’t like that they even know my password. They should be using hashes instead. They’re doing it incorrectly.

Here is the full email (user/pass redacted):

Subject: Reminder
TO: <[my.school.email]@LaTech.edu>
Date: Thu, 11 Feb 10 12:35:23 CST    
From: <Registrar@LaTech.edu>

REMINDER:

          Your BOSS PIN is: XXXXXX
          Your CWID number is: 100XXXXXX

PROTECT THESE NUMBERS!

I sure wish they’d protect these numbers for me instead of emailing them to me every quarter.




profile for Chris Benard at Stack Overflow, Q&A for professional and enthusiast programmers