My name is Juri Strumpflohner and this is my technical blog. I'm a software architect, .Net, Android, Web and Java dev, TDD and best practices promoter and martial arts practitioner.

Recent Posts Subscribe

Dear reader of Juri's TechBlog,
I moved my blog to a new domain and a new hosting solution as well. I'm now blogging on juristr.com.

Time Machine backups to Windows shared network drive

As some of you may have already read I acquired a MacBook Pro about half a year ago and I love it ;) . Now one of the really cool things OS X provides is Time Machine backups.


It's so great because you simple don't have to do anything. If at all, you can specify the folders which should be excluded from the backup, but the rest is a completely automated process. Time Machine takes care of creating backups that contain the best possible coverage, starting from hourly, weekly to monthly backups, depending on the remaining space on your backup drive.

Now, Apple wouldn't be Apple if they wouldn't have a business model behind this thing.They call it Time Capsule and it is the device which is intented to be the backup drive on the other side of Time Machine. It is more than just a simple external (network capable) HD: it may also function as print server and router.

Anyway, I already bought an external HD about 1 1/2 years ago (I guess). Unfortunately it cannot be attached to the network, but just over USB. So for a while I used to do my backups by manually attaching my HD to the USB port of my MacBook and let Time Machine do its work. However this is cumbersome and you often forget to attach it regularly and moreover, the HD usually stands at some place in your apartment. You're not going to take it around and again, it's nerving to take your notebook there, attach it just for the purpose of doing backups.

So the idea came to my mind of sharing my HD over the network through another computer. I still have my very first notebook, an Acer which is about 6 years old now, I guess. I usually use it as some kind of server, also for sharing my non-network printer to the home wireless. So why shouldn't I also expose my HD?
A post on Superuser pointed me to some interesting pages (this one is another good one). I'm not going to repeat everything since you can get more informations on the linked pages. The main steps are the following:
  1. Activate 'unsupported' network drives for backup
    defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

  2. Create a sparsebundle which will be used by TimeMachine for doing its job. This sparsebundle has to be created locally
    sudo hdiutil create -size 320g -type SPARSEBUNDLE -nospotlight -volname "Backup of <computer_name>" -fs "Case-sensitive Journaled HFS+" -verbose ~/Desktop/<computer_name>_<mac address>.sparsebundle
    

  3. Share the external HD on your Windows server (or notebook as in my case) and make sure you have the necessary user rights for writing/reading.

  4. Mount the network drive and copy the created sparsebundle on it

  5. Configure the network drive for backups by referencing it from within the Time Machine configuration
You have to pay attention that the hostname you indicate in the .sparsebundle name matches exactly your Mac's hostname. Spaces and strange characters may create problems.
Moreover I'd suggest to do the first backup directly over a wired network connection since the 1st backup may take quite a while.

Note, if you use your ethernet card for doing the initial backup which is highly recommended, you have to use the MAC address of your that ethernet card, otherwise Time Machine won't recognize your sparsebundle.

I'm now using this backup mechanism for about three weeks and it works seamlessly. When my Mac is within the home wireless network it automatically connects to the shared backup drive and starts creating his hourly backups. Just great :)

HowTo: Use your iPhone as a remote control for presentations

My latest post is already a while back but I'm currently extremely busy. More posts will come in February. Today, I successfully presented my talk for the final exam of the "Technical Scientific Communication" course. It consisted of an approximately 10 minutes talk about a technical topic (preferably the current research topic). Using this occasion I have to say that iWorks's Keynote is just amazing. I've used MS PowerPoint, OpenOffice etc for a while, but when it comes to create professional looking presentations, none of them can cope with it.

But let's come back to the actual topic of this post. When doing such presentations, it is always quite uncomfortable if you don't have a remote pointer and you have to always use your touchpad or notebook's keyboard. It hinders you somehow in your freedom of movement during the presentation. But if you have an iPhone you actually have you're pointer already with you, without knowing ;) . Yesterday evening, Matthias pointed me to a really nice app for the iPhone provided by Logitech. It's called TouchMouse and consists of an iPhone app, freely available on the App Store and a small server as a back-end for the communication between your iPhone and Mac/PC. Yes, it also works for PCs (Windows).
However, the app isn't just made for the purpose of controlling presentations. What is does is basically to bring your notebook's touchpad to your iPhone.



So, as the figure shows, you have the left/center/right button and a couple of further configurations that let you customize the app. The best of all: it's totally free!

Source:
http://www.logitech.com/index.cfm/494/6367&hub=1&cl=us,en?bit=&osid=9

HowTo: Use globally defined resources in your ASPX code

When creating localized web applications using ASP.net you may often come across strings which are the same on many of your interface parts. Usually you probably use the VS functionality "Generate local resources" which creates you an appropriate resx file containing the keys of your ASP.net Page or UserControl. But take for instance the simple example of a "save button" having the text "Save". Using the "generate resources" approach will lead to a situation where the text "save" appears in many different resx files. This may render it particularly difficult to make changes afterwards, i.e. when your customer suddenly wants to have the text "save content" instead of "save" alone. It would therefore make perfectly sense to have this kind of text defined globally.

This can be done quite easily:

  1. Add the special ASP.net folder "App_GlobalResources" to your ASP.net project
    You can do this by right-clicking on the project and then choosing "Add / Add ASP.NET folder / App_GlobalResources".

  2. Add a new resource file to the created folder
    To achieve this, right-click on the App_GlobalResources folder you just created, then click "New Item" and choose "Resources file". Give it a meaningful name, i.e. "GlobalResources.resx".

  3. Add a new entry for your "save" text
    Add a new entry to the resource file with the key "Button_Save" and the value "Save".

  4. Now open the ASPX code containing the definition of your button(s)
    You can now set the localized text from the resource file as follows:

    <asp:Button id="btnSubmit" runat="server" Text="<%$ Resources:GlobalResources, Button_Save %>"/>

Comments smell! Replace them with more expressive code.

As already pointed out in that post, here's another code example:

...
//300 = Italy
if(aCompany.NationId == 300)
{
   ...
}
...
The comment above the if clause is definitely a code smell. If you wouldn't have that and you come back three months after releasing the software in search for a bug, you probably don't remember what's the meaning of 300, right? Therefore, refactor it by writing more expressive code:
...
if(aCompany.NationId == Nation.TypeOf.Italy)
{
   ...
}
...
The comment is completely useless now. Every developer in the team will now understand the meaning of this code without any effort. Note, such code can lower the mean-time-to-repair (MTTR) significantly.