Visual Studio using old app.config value or setting

Once in a blue moon, I will run into a problem with Visual Studio 2012 where the App.config for a console application is getting cached somewhere and there’s no way to release it. So the App.config is stuck with old values which aren’t correct for the application today. It’s happened maybe twice this year to me.

The App.config in my solution shows the correct values. The one that’s been put in the output directories for Debug and Release both look good, but my quick little console application is pulling ghost values from an App.config from last week. I’ve tried building, rebuilding, and finally, all to no avail.

The only thing I could think of to fix this ( which did work ) was:

  • Copying the contents of the App.config file from within Visual Studio
  • then delete the file from within Visual Studio
  • Then re-add the config file
  • Then paste in the contents.
  • Rebuild and run.

I’m going to chalk this one up to ghosts in the machine.

Continue reading

Amazon Kindle, Expired Credit Card and Gift Card Balance issue

Ran into a weird problem with the Amazon Kindle in our household. They don’t let you purchase a new book when you have an expired credit card in your one-click setup, even if you have a gift card balance on the account. We couldn’t figure it out on the Kindle, so I had to login to Amazon, delete the expired credit card, and then the purchase went through with no problem via the gift card. It’s funny because with so many of these devices today, when you actually have to break out the computer and go to a website, it feels jarring and old-fashioned.

Continue reading

How to get the address of the svn server for my subversion repository?

Recently, I had some code from a Subversion repository on my machine, but no longer had tortoise svn or any svn command lines tool set up. Luckily, I remembered that in Subversion there is a lot of fun data inside the .svn directory. For instance you can see the address of the server and repository by viewing the .svn/entries file at the root of the local subversion files.

Just look for the svn:// or svn+ssh://

That line should show you the svn server address, as well as the repo name and branch.

Continue reading

ASP.NET MVC Model binding in PHP?

I’ve been working a lot this year with ASP.NET MVC 3 and C#. One of the things I really like about these technologies is the model binding. Let’s say I have a data model called “User”, a plain old C# class like this:

I can set that as a model for my view to use in the “Edit” controller like so:

And then I have “User” as the data model in my view. Here’s what’s awesome about it, let’s say I need to accept edits of the user account, maybe they can fix their first or last name. I can pass that same User model from the previous page via a form into an Edit method that accepts that data model. I don’t have to muck about with assigning the Request variables ( POST / GET ) to an object. All that is handled for me.

The ASP.NET MVC model binding will attempt to bind your model in these scenarios:

  • If you have a form element on the page with an identical name to a property in the model
  • If the url contains a key value pair from your routing that is identical to a property in the model
  • If any REQUEST element has a name that is identical to a property in the model
  • Otherwise, that property of the model will remain null

Plus, the ASP.NET MVC model binding will let you turn on/off model binding for various properties of the model.

PHP, or rightly, the many PHP frameworks really need to implement something like this. A few perform some pieces of this concept but I’m not aware of any that currently serve up the whole enchilada. What do you think?

Continue reading

Database stored procedures, functions and triggers are source code of your application. Please treat them as such.

As a consultant for the past two years, when I come into a batch of code that has many stored procedures or triggers in the database, the first thing I ask is whether those stored procedures and triggers are under some kind of revision or source code control. If the developers/DBAs look at me like I’ve got two heads, then I know I’m in for a doozy of a gig because those devs are probably not doing the best job they could be doing.

And that makes sense right? You don’t call in a consultant if everything is unicorns and rainbows with your system.

Stored procedures, functions, and triggers in your database are part of your codebase. They could even be the most important and most delicate piece of your codebase.

I’ll repeat this again for total clarity… Stored procedures, functions, and triggers in your database are part of your codebase.

But not managing your codebase with a tool is a huge mistake. And yet, I see this time and time again on my gigs. And if I had a nickel for every time I saw a stored proc named with “_new” or “_new2” or “_use_this_one” in the name, I could invite Warren Buffet over to play cards and he would consider it.

