Bob Parson's 16 Rules For Success
Professionally, I work as a Software Engineer at GoDaddy.com. The crazy Super Bowl ads and fun company culture are what attracted me to work there. The owner of GoDaddy.com, Bob Parsons, has a list of "16 rules for success in business or life in general" which I thought were worth sharing.1. Get and stay out of your comfort zone.
2. Never give up.
3. When you are ready to quit, you're closer than you think.
4. Accept the worst possible outcome.
5. Focus on what you want to have happen.
6. Take things a day at a time.
7. Always be moving forward.
8. Be quick to decide.
9. Measure everything of significance.
10. Anything that is not managed will deteriorate.
11. Pay attention to your competitors, but pay more attention to what you're doing.
12. Never let anybody push you around.
13. Never expect life to be fair.
14. Solve your own problems.
15. Don't take yourself too seriously.
16. There's always a reason to smile.
Bob's motto is "We're not here for a long time, we're here for a good time". He has a video blog which has a lot of great material worth checking out. He also reads every comment and responds to a lot of them.
http://www.bobparsons.tv/
Labels: Personal
posted by Brian at 8/11/2008 09:13:00 PM | 0 Comments
Shell Execute with output
Using the System.Diagnostics.Process class you can get a stream to read the output of the application you are executing. For example, you could execute "dir" to list get the directory contents of the working directory specified as a string.
Here's a basic class I wrote that allows you to get the standard output:using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
namespace Kahnadex{
class WindowsHelper{
public static Exception ShellExecute(string in_WorkingDirectory,string in_FileName,string in_Args,out string out_StdOut){
Process p = new System.Diagnostics.Process();
p.StartInfo.WorkingDirectory = in_WorkingDirectory;
p.StartInfo.FileName = in_FileName;
p.StartInfo.Verb = "open";
p.StartInfo.Arguments = in_Args;
//required to capture standard output
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();
//read the command line output
try{
StreamReader sr = p.StandardOutput;
out_StdOut = sr.ReadToEnd();
return(null);
}catch(Exception ex){
out_StdOut = "";
return(ex);
}
}
}
}
posted by Brian at 7/31/2008 01:03:00 AM | 0 Comments
ToString for C++ base types
#include <sstream>
template <class T>
inline std::string ToString (const T& t){
std::stringstream ss;
ss << t;
return(ss.str());
}
Labels: C++
posted by Brian at 7/31/2008 12:36:00 AM | 0 Comments
Creating or moving a MySQL database
Unlike SQL Server, you cannot reliably move a MySQL database by moving the binary files in the MySQL directory. Instead, you should use the mysqldump utility.
Open a command line window to the MySQL bin directory and make sure both mysql and mysqldump binaries are both present. On Linux this location is likely /usr/local/mysql/bin and on Windows this is most likely C:\Program Files\MySQL\MySQL Server 5.0\
Dump the database using a command like this:./mysqldump --user=user --password=pw database_name_here > db.sql
Then connect using the MySQL command line client and create the database:./mysql --user=user --password=pw
create database new_database_name
use new_database_name
source db.sql
posted by Brian at 7/16/2008 02:36:00 PM | 0 Comments
Logging in automatically in Windows
On every media center PC I've used, most of the usage didn't involve a keyboard. With Windows Media Center Edition 2005 I mostly used the MCE remote control and with my new Windows Vista machine I use a touch screen.
One obstacle for getting the perfect setup on your media center is the logging in process. On Windows XP or Vista you'll have to click a Windows XP user icon (or enter a username) and enter the password (if applicable) to log in. I want to have a password to protect shared content but I don't want to have to actually log in or click the frog Windows XP user icon next to the name "Brian". I want my user account to automatically log in and have it run a startup script, open up commonly used programs, etc. There is a fix available for Windows XP / Windows Vista.
Use the Start Menu -> Run to pull up the run box (or on Vista, just pull up the start menu and click on the "start search") and type in "control userpasswords2". Hit enter and you will be presented with a "User Accounts" dialog. Simply uncheck the "Users must enter a user name and password to use this computer" box. When you click "Apply" or "OK", the dialog will prompt you with the credentials you want to use to automatically log in. Enter the user you would like to be automatically logged in and you're ready to go.
Labels: Windows, Windows Vista, Windows XP
posted by Brian at 5/28/2008 08:40:00 PM | 0 Comments
SCOPE_IDENTITY
In SQL Server, there are three ways to get the identity of the row you had just inserted: IDENT_CURRENT(), @@IDENTITY, and SCOPE_IDENTITY().
IDENT_CURRENT() is not limited by scope and session; it is limited to a table. For example, you can use IDENT_CURRENT('TableName') to get the last identity generated for table 'TableName'.
SCOPE_IDENTITY() and @@IDENTITY will return last identity values generated in any table in the current session. However, only SCOPE_IDENTITY() returns values inserted within your current scope (the scope of the SQL you just executed). @@IDENTITY is dangerous to use in my opinion because even though it is limited to session, it doesn't take into account identities that could have been made by triggers. SCOPE_IDENTITY() is always safe to use after making your insert to get exactly the identity you need.
For more information, check out the official MSDN documentation:
http://msdn.microsoft.com/en-us/library/aa259185(SQL.80).aspx
Labels: SQL, SQL Server
posted by Brian at 5/28/2008 09:07:00 AM | 0 Comments
Randomizing your selection in SQL Server
Sometimes you might want to randomize your dataset. In the SQL driven MP3 player I worked on, I wrote a stored procedure to handle putting together a playlist for the user (since all the song data is already in the database). There are probably a lot of other good uses for random selections and the code sample below works great.
In your select clause you can add an ORDER BY statement and use NEWID().SELECT * FROM
TableName
ORDER BY NEWID()
Labels: SQL, SQL Server
posted by Brian at 5/28/2008 12:33:00 AM | 0 Comments
Date formatting using MySQL
By default MySQL stores its dates in 'YYYY-MM-DD HH:MM:SS' format. When you have to integrate with .NET, it's nice to get the date in a format which is readable by DateTime.Parse().
In your SQL query, you can format the date by using the date_format function.SELECT date_format(YourDateHere, '%a %D %b %Y') FROM TableName;
Here are some example formatting strings and examples of their output (replace the formatting in the red part of the query above).
| Example | Format String |
| 1/28/2008 | '%c/%e/%Y' |
| 01/28/2008 | '%m/%d/%Y' |
| 1/28/2008 12:30 | '%c/%e/%Y %H:%i' |
| 01/28/2008 12:30 | '%m/%d/%Y %H:%i' |
| 1/28/2008 12:30:59 | '%c/%e/%Y %T' |
| 01/28/2008 12:30:59 | '%m/%d/%Y %T' |
posted by Brian at 5/22/2008 04:19:00 PM | 0 Comments
C++ String Stream
After using C++ for many years, I found myself still using the printf family of C functions for formatting. When I started my new job this last March, I noticed the other folks are big on using string streams. I've been trying to ween myself off sprintf and wanted to share some very simple examples.#include <iostream>
#include <sstream>
using namespace std;
int main(int argc,char** argv){
ostringstream buffer;
buffer << "Testing " << 1 << 2 << 3 << endl;
cout << buffer.str();
return(0);
}
This code will output:Testing 123
That code isn't too bad. If that's all there was too it, I wouldn't mind using the string streams. However, advanced formatting is not so easy. But of course you can always use defines to help.
Let's say that we want a program to display today's date in MM/DD/YYYY format. Using C, this is extremely trivial.int main(int argc,char** argv){
time_t time1 = time(0);
struct tm* time2 = localtime(&time1);
printf("Today's date is: %02d/%02d/%04d\n",time2->tm_mon,time2->tm_mday,(1900+time2->tm_year));
return(0);
}
However, I don't think the code very elegant using string streams.#include <iostream>
#include <sstream>
#include <time.h>
#include <iomanip>
using namespace std;
#define FormatInt(number,spaces) setw(spaces) << setfill('0') << int(number)
int main(int argc,char** argv){
time_t time1 = time(0);
struct tm* time2 = localtime(&time1);
ostringstream buffer;
buffer << "Today's date is: " << FormatInt(time2->tm_mon,2) << "/" << FormatInt(time2->tm_mday,2) << "/" << FormatInt(1900+time2->tm_year,4) << endl;
cout << buffer.str();
return(0);
}
If there is a better way to do this I'd love to hear about it. For now, I'll use string streams at work and continue using sprintf in code at home.
Labels: C++
posted by Brian at 5/12/2008 07:45:00 PM | 0 Comments
Bugzilla Install Guide for Windows
In December I installed Bugzilla on my file server to help track bugs and enhancements for all of my personal projects. Bugzilla is a pleasure to use, especially after years of using Mercury Quality Center at work. In my opinion it doesn't have any bloat and is easy to modify to your needs. The developers did a great job.
http://www.bugzilla.org/
Installing the program was not easy. But after an hour or so of beating my head on the desk I found an excellent Windows install guide by Byron Jones. The install guide gives an overview of locating and configuring Bugzilla, Perl, Apache, and MySQL.
http://www.bugzilla.org/docs/win32install.html
Labels: Bug Tracking
posted by Brian at 5/12/2008 07:29:00 PM | 0 Comments