Thursday 27 February 2014

Editing a codebase on a remote server from Chrome OS


Here's a quick post about how your Chrome OS device, in developer mode, can edit a codebase on a remote (e.g. university, personal) server as if the code were local. And you don't need to install Crouton or any Linux partition-esque things to do so. This allows instant saving back to the server, where you might be running scripts or need access to large data files you can't host locally.


Step 1: Install Caret

https://chrome.google.com/webstore/detail/caret/fljalecfjciodhpcledpamjachpmelml?hl=en
Caret is an excellent code editor in the style of Sublime Text.


















Step 2: Install Chrome OS dev tools

  • You need to be in developer mode on your Chrome OS device, but the channel is irrelevant (stable/beta/dev)
  • Open a terminal with Ctrl-Alt-T
  • Type sudo -i
  • Type dev_install

Step 3: Mount the remote server

  • Exit from the superuser session by Ctrl-D
  • Type cd ~/Downloads
  • Type mkdir remote_folder, where remote_folder is whatever you want to call it
  • Type sshfs username@remote.server:/path/to/folder remote_folder, where you can fill in the information for your username, remote server domain, and the default folder you want to start in

Step 4: Use Caret to edit code in the style of Sublime Text and other code editors

  • Project --> Add directory
  • Browse to Downloads/remote_folder/ then find the top level folder containing code you want to edit.
  • Edit! And Saving will instantly save back to the server. So perhaps you want a SSH window open simultaneously, running scripts on the server.
Hope this is useful.


Tuesday 29 October 2013

How much science can you do on a tablet?

Apple have announced both their iPad Air and Mini Retina this month, and we fully expect Google to follow with a refresh to the Nexus 10. Due to excellent battery life, portability, and mature application stores, I've tried working on both iOS and Android tablets (the Asus Transformer Infinity, the Nexus 10, and briefly, the iPad 3) for my work in scientific research, with mixed results. Unfortunately, I've not had a go with the Microsoft Surface range, but there are some excellent blog posts by Mark O'Connor to assist me in my review (albeit from a programmer's, rather than a scientist's, point of view).

It's a recurring question (of mine, of the internet's) whether a tablet can indeed replace a desktop and/or laptop for some, most, or even all your scientific research needs. This may be with or without a keyboard attachment (this blurs the lines between laptops, 'hybrids' with dockable touchscreens, and tablets). Of course, my answer to this will be general, and heavily biased by my experiences and needs. Everyone has a different workflow and specific discipline, each requiring unique and personalised technological demands. But this is why comment boxes were invented: do chip in below (or on Google Plus) with your opinions.

Requirements


Let's remove the low-hanging obstructions first. If you have access to a supercomputer for heavy lifting, like running hefty computer scripts, then tablets are viable; however, not if you need to carry round your CPU heft. Let's also assume that, if you need professional-grade image editing or other proprietary software, you won't even consider the lightweight alternatives. (Journalist reviews of Chromebooks and tablets as productivity replacements are often negativity skewed due to their disproportionate reliance on software such as Photoshop.)

I need to following in my entire workflow:

  • Access to Mendeley for scientific article reading, management, annotation, and bibliography creation
  • Access to a GUI word processors (e.g. Google Docs, MS Word) and LaTeX typesetting (preferably cloud-based like sharelatex.com). 
  • Access via SSH to the university supercomputer (remote access to edit and run scripts for my research)
The following qualities are encouraged in my device of choice:
  • Screen size big enough to see a lot of code, images, writing; but small enough to be portable
  • VGA or HDMI out for presentations
  • Long battery life for working remotely, at conferences, etc
  • Openness and access to free software


General issues

Both Android and iOS tablets run on ARM processors. This is an architecture: the computer is set up differently to your typical PC (which often run x86 processors). Apps or programs written for one architecture cannot simply work on the other one without being recompiled. In addition, (non-Pro) Surface tablets run a ARM-specific OS called Windows 8 RT. ARM architecture typically gives devices excellent battery life (not always...) but less computational heft. If you're doing mostly less-CPU-intensive tasks, such as coding, writing, and reading, modern mid- and high-end tablets have the power. The other issue is that the apps you require have to be (1) written for your mobile OS of choice, and (2) has to be optimised for your tablet. This is not usually an issue on iOS and Android, but Windows RT currently falls short in the quality of ecosystem, as reported by many other sites. On an optimistic note, Android once upon a time had a much lower quality of tablet apps in comparison to iPads, but has now arguably caught up.