For managing the source code of your stored procedures on SQL server, there’s even some commercial tools available that take your database objects and chucks them into your source code repo. Or you can always just create a “sql” directory in your source code repository and store the objects there.

There are a lot of ways to manage this problem. Ignoring it, is not managing the problem, it’s making it worse.

Continue reading

Turned off my “home page” today

I turned off my web hosting today that hosted my home page and a few small facebook apps that weren’t making any serious money. It’s kind of the end of an era for me. I’ve hosted my own web page and small apps since probably 1997.

These days it just doesn’t make much sense to host your own anything. The cloud is our new overlord and I for one love the stuffing out of it.

You can have code at github and bitbucket for free (bitbucket does private repos at no cost – yay! ).

You can have your blog on blogger or wordpress. You have your random one-liners and cries for help on twitter.

You have linkedin so that recruiters can spam the daylights out of you with terrible positions in far away countries.

You have roughly a million services for hosting your small apps, like Heroku, PHP Cloud, Google App Engine, and Azure.

I just can’t justify the expense of a basic web hosting or virtual server account any more. I won’t miss doing the system administration on that thing and constantly worrying about hackers. That’s for sure.

I still need a proper home page for my domains to link to all my various cloud identities. Any suggestions?

Continue reading

Fun questions to ask Siri for iphone 4s

In addition to the usual helpful things like sending texts and setting up appointments, Siri also responds to a bunch of silly questions as well. Try these and see what you get:

  • What is the meaning of life?
  • Siri, what is your favorite color?
  • Siri, how old are you?
  • Siri, how do you work?
  • Siri, Knock knock?
Continue reading

Review of Siri voice app for iphone 4s

I’ve been playing with Siri on the new iphone 4s for about 12 hours now and I can honestly say I’m quite impressed with the features. The small help section within Siri gets you going quickly with example commands. When Siri doesn’t understand a command, she prompts you to do a web search for that phrase. Of course saying things like “google barack obama” or “search for barack obama” also command her to do a google search for those terms.

A lot of the examples show how you can text, email, or call using Siri by just referring to a person’s first name.

  • “Text Vinny”
  • “Email Vinny”

If you have multiple Vinnies in your contacts, Siri will show you a list and prompt you to choose one. This makes perfect sense. However, the voice commands don’t appear to work very well for choosing which Vinny. Siri doesn’t seem to understand names very well ( which from a programmers point of view makes perfect sense ). I was hoping that it would work like most phone systems work however, where I could say “one” and Siri would select the first Vinny in the list or “two” for selecting the second Vinny and so on. It doesn’t work like that. So you either have to click the “Vinny” that you want or try to say their whole name in the original request like: “Email Vinny Boombotz.” And you have to really pronounce names phonetically ( not necessarily how they’re pronounced ) to get the right name to show up.

The same issue comes up with email addresses. When you command:

“Email Vinny Boombotz”

If Vinny Boombotz has multiple email addresses, Siri will show you a list of Vinny’s email addresses and prompt you to choose one.

I’ve found that text commands work better than email commands and that’s usually because most of my contacts only have one mobile phone number and therefore one texting address. Saying “Text Vinny Boombotz” will have Siri prompt you for the body of the message. Saying “Text Vinny Boombotz I’ll be right over” will have Siri put “I’ll be right over” in the body of the message. Pretty handy.

Creating meetings and reminders works very well. When you say “Remind me to call Vinny Boombotz at 8:30pm” Siri will set up a reminder for 8:30pm with Vinny’s number attached. So the reminder winds up with a “call” button on it for easy dialing.

Commands like “what’s the weather today” and “show me today’s meetings” are pretty handy as well.

Commands like “Find me an italian restaurant” have Siri locate italian restaurants local to you. Clicking on one shows a map and then clicking on the map label will show you the phone number and address of the restaurant.

There’s a whole slew of mapping functions that I haven’t even tried yet.

