Archive for the ‘Powershell’ Category
Listen to your product
When you need to make a decision, but you don’t have enough information, you have two options. Seth Godin suggests flipping a coin, and I agree that sometimes this is the best way to go. When you are short on time, or there is simply no cost effective way to get the information you need, coin flipping will at least move you forward. The second option is to get more information. One of the great things about software is that you can often get more information with the simple investment of time. Of course, when you can’t afford the necessary time, your back to coin flipping.
As I mentioned last time, I have shifted from Nozbe.Net to what I am calling WinNozbe (at least for now). The idea is a Windows application that can either operate on it’s own, or sync with Nozbe. I want it to operate either offline or online as needed. But all this is work to be done; it is still early days.
The reason for the switch was that I did not feel that I had enough information to finish the part of Nozbe.Net that updates Nozbe itself. Until I wrote a program that actually wanted to do that, it wasn’t clear how it should work. So read-only Nozbe.Net was published, and I turned to developing the program I wanted to begin with so I could let the program give me the answers.
Did I learn how I wanted to update Nozbe? No, I learned that I needed to modify how I provided the information from Nozbe! Nozbe.Net was originally tested by writing Powershell scripts that sliced and diced the projects and actions, so Nozbe.Net returns arrays of hash tables, the sort of thing Powershell handles with ease (and not incidentally a simple translation of the data as provided by Nozbe). But, WinNozbe is a more complicated system and hash tables are not exactly what is wants. So work has shifted into the gray area between the two. The end result will likely be an update to Nozbe.Net before WinNozbe is ready for publication.
I have heard artists say that a statue is not something they make out of stone, but something they find in the stone. The structure of the stone constrains what is possible, and the combination of the stone and the sculptor creates the statue. Working in software is far from working with stone, but that same interaction occurs. If you can take the time to listen to what you are making, it will tell you what you should do, and the result will be amazing.
Nozbe.Net
So far this has all been a long introduction to what I am about to announce. I wanted to explain where I had come from and where I was trying to go. Having selected Nozbe as my trusted system, I settled in and decided to stay, but I wanted features that I did not expect Nozbe to produce any time soon. So, I decided to create those features myself.
With the api documentation in hand, I started to write a program that would speak to Nozbe’s system in its language. As I started to make the various parts work I realized that what I needed was a class library that the real program could call. All the Nozbe related details would be in this class library, and the program would just handle doing what it needed to do without worrying about the details. With that in mind I created Nozbe.Net.
Nozbe.Net is a class library callable from any Microsoft .Net based language. It is designed as a thin wrapper around the Nozbe web service api, translating those calls into .Net methods, and the data into .Net collections. In addition, I have begun adding functions to do things like save the data into a local backup.
At this time, Nozbe.Net is read-only, meaning that I have not finished the design of how updates can be made. That is the next step, but as I started to write that code, I realized that I needed to shift back to writing the program I had started. The original project was to write a Windows program that would give me the features I wished Nozbe had. I need to finish writing that program so that I can decide how best to support synchronizing updates with Nozbe. Once I have that done, I will post an updated version of Nozbe.Net.
In the meantime, there is a lot that can be done with the library as is, especially if you are comfortable with Powershell. Here are some examples to get us started.
Step one is to access Nozbe.Net:
add-type -path “.\Nozbe.Net.dll”
Step two is to login to Nozbe. We have two options:
$session = new-object Nozbe.Net.Session “myappkey”, “myuserkey”
or,
$session = new-object Nozbe.Net.Session “myappkey”
$session.Login(“email”, “password”)
Notice that you will need an app key. This is something that you have to ask Nozbe for. See the Nozbe api page for details.
Step 3, get all the Nozbe data (except completed projects and tasks)
$data = $session.GetData()
or to get everything including completed items:
$data = $session.GetData(“”, $true)
The “” means all types of information (for example, you could say “project” to just get projects). The $true means completed items should be included.
Create a local backup
$session.BackupToDisk($data)
Find Projects without a Tag
$data.project | where-object {$_.tag -eq “”}
Find Projects with no Actions
$data.project | foreach-object {$project = $_; $tasks = ($data.task | where-object {$_.project_hash -eq $project.hash}); if ($tasks.count -eq 0) {$project}}
List Project names with number of tasks
$data.project | % {$project = $_; $tasks = ($data.task | where-object {$_.project_hash -eq $p.hash}); “” | select @{Name=”Project”; Expression={$project.name}},@{Name=”Tasks”; Expression={$tasks.Count}}}
Now I know that if computer programming is not your thing, this is a foreign language to you and not apparently helpful. The good news is that when I have the full program finished, I will be releasing that as well and you will not need an app key, and you will not have to learn to program. For all those of you that understand Powershell, or C# or VB.Net, please try Nozbe.Net and let me know what you think. I have published it as open source in order to encourage others to contribute.
Let me know what you think.