Sunday, October 26, 2014

Couchbase Server + Retrieve records since a given date/time

For one of my current projects I need to be able to query for documents since a "last retrieved" date/time. To do this I created a simple view using the convenient function "dateToArray". I included Id in the key to ensure that I get a result per unique document.

The view:

function (doc, meta) {
  if(doc.Type == "Account") {
    emit([dateToArray(doc.LastModifiedDate), doc.Id], doc.Id);  

To get the proper results I first needed to sort descending, then choose a valid start key. This will give me all of the documents since 10/16/2014. Enjoy!


Tuesday, October 7, 2014

I am cross platform...

I run Windows 8 in a Parallels VM on Mac OS X Mavericks. I develop software using Visual Studio in Windows 8, Xamarin Studio on Mac OS X, XCode on Mac OS X, and I heavily rely on Sublime Text for cross platform development.

Did I mention I develop with NodeJS on Ubuntu Linux and I administrate Couchbase Server running on Ubuntu Linux in a cluster on the Azure Cloud?

I am cross platform.

Wednesday, October 1, 2014

Xamarin is cool, but it isn't ready yet...

I have spent the last three days learning Xamarin. I have had some huge successes such as setting up navigation, storing data via Couchbase Lite, and sharing code among platforms. The biggest disappointment so far surrounds authentication. I followed an example ( but I have been unable to get Google auth or Facebook auth working with it for iOS (both work for Android). The feedback in the forums is lackluster at best. Lots of good questions, but very few decent answers. It looks like most of the time questions are left laying around rather than being responded to.

Auth is a basic function these days, and good community feedback is vital for learning these tools, if you cannot provide both of these you are simply not ready to be used on a large scale.

I will try again in six months.

Friday, August 15, 2014

Use a custom domain name with an Azure Website

Thursday, July 3, 2014

"Undo" in a document database...

Doing an "undo" when modifications have been made to a monolithic structure can be a tricky beast, however, doing so in a document database is literally just a couple lines of code.

1. Anytime modifications are made to the current state you save the previous version with a simple new key.
2. When the user requests to go back in time you load that document, then save it again with the key that points to the document with the current state.
3. Done

Cheap, easy, no gold plates.

Wednesday, June 25, 2014

Be simple and choose wisely...


I have spent the majority of my career working for a single company. I have also done a large amount of side work, both large and small, coding, etc. You will find, as you follow my blog, that I am not scared of jumping to new technology and I have as much experience as anyone in my region at doing what it is that I do. I say this, because I feel that the next few paragraphs are quite important for anyone going into my field.

Be simple and choose wisely...

For the first several years of my career I put a heavy emphasis on following only the few key technologies that paid the bills. I followed them as far as possible. I would jump quickly to their new tech without regard for much of anything aside from my own personal satisfaction. I had to do this,  I needed it, because my passion is technology and NOT business. I like to learn and I like to tinker with the latest and greatest as soon as it hits the street. This is great to do on the side, but not really good when it affects an entire team of people or an entire business process. Being simple and choosing wisely was not what I was doing at all. I was choosing technology for my own interests and not that of the company or others on my team. I could argue otherwise and I won several small debates on this subject but in reality it was smoke and mirrors and I was wrong.

I have spent the last few years trying to undo that old style of thinking in an effort to keep things simple and to make sure that my decisions minimally impact people I work with and customers who use my products. In some ways, I have made great strides. I choose completely portable, free tooling over proprietary tooling because I believe the open source movement will pave the way going into the future. I believe it will result in better tooling, easier to share code, and an easier career path for techies like myself. I also have started building my projects based on standards rather than anything specific to one proprietary entity or any one "grand idea". I have also taken a few steps backwards. I have supported or allowed things to happen that were against my better judgment. I have drifted away from simple technologies like SQL in favor of some that have not had time to stretch their legs yet or simply are not proven. I have paid the price for these decision and so have others on my team.

I am quite confident that if you adhere to the following key points you will make good and bad decisions, just as I have. You will, however, make far fewer bad ones. :)

How to be simple and choose wisely...

  • the initial requirements are ALWAYS wrong and they will change and twist over time 
  • release your project in extremely small chunks and gain acceptance from all involved before moving on...I said ALL involved
  • the smallest amount of code complexity will become a mess or a hurdle at some point
  • other people have already conquered technical hurdles that you may run into, find their solutions
  • DO NOT use "cutting edge" technologies or architectural ideas, unless you happen to be lead architect at Google, then you probably know better than me :)
  • do not be afraid to stick with a certain amount of legacy code or to choose a simple idea over some grand scheme you think will solve all your problems
  • follow the industry as a whole, not a single company, and not a single technology suite
  • do not move fast, even if business pressures you to do so, you will pay for it in pain that is worse than losing your job
  • if technology is your passion find a way to do it as a hobby or in an academic setting
  • if business is your passion and you are also good at tech, may God be with you

Monday, June 9, 2014

Restoring a database using Transact SQL

This is mainly here for my own benefit so that in a few months when I need this again (and I have forgotten it) I will be able to find it easily. :)

-- List the files in the backup
RESTORE FILELISTONLY -- FILELISTONLY contains a list of the data and log files
FROM DISK = N'C:\.bak'

-- Restore the database
FROM DISK = 'C:\.bak'
MOVE N'' TO N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\.mdf',
MOVE N'' TO N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\.ldf'