The Wolfram Alpha piece of Siri is kind of like the ultimate bar bet tool. You can ask questions like:

  • “Who won best actor in 1982?”
  • “Who won the SuperBowl in 1986?”
  • “What’s the population of China?”
  • “How many calories in an Egg McMuffin?”

And the Wolfram Alpha piece kicks in and gives you a handful of information on your topic. Again, if its not in Wolfram Alpha, then it falls back to a web search. But I found this much quicker then typing in a search. I’m probably going to use this piece of it quite a lot.

There’s also a bunch of fun questions you can ask Siri that I mentioned here.

There’s big things missing from Siri right now that I hope get improved. There’s really no concept of “latest news” or “latest baseball scores.” Siri will prompt you to do web search for these terms. Ideally, they should open up the API to/from Siri so that if you ask for “latest baseball scores” it can query ESPN or another sports outlet for that request. It would be really killer if when you created iphone apps that you could register some Siri answers in your app so certain questions would go to your app instead of just a default web search from Siri.

So in the baseball case, the ESPN app could register answers with Siri to questions like “Latest baseball scores” or “Next Texas Rangers game.” So if Siri couldn’t find the answers to those questions, it could question the ESPN app on your phone for those questions, before doing a default web search.

In conclusion, I think Siri is a nice addition to the iphone. It’s not quite a killer app but its definitely useful and something I’ll probably be using a few times a week.

Continue reading

How to find all the distinct PHP session variables that your applications uses.

The short answer is a one line Linux shell command:

This command:

  • looks through all the files in your application recursively for the PHP $_SESSION reference
  • finds any variables named with capital letters, or lowercase letters, or underscores, or numbers
  • sorts the list alphabetically
  • removes the duplicate items in the list

The long answer is that I found myself with an interesting dilemma recently. How to find all the PHP session variables set in my application. Some pieces of the application were new code, some were older legacy code. I needed to get the full list of session variables because I needed to delete most, but not all of them for a certain usage case ( ie, the user is still logged in and has some properties, but the other session data could be safely destroyed ).

So I began with some command line greps on linux. First I tried:

This was a decent list, but about 1000 rows long. Too unwieldy to deal with. Let’s get rid of the filenames, I don’t really care where the session values are set for my case.

This is a little better, but I don’t need the whole line, just the session variable itself. Let’s see if we can start to grab the session var using a regex pattern.

Now we are cooking. This is a nice list of the session variables ( albeit only one array level deep which is all I needed ). Now how to remove the duplicates? Maybe we should “sort” them first?

That is really close. Is there a way to remove duplicates with the “sort” command? Yes, there is. Hot dog.

There it is. That’s the final command I used which located around 50 variables in the old legacy code and new modular code that were used in the sessions. The only really drawback to this code is it will not find multiple nested array values on the session itself, but you could add that as a separate regex if you need.

Continue reading

Yahoo email account hacked

My wife started sending me emails about male enhancements around 3am Saturday morning. I first took slight offense to this but quickly realized they were addressed to everyone in her address book. Her Yahoo email account had been hacked.

We updated her account password, alerted Yahoo security via a basic form on the Yahoo site, and added a “sign-in seal” to the account.

But really, this should not have happened in the first place. There’s a page in the Yahoo accounts menus that shows you the last 20 or so places you’ve logged in from. There’s a bunch from our hometown and then a couple in France. She’s never logged into Yahoo from France. Ever. Shouldn’t Yahoo be throwing a red flag on that and displaying some of the maiden name, first pet name questions?

The other disappointing piece of this is that there’s no “sign me out of everywhere” button, you can only opt to be signed out every day.

This is really terrible security. I haven’t forced her to switch to Gmail yet but I probably will strongly urge her to do so in the coming weeks.

  • Gmail has two factor authentication which practically eliminates this.
  • Gmail has a button to sign you out everywhere
  • I *think* Gmail has something if you’re logging in from a different country ( but I’m not positive on that )
Continue reading