Tuesday, August 13, 2013

Why Single Sign On is good

I've written countless login mechanisms. To be honest I'm sick of them. But there's a better reason to go with SSO only in my next app. User friendliness.

SSO is user friendly

SSO mechanisms are quite slick. Instead of sending users through yet another boring signup form, sending out verification emails and forcing eye cancer upon them with an unreadable captcha, they just click a button, authorise an app and off they go.

The key lays in their existing accounts with major services like Google, Facebook or Twitter. Those services are doing a fantastic job in verifying signups. So people went through all that already. Their profiles are verified and trustworthy.

Clicking a button to make a service accessible is therefore a huge improvement for many users. Besides, have you ever filled out a lengthy signup form on a mobile phone? SSO buttons eliminate any need for that at all, resulting in more signups.

SSO makes development easier

SSO is confusing at first. There are many things involved in the process. I've once written the process in PHP as a Typo3 plugin. It was hell back then and I never really understood what happened there.

I'm still not much better off when it comes to the understanding of all the things involved in the process. However, times have changed and it's much easier to do.

I've looked into passport.js, a node.js library. It supports many different SSO mechanisms, partially through additional node modules. Whats even more interesting however is it's integration into the express framework.

That integration is so huge to me that I abandoned my first CouchApp only prototype in favour of node.js with express.

Again, getting started is not exactly easy. Luckily I found this video which walked me through a basic Facebook setup. If you're looking to get started with passport.js, I suggest you check it out.

Friday, August 9, 2013

Fixing Coda 2 Connection issues

I often rely on a satellite internet connection. Those connections make life with Coda difficult. Often files aren't transferred over SFTP. The timeout is epic and it makes life really difficult.

To get around this problem I gave up on Coda's embedded SFTP client. Instead I've mounted the remote server through SSHFS. So far I didn't run into the same problems and files are transferred reliably.

SSHFS can be installed on pretty much any UNIX OS. I personally use it within a Linux VM since the local project files are in there as well. However there's no need for that. You can install SSHFS on your Mac as well.

Binary versions are available from the osxfuse project. To be honest I didn't try them but that may be the way to go if you don't want to install a portage on your Mac.

I on the other hand couldn't live without MacPorts. If you have it installed, just install the

sshfs
port. Once installed you can easily mount your remote website using a command like this:

sshfs username@remote.tld:/var/www/ /Users/arthur/mymountpoint/

To optimise the process I suggest you're using SSH keys instead of passwords. That way it's not only more secure but also much more comfortable. Hint: those keys work with Coda as well.

Thursday, August 8, 2013

Limit Apple Mail to 80 Chars

Using Apple Mail I occasionally receive complaints, mainly from Linux users, that I should limit the length of a line to 80 characters. The only problem, Apple Mail doesn't support this!

It's no problem doing this in pretty much any other email client. So switching from Apple Mail to something like Thunderbird or Opera Mail may be an option. But I actually like Apple Mail so, that's not really an idea I'd like to go with.

Luckily I found this thread on the Apple Support forum that explains how to use Automator to partially get around this problem.

The answer by "Scott Atchley" really works quite well. What he does there is simply to create a new Service in Automator. It takes selected text from the Mail application, sends it through the "fmt" command and replaces the original.

I've created the workflow and put it on my Google Drive for you to download.

Or if you'd like to create it yourself, here's a screenshot of how this simple service looks on my Mac:

Once created and put into the

~/Library/Services/
directory it shows up in your keyboard shortcut menu. Create a shortcut of your liking.

Once the shortcut is set, restart Apple Mail and try it out. Select the text you'd like to transform and hit your shortcut.

Even so this solution works it's but a dirty hack. Apple should really add that feature to Apple Mail. I really hope that they get over this "consumer" idiocy and once again respect their pro users, many of which are veterans using macs since the early 90s or even earlier.

Monday, August 5, 2013

Getting rid of VirtualBox Windows

I often use VirtualBox VMs to run a development environment within. These are usually some very basic command line operated *NIX systems. Since I interact with them through SSH via a host only network connection I don't really need the Window that pops up when starting a VM. It's actually quite annoying.

Luckily there's a simple solution. Instead of starting a VM using the graphical VirtualBox Manager, you can start it using the following command

VBoxManage startvm "VM name" --type headless

In headless mode the useless "dead" windows aren't created any more which really is quite a blessing. To stop a VM either shut it down through SSH or use the following command

VBoxManage stopvm "VM name"

To see a list of your VMs run the following command.

VBoxManage list vms

Monday, July 29, 2013

Tools for changing the World

As an ongoing entrepreneur my ambitions to change the world are part of the new job description. One thing I notice when I talk to tech people is their obsession with details.

Knowing some of your infrastructure in depth sure is important. Even as a non technical person running a tech start-up you clearly want to know about why things are as they are. If people use expensive Windows servers for no obvious reason learn why and consider using something else for example.

I've grown up with Linux. I know my way around UNIX systems and for a long time I wanted to know all there is. Truth is however thats an impossible goal. I'd spend all my life learning more and more details which don't get me anywhere.

I realised how important it is to have the right tools and the right set of know how to avoid getting tied up in non productive work.

For instance, unless you're running a mail server company, spending time to configure a mail server is a waste of time and money. The hours fiddling around with those settings could have been spent on productive work in the field you're trying to sell something.

Same thing about Desktops. I know a lot of die hard Linux guys who use their Linux desktops. Sometimes that's OK, but the truth is that in many cases a Mac with all its fancy software is more productive than a Linux Desktop. People spend way to much time tinkering around with their system and produce results with tools that are way to complicated.

I'm not saying that I don't use Linux desktops or that they're bad. My point is that you should chose your tools wisely. Find out what works for you, not against you. Avoid things that require a lot of time without really adding any value for that.

Most importantly, get rid of anything that distracts you from your actual work. If your phone makes a lot of trouble consider getting another one that gets the job done without your constant supervision.

Choose tools not only by their price but look at how comfortable they are. Spending a bit of money on a stress free user interface instead of going with a free program thats a mess can save you endless hours of unproductive work.

Tuesday, July 23, 2013

Fixing Power Manager on Linux Mint 15 MATE

Due to some issues with my previous Mint 15 installation using the Cinnamon desktop I decided to do a fresh installation of Linux Mint 15 MATE. That way I could make use of the new LUKS manager in the Mint installation and get rid of the eCryptFS home directory encryption which too caused issues.

The MATE edition is really nice and is pretty much unchanged to a much earlier version of Mint I fell in love with. The fantastic "start menu" is still in there, all the GNOME goodness still works as I'm used to and it feels like a Desktop written for a computer instead of trying to serve multiple purposes.

One problem however is the power manageent. I don't like it when the screen dims down just because I pull the power cable. The standard Mint Power manager doesn't offer any options regarding that issue and I really didn't fancy going down to the command line level on this one.

Instead I've installed the XFCE4 power manager which integrates seamlessly. More importantly however it allows for much more detailed settings on how the notebook should behave in different modes.

To install it on your Mint Linux box use the following command:

sudo apt-get install -y xfce4-power-manager

Afterward find it or call it from the console using the same name as above in the installation command.

Sunday, July 14, 2013

Discovering JavaScript Closures

One of the biggest issues I have with JavaScript are callback functions which cannot access data from their parents scope. I tried OOP to get around this problem, yet the lack of a reliable $this variable voids those efforts pretty much.

Right now I'm working on a piece of middleware which should download a file from a CouchDB server, send it to a service providers API and obviously update the source document with the result.

Sounds easy, but if the callbacks don't know about the CouchDB document any longer this simple task quickly becomes a nightmare.

And so it happened that I've discovered this article about JS closures. Not entirely sure how it works under the hood but it sure solved my problem. The final code looks a bit like this:

function change_processor(change, param) {

  return {

    download: function() {

      for (var filename in change.doc._attachments) {                                               
        http.get({
          url: param.dbhost,
          port: param.dbport,
          path: '/' + param.dbname + '/' + change.doc._id + '/' + filename
        }, function(res) {
          var data = [];
          var dataLen = 0;
          res.on('data', function(chunk) {
            data.push(chunk);
            dataLen += chunk.length;
          }).on('end', function() {
            var buf = new Buffer(dataLen);
            for (var i=0, len = data.length, pos = 0; i < len; i++) {
              data[i].copy(buf, pos);
              pos += data[i].length;
            }
            console.log(buf.toString('ascii'));
          });
        });
      }
    }
  }
}

module.exports = change_processor;

The cool thing about this closure is that variables like `change` are available throughout the entire construct, including the callbacks of http.get. It's incredible.