Tuesday, June 3, 2008

Why my diverse background makes me a better programmer

I have had a fair amount of very different jobs so far in my life. I have been a Chef, a Sonar Technician in the US Navy, a Medic in the US Army Reserves, an Accounts Payable and Purchasing clerk, and a Financial Systems Analyst. They all made sense at the time, and have all been fulfilling in their own way, but in every case I knew shortly after starting that these were not jobs that I would be happy doing for the rest of my career. Once mastered they would become repetitive and ultimately boring. I was extremely happy when I started down my most recent career path, I had finally found something that I could see myself doing forever, something that would never get boring; Programming.

Something that I find interesting is that in each change I was able to leverage skills learned in the previous jobs, even when completely un-related. I often tend to think “outside the box” and challenge notions that are commonly accepted as fact. Looking at a problem from multiple points of view has given me the ability to find creative solutions that someone with different experiences may not think of.

How to Import a CSV file into MySQL from Linux

Below is a step by step set of instructions on how to import a csv file into MySQL from the Linux command line. If it works correctly you will see the first 10 records displayed on screen. If your csv file has invalid characters you will get warning messages with the line number.

Create a .sql file with the following code:

truncate table table_name;

load data local infile 'csv_file.csv' into table table_name

fields terminated by ','

lines terminated by '\r\n'

ignore 1 lines

(field1, field2, etc.)

;

select * from table_name limit 10;

Then create a .sh file with the following code:

mysql -u your_username --password=your_password --show-warnings -D your_database_name <>

Run the .sh file and your csv file will be loaded into your table.

Monday, June 2, 2008

BrainTree API and ActiveMerchant

Recently I was working on a project that needed an e-commerce solution for monthly subscription renewals. We also wanted to be able to securely store the user’s credit card information to use for recurring billing. At first evaluation it seemed like we where going to need 2 separate solutions here. An e-commerce gateway and 2 way encryption for secure credit card information storage. This seemed like an awful lot of work and we couldn’t be the only ones that need this, it felt like we were trying to reinvent the wheel. After some research into other options we found the solution we where looking for.

The service we found is from BrainTree Payment Solutions. They have an API that will securely store the credit card information and return a unique token. Storing this token has far less risk involved. If someone were to gain access to this token in your database, it would be useless to them.

But that is only a fraction of what this API can do. It is also an e-commerce gateway that supports all the major credit card types as well as Echeck, ACH (automatic clearing house) and EFT (electronic funds transfer) which are all forms of Direct Deposit. It also supports some of the online payment options such as PayPal, Bill Me Later and Google Checkout.

All of that functionality is pretty awesome right? Well if you are a Ruby user it gets even better. You can access all of this functionality through a familiar e-commerce library; Active Merchant. All of the functionality with the ease of Active Merchant, what more could you ask for?