If you do a lot of writing, a bluetooth or dockable keyboard is essential. This begs the question: don't they already have screens that attach to keyboards? The advantage of a removable keyboard and ARM-powered heart is the flexibility to slouch-and-read versus sit-and-type - and the freedom from being tethered to a power source.

Let's look at OS- and ecosystem-specific issues.

iOS

The only tablets that run iOS are the iPads. As mentioned, I've only had 1-2 weeks of iPad experience. Apps can be more polished than those seen on Android and Surface tablets, but in my experience, you had to pay a lot more, and a lot more often, for suitable apps. I found Android to have a lot of excellent Google apps (free) and open-source software/ports (free), but the applications were sometimes buggy or ugly (if this matters to you). The blogosphere has contrasting arguments about ecosystem app prices, however, and statistics alone do not tell the story. Some developers charge for features after you've downloaded their free app; others require you to update to a new (paid) version for continued development.

iPads are more locked-down; this might result in a more secure system, and may protect battery life against badly-written power-sucking apps, but it can make it hard when trying to browse files, administrate at a system levels, etc. This ultimately was the knock-out blow for my budding iOS adoption: for example, I need to be able to easily upload/download files when working remotely.

Android

Simply, you've got more choice here. Android tablets are made by Samsung, Asus, Google, and many other companies. You won't find a dockable iPad; you won't find an iPad with a dedicated and specialised stylus. However, build quality tends to fall short of the iPad's industrial-yet-pleasing design. 

Windows (RT)

There's the Surface 2, which runs Windows RT, in line with the rest of this list. But there's the Surface Pro 2, too, which has x86 architecture. The Surface Pro is best described as a touch-screen laptop with a removable keyboard, rather than a tablet, and is almost double the price of the entry-level iPad/Nexus 10. It can run Windows 8 programs, rather than simpler apps, but battery life is inferior. It's ultimately the comparison of apples and oranges. As such, I will only consider the Surface 2 (ARM) here.

As mentioned, Windows RT is still developing; more worryingly, it's not clear if it will be allowed to continue to develop. Companies have, one by one, stopped making ARM-powered Microsoft devices, and instead concentrated on x86 devices instead. The excellent keyboard options that the Surface has available may be a moot point if the OS languishes in its current state, behind Android and iOS.

On the other hand, if you require MS Word above all else, you can't beat the Surface 2. MS Office comes free of charge with the device, and it is almost identical to the typical PC (x86) version.

My experience

I found tablets to comfortably perform a lot of common tasks in my work. I found that writing was good in word processing apps (Apple's Pages, Android's Google Drive/Docs), though a little more difficult on sharelatex.com (using a web browser on a tablet is not still on par with laptops, but e.g. the Google Chrome team are on the path to merging the two branches). This was similar across devices I used. Reading was also excellent on all three of the iPad, Asus Transformer Infinity, and Nexus 10. Ten inches is the minimum for PDF reading/annotating if you don't want to be constantly zooming and scrolling, and a high-resolution screen is also important when studying images and text. Using SSH apps, I could log on to my university supercomputer and edit/run code. I could even write code locally and upload it later, when offline. I could manage my Mendeley library almost completely via apps and the browser, thanks to a wonderful application.

However, the screen size was prohibitive at times; multitasking was a pain; web-browsing could be laggy; and OS updates on Android often broke as many features as they fixed (a common issue with Google, who seem to value cutting-edge over stability). Some have said that a 10-inch screen forces you to concentrate on the task at hand, bottlenecking/sharpening (delete as appropriate) your focus and attention. Others, me included, are so scatter-brained with code and writing/reading that a large surface area is required; tabs and windows litter two or more monitors; alt-tab or its equivalent just won't cut it. Most importantly, apps might be a good approximation, but if they can't beat a full-blown program on a (x86) laptop, you're left wondering if it's possible to skimp. In my case, the most important program was Chrome, as I (can) do most my work in the browser. Google Presentations isn't ready for tablets yet, either, and that is my go-to application for PowerPoint-style presentations (on my Chromebook).

The worst experience was with Asus. My Infinity tablet, while beautiful, broke often. It's more truthful to say my five Asus tablets. In the end, I took the refund rather than waiting for Asus to fix yet another mechanical issue. Also, Asus tablets have a common processing bottleneck where the computer chip can't seem to do two things at once, like downloading an app update and type at the same time. I also faced nothing but problems when connecting to an overhead projector to show a PDF. You just can't risk these issues cropping up on the day of a scientific presentation! On the contrary, I didn't see the same fragility with the Nexus 10 and iPad.

Summary

Today, I use a Chromebook Pixel (x86 laptop) for my day-in, day-out workflow, and this speaks volumes. Ultimately, one needs reliability. I didn't find this physically with Asus tablets, and I didn't entirely find it software-wise in the app stores on both iOS and Android (though we're almost there). One also needs productivity; if this requires a large screen, then it's going to have to come from a laptop as it stands. But if you like the modular focus of full-screen apps, it won't be a problem for you. And if you want to type quickly and efficiently, you need a hardware keyboard, begging the question: "And so what's left to make me choose a tablet over a laptop?" And here's where I hold the candle of optimism for tablet (and portable/cloud) computing as a whole: battery life should be all-day, apps and OSs should be lightweight and easy to maintain, and there should be plentiful development for applications. Here, tablets (and Chromebooks) are side-by-side, if not well past, the level of standard laptops that run Windows and Mac OS. So I'd answer my title question as such: close to all but not close enough. You can't replace the laptop or desktop completely as it stands. Let's see if the new Nexus 10 and attendant update to Android (4.4) appear enough to make me change my mind.

Let me know if you have any other solutions or workflows. I probably have a lot more to say on this topic, but this was a rough overview of the major issues and experiences I've had.

Wednesday 16 October 2013

ShareLaTeX vs Microsoft Word in scientific writing: Part 1

A co-author and I are in the process of writing two scientific articles for submission to a meteorological journal. As these two papers will be similar in structure and content (obviously not too similar!), this gives me an opportunity to weigh the benefits of LaTeX-in-the-cloud versus the standard Microsoft Office Word application. So let the fight begin! In the cloud corner, I present the Chromebook Pixel:

Chromebook Pixel (left) with external monitor displaying PDF (right)

It's the best Chromebook out there right now, and was produced as more of a showcase for Chrome OS. It's got more power than most people need in a Chromebook. Also, it can simultaneously run Ubuntu Linux thanks to the Crouton project. This comes into play later in the post.

Next, in the local/MS Office corner, I present the Compaq Presario C700:



It's old, but still going. It runs Windows 8 (soon to be 8.1) and Microsoft Office 2013. Its battery is now useless, requiring constant hookup to the mains; fortunately, I can access it from my Chromebook remotely via Chrome Remote Desktop, if I need to be portable.

As with all good scientific sensitivity tests, I need to keep everything the same in both cases, and just change the variable I'm testing. Here are the other helpers in my paper-writing factory:

Bibliography management: Mendeley

First, I use Mendeley to manage my biblography. It's an "iTunes for scientific papers and PDFs", as I've once heard it described. It syncs all my PDFs (metadata and all) to the cloud, so I can access everything from the browser, or download a desktop program (Mac, Linux, Windows). Its major flaw for us Chrome OS users is the almost-impossible way to get PDFs into your online catalogue, as you can't download the application (and shouldn't need to!). Yes, this is a little extremely counter-intuitive for a cloud-friendly application, but that's the way it is right now. The best solution is to run Ubuntu on my Pixel when I need to upload PDFs, via the previously-mentioned Crouton solution. But if I just want to access my papers within Chrome OS, Metatato is a handy website (and Chrome extension) which mimics many features of the desktop Mendeley program.

When I'm using ShareLaTeX, I can upload a .bib file automatically generated by Mendeley. Then I can easily cite references within LaTeX (this ease is a major advantage of LaTeX over Word). And when I'm using Word, there is a plug-in that allows Word to import citations from Word, and automatically generate a bibliography. I've only had experience with ShareLaTeX; I will report back on Word-and-Mendeley integration in Part 2.

Figure creation: Google Drawings

I'm creating figures for publication with Python, but this is maintained on a separate server. I access the server via SSH from Chrome OS. The outputted images are then downloaded onto my Chromebook via a public_html folder on the server, and uploaded into Google Drawings if required (for annotating, combining etc). I've previously mentioned Google Drawings as a good all-round image editor. It can combine smaller images while maintaining their resolution (good for publications); it is good for quick schematic diagrams; it integrates well with other Google Drive office-style applications. It is easy to export (download) the final product as a .pdf to create good-quality figures for either Word or ShareLaTeX. And it certainly beats using Word or Powerpoint to mash together a diagram (often the case in academia it seems!).

Verdict: Using ShareLaTeX for collaboration

If the other person is not as comfortable using LaTeX, it can become difficult. A lot of people are much more comfortable with Word due to its malleable, What-You-See-Is-What-You-Get nature.

Example of ShareLaTeX.com screen, with code in the middle, and the compiled PDF on the right.

Otherwise, ShareLaTeX shows history of edits (with a paid account), has a chat facility, is accessible simultaneously by two (or more, with paid account) people, and compiles relatively reliably. I found that large documents (my thesis, for example) sometimes wouldn't compile, but this was only ever temporary and more likely to do with the huge volume of high-DPI figure files in my project.

The main advantages with (Share)LaTeX is as follows:

  • Seamless, easy management of bibliography
  • An organised folder of high-resolution figures that precludes the need to chase images round your Word document
  • Everyone has the same 'version'; no compatibility errors like with Word (both different years and different OSs!)
  • Fast help from the website developers when there were issues compiling
  • ShareLaTeX is free at its base feature level, which is sufficient for many people (poor students like me included)


    However, there are shortcomings:
    • Can be tedious when trying to get a manuscript to output perfectly in line with a journal's style guide. Sometimes, where a change would be a couple of keystrokes in Word, it would be a time-consuming Google goose-chase to track down the relevant 'hack'.
    • ShareLaTeX is still missing a mature 'track changes' equivalent for collaboration (and the ability to point fingers at whoever just deleted that supremely-written paragraph)
    • Some journals don't like LaTeX. Full stop.
    I hope to discuss these matters further when I begin the entire process again for the second paper, but in Microsoft Word. I look forward to sharing my experiences...

    Completing a Master's in the cloud

    As previously mentioned, I decided to do my Master's Thesis work on a computer running Chrome OS (a Samsung Chromebox). Including a HD monitor, keyboard, and mouse, it cost less than half the price of my colleagues' iMac desktop computers (running OS X). In fact, I started using an iMac before being offered a new computer of my choice, and chose the cheaper Chrome OS route. I'm not saying everyone can save money and do that; but I'd like to explain why I don't think a $1500 desktop computer is the right choice for everyone.

    Example of Chromebook and external monitor (rotated for easy reading of PDFs)

    First, my main tasks as a Master's student were writing essays for classes, writing my thesiscoding in Python and Matlab as part of my research, and putting together poster and projector presentations. Originally, on the iMac, this was completed using Microsoft Office Word, a local build of LaTeX, Mac's native Terminal, and Office Powerpoint, respectively. The iMac wasn't a newer model; it was creaking and slow, and the spinning beachball of death made a frequent cameo throughout. When I switched to the Chromebox, I gained speed and ditched frequent, large application updates. But I also had to create a new workflow. Here's how I did it.

    Writing

    LaTeX is my favourite way of creating a professional-looking manuscript, but for short class essays, it can be overkill. However, Microsoft Word can also be overkill. Google Docs does most of the same, basic tasks, and is frequently updated. It auto-saves every few seconds, is accessible on any computer with internet connection, allows download of .doc files for offline editing (or even switching to e.g. MS Word), and is excellent for collaboration (not that class essays required much of that).

    Google Docs


    ShareLaTeX.com


    When it came to long, organised manuscripts with many images and some mathematical typesetting, I required LaTeX. Luckily, ShareLaTeX.com is a fantastic free resource; it compiles 'in the cloud', meaning it's an all-in-one system to avoid requiring a local build of LaTeX for your typesetting needs. It was slightly slower to upload my figures, and compile remotely, but this downside was countered by frequent auto-saves, and the fact that packages were provided and administered by the website programmers. Less time worrying about admin; more time writing my thesis.

    Coding

    I was fortunate to have access to a university server with plenty of programming power. Chrome OS has an extension that lets the user SSH into another server or computer. In my case, I was harnessing the server's horsepower, and hence my local computer was a terminal with no need for a powerful processor: just the window to connect remotely. If I needed to do anything locally, however, I would have needed to either run a Crouton script (which installs a Linux distribution, such as Ubuntu, to be run alongside Chrome OS with no need to dual boot) or install a ChrUbuntu partition (requires a restart of the computer to boot into Ubuntu). Chrome OS, while based on Linux, does not allow installation of regular Linux applications without some severe modding.

    Presentations

    Google Slides (image created with Google Drawings)

    I ultimately presented my Master's defence in Google Slides, a free alternative to MS Office's Powerpoint. Not only does it automatically back up slides while editing, it can be used to present via a projector on any computer with the Chrome browser. It did not have many templates and some other flashier features found on Microsoft's paid competitor, but it was sufficient for a professional and reliable presentation. In terms of creating a conference poster, Google Slides has recently updated to allow for custom page sizing. I will report back on this when it comes to creating a poster for a conference I am attending in February.

    Other

    To create schematic diagrams, and to perform other image-editing functions, there were two programs that provided all the tools I needed. First, Google Drawings is a Paint-like web application which integrates well with Google Drive's free alternatives to MS Office. It works very well for combining high-resolution images (and keeping the resolution before downloading as a PDF). Second, the offline packaged app Pixlr Touch Up proved useful for changing colour images to black-and-white, cropping, and other basic photo and image tools.

    Overall, the Chrome OS experiment was a success, and I did not regret being an early adopter (I don't know anyone else who currently uses Chrome OS as their main OS for science research). If you have any workflow-related questions, or wondered if this kind of system would work for you, please use the comments section below.

    Tuesday 15 October 2013

    Introduction

    Are you a Mac person or a PC person?

    This was the first technology-related question posed to me soon after starting work on my Master's Thesis at a new institution, two years ago. It's probably a common one for most people too. But it's a false dichotomy: it's a post-PC world. A world where Microsoft hasn't yet successfully adjusted to falling PC sales. Apple isn't the sole alternative for science, education, and technology, as I will argue. This blog will hopefully offer thought-provoking alternatives, or advice to those looking for open, cheap (free?), flexible workflows in scientific research, technology, education, and beyond.

    There have been many solutions to the bloated, high-expense Windows ecosystem. Such as an iPad as a thin client; that is, using a lightweight terminal (such as an iPad) to connect to a more powerful server or computer elsewhere. Or the typical fallback of Linux, with its various distributions  though we haven't yet seen the oft-hailed world-conquering new dawn of Ubuntu. My choice two years ago was halfway between these two: Google's Chrome OS. It's a lightweight distribution of Linux, but at first glance, it best resembles Windows 7. However, it couldn't be more different. HTML-based packaged apps (that work offline) combine with websites or 'extensions' loaded in the Chrome browser (that usually don't). You cannot install Windows or Mac apps, but this in part prevents the typical system slowdown you find in those OSs. Updates to Chrome OS occur automatically every six weeks or so, takes seconds to complete, and the HTML/Linux core obviates many of the security risks with Windows/Mac machines. And as everything is synced with the cloud, you can wipe the machine (accidentally, deliberately), and everything can be returned safely at a later time simply by logging in. Best of all: laptops and boxes start at $199 (USD).

    Photo: Andrew Cunningham, Ars Technica

    Schools are catching on. The public are enthusiastic. But the key is that Chrome OS (and cloud-computing in general) does not work for everyone. This is especially so as a researcher in science. In fact, it doesn't always fully work for me (as I will articulate in a later post). Many of us need specialised (local) applications that may be constrained to just one or two OSs. Others require proprietary software such as Photoshop and cannot afford to skimp. On the other hand, there are some everyday apps that can be replaced with cloud-based (and usually free) alternatives. For example, Microsoft Office becomes Google Docs. A local setup of LaTeX (the typesetting language used often in sciences and technology) becomes ShareLaTeX. By nature, these cloud-based alternatives are backed-up and frequently use auto-save, and become more reliable than traditional local applications. There's also the option of remote access via a Chrome window into your Windows, Mac, or Linux laptop. Finally, there are other ways of running typical distributions of Linux on a Chromebook if needs be.


    But further specifics can wait until a future blog post. This blog will highlight, amongst other things that pop into my head, the benefits of open-source, or free, or cloud-based techniques in the sciences, technology fields, and education. It's driven by a few main points:
    • Academia shouldn't be spending so much on bloated, locked-in systems when it should pride itself in free, open alternatives, where available and appropriate.
    • The same can be said for school and university students, who are often encouraged to buy high-end laptops that some students simply don't need.
    • Tips and tricks, and faster and more efficient workflows, are better shared between scientists and in other related fields.
    Comments encouraged, and I hope to write something of interest!