Wednesday, 9 October 2013

Getting stuff into Editorial

Editorial is the new text editor on the block that has all the kids talking. Its two main features that set it apart from the other N markdown editors available on the iPad are a) Inline preview of markdown, in a very pretty format, and b) the thing is fully Python scriptable. A compendium of workflows shows all the cool stuff you can do with built in workflow components and Python scripting.

One issue with apps like this is getting docs in there in the first place. Many apps, Editorial included, can access a Dropbox account, and will by default set up their own directory in /Apps/. So one has a choice of manually moving documents to and from that directory, or making one’s entire working directory available to the app. This latter is overkill, so I was looking for an easy way to get stuff into and out of Editorial. The solution is to stick the following bash code into an automator service. When run on a file, it will move that file into the Editorial Dropbox directory, and create a placeholder file with extension “edi” in it’s place. Running the script on the “.edi” file will move the document back to its home (and delete the edi placeholder).

xpath=${1%/*} xbase=${1##*/} xfext=${xbase##*.} xpref=${xbase%.*} editorialDir="/Your/Editorial/Dropbox/Directory" if [ "$xfext" == "edi" ] then echo "here!" targName=`less $1` mv $editorialDir/$targName $xpath rm $1 else if [ -a $editorialDir/$xbase ] then COUNTER=2 while [ -a $editorialDir/$xpref$COUNTER.$xfext ]; do let COUNTER=COUNTER+1 done targName=$xbase$COUNTER.$xfext fi mv $1 $editorialDir/$targName echo "$xpref$COUNTER.$xfext" > $xpath/$xpref.edi fi

Sunday, 10 March 2013

Google Nexus 4

So recently I lost my iPhone 4 on the way back to the office from lunch. Two things of note:

  1. I had location services turned on on the iPhone, and could use the “Find my iPhone” feature to track it down. I managed to work out roughly where it was, to within 20–30 metres or so, but the location kept jumping around, indicating the phone was inside (or inside a drain) and couldn’t use GPS. This turns out to actually not be that helpful—I asked around various shops/businesses (including where I bought lunch) but without having a good idea about the precise building or room, there’s not much you can do. One feature I unfortunately did end up using was the remote wipe; I’ve lost a phone, but don’t have to worry about nefarious use of personal information.

  2. To replace the iPhone—which had been carrying along nicely, no complaints—I bought a Nexus 4. This turns out to be pretty full of features, and nearly half the price of an iPhone 5 (yes, I could have bought an iPhone 4 or 4S, but, y’know…). Some impressions:

    a. The phone itself is pretty solid, and really light compared to previous smartphones I’ve owned. It’s a slippery sucker though, and seems to willitself off tables and armchairs.

    b. I had an Android phone a few years back, and although I thought it was good, it didn’t have the same level of polish as iOS. This version (Jelly Bean) actually looks nice, and I’d forgotten how cool it is to use things like widgets. I totally understand the benefits of Apple’s walled garden, but it’s nice to be able to do your own digging. The one glaring exception is the gmail app—on iOS the recent-ish update to the gmail app is beautiful to look at, and the Android version is just plain old ugly in comparison.

    c. I seemed to encounter the issues with buggy wi-fi that have been bugging others. Wi-fi at work was fine, but the connection at home kept dropping. I came close to just returning the damned phone as I wasn’t able to reliably download apps, but in the end installed a third party app that brought the issue under control.

    d. One new feature in Android is Google Now. This allows you to do voice searches and commands, and also brings up useful information (e.g., appointments, flight details) by intelligently working out when you’ll need them. So far I’ve only ever been told about the weather and upcoming calendar appointments, so I lead a dull life (most plausible) and/or Google needs to mine my data deeper (also plausible, and somewhat disturbing).

    e. I don’t have a constant mobile data connection. Whether this is to do with poor coverage from Virgin or a hardware/software fault I don’t know, but it is something I miss from the iPhone on O2.

Thursday, 19 July 2012

New ipad = lush paper reviews

One nice feature of the new iPad (iPad 3.0, whatever) is that it has voice dictation built in. This isn't Siri, but simply a mechanism for talking loudly and unnaturally to the iPad and getting back a text transcription of what you said. This makes reviewing a breeze. I tend to mark up PDF's on the iPad with comments, and the voice transcription gets around using the software keyboard which, though OK, isn't really ideal for typing more than a few words.

Friday, 18 May 2012

Major minor annoyances

Some people have issues with the fancy new appearance of the Google products that's been rolled out over past 6 months or so. I don't actually, but in the process it seems Google have also been shaping the profile of their products and services.

One manifestation of this is in the drop-down box under "More" when you run a search. One option under that menu I used to use extensively was Google Scholar, which would take the search term you just used and use it to search Google Scholar. Now, you click on "More", go down to the bottom of the long list of options to select "Even More", and then get taken to a web page which has Google Scholar there somewhere, just keep looking. Click on Scholar, and oh, by the way, you've lost your original search term.

This might be a symptom of the larger number of services that Google offers, but seems crazy for two reasons:

a) Some of the options in the menu bar or the "more" menu itself show up in the side bar after you've run a search anyway; redundant! Why not put Google Scholar over on the left there buddy?
b) It's not clear why there isn't space for Scholar, but there is for options like "Finance" and "Books".

I find it hard to believe, but maybe this shows that academic users are in the minority. Some have implied that this is all about commercialisation, and others wondering whether this is the end for Scholar altogether (I doubt it, given Google seems to have some interest in research and academic collaboration).

Anyway, a solution is to forego Google altogether. I've been using DuckDuckGo as a search engine, and it's pretty neat. The results it returns are nice and clean, it's attitude to privacy is refreshing (it allows users some), and most importantly it allows specifying particular web sites to search using a bang (!) character. So Google Scholar is !gsc and can be entered on the fly, and once used is easily accessible in a drop down box for future searches.

Long-term, the question is what happens with offerings like Google Scholar, and whether alternatives like Microsoft Academic Search become more appealing.

Tuesday, 6 March 2012

GeekTool

Just found a neat tool for OS X called GeekTool. It installs an item in the preferences pane that allows you to show all kinds of geeky stuff (CPU load, memory usage etc.) on your desktop. People have done some pretty cool things with it, but my use is more mundane: just checking that all my hg autosync processes are up and running.

Monday, 6 February 2012

Switching between Scrivener and Bibdesk

For the past 8 years or so, I've used LaTeX almost exclusively to write my (academic) papers. Once it is up and running it takes care of the nitty gritty of formatting and referencing, meaning you can focus more on the writing. For several of those 8 years I've been on a mac, and finding the combination of TeXShop and BibDesk pretty darn awesome. BibDesk is a reference manager for the Mac that stores its database in BibTeX format (a standard bibliographical format used by LaTeX). TeXShop is an editing program built for editing LaTeX files; these are plain text and could be edited in any old text editor, but TeXShop provides nice LaTeX syntax highlighting and a fairly useful macro system (and is less busy than other editors I've looked at).

Having said that, TeXShop is pretty ugly to work in sometimes when there are lots of comments and insertions around and things start to get messy. So recently I've been using Scrivener to write my papers and similar documents. Scrivener is basically a lovely looking writing environment that let's you make comments separate from the doc (a la Word), and has some nifty features for managing project-related files and snippets (great for collecting random thoughts you want to put in a paper somewhere at a later date...but not just now!). It doesn't do LaTeX natively, but I've got a pretty smooth system converting to LaTeX via multimarkdown (more on that another time). One thing I miss about TeXShop is the ability to quickly search for BibDesk references inside the editor. We can't do this (at least while it isn't scriptable), but the next best thing is to set up some shortcuts to switch between the apps. My setup is as follows:

* In Scrivener, I have BibDesk set as my bibliography manager (under Preferences > General). This does little more than switch to BibDesk when I press command-Y.

* I have a little applescript in BibDesk that it is triggered by the same command-Y key combination. It will take the references currently highlighted in BibDesk and copy them to Scrivener. The applescript is as follows:
tell application "System Events" to keystroke "c" using {command down}
tell application "Scrivener"
activatetell application "System Events" to keystroke "v" using {command down}
end tell
* All this will do is copy whatever BibDesk usually copies into Scrivener. We want to copy the references over in multimarkdown's referencing format, and can do this using templates in BibDesk; see  here for a discussion and examples. Mine looks like this:
[#<$publications.citeKey.@componentsJoinedByComma/>][]
So when I press command-Y in BibDesk (having selected a few references) I get something like [#Estes55;][] back in the Scrivener doc. It's a bit slow and clunky but does the job. Also, I'm not really an Applescript programmer, so there may be a more sensible way to do this.

Friday, 3 February 2012

Computational modeling summer school


Hey, you should totally check out the 2012 SNF Summer School in Computational Modeling of Cognition!

Mercurial: Dropbox for geeks

I'll admit it, Dropbox is pretty cool. It's great for quickly sharing photos and docs with others (including collaborators), and for a while I was using it to keep much of my working directory in sync across computers. What's especially cool is the rat pack add-on, which keeps track of all your file changes so you can revert to an old version if you do something stupid (and boy, can I do some stupid things).

However, last year there were a few privacy issues raised with Dropbox. The first is that there is no client-side encryption. That means that although your data is encrypted on their servers, this can be decrypted by them also. Their policy is not to do that, but they *can* be forced to "when legally required to do so". Then there are fond memories of the time that every single account was left accessible without a password for a good few hours. Ouch!

Even though the work I've been sharing on Dropbox isn't super-sensitive (just working papers, data analyses and modelling), this isn't really reassuring. One solution is to use services like SecretSync. However, this requires forking over money for a pretty basic service that Dropbox should be providing by default. So instead I've turned to a geeky option called Mercurial. I've actually been using this for a few years to keep stuff in sync with Steve Lewandowsky when we were writing our masterpiece, and it works really well.

Mercurial is technically known as a distributed version control system. We start off with a seed repository, which contains the initial state of all our files (if any), and initialize it. Then every user of the repository can clone that repository to their own computer so they have local copies of the files. One important thing is that the files in our directory are kept separate from the repository itself. Accordingly, working practice is to edit as per usual, and then every now and then to "commit" those changes to the repository (e.g., at the end of the day, or when you've reached a milestone). However, even after committing those changes, they'll still just be local to your computer. Accordingly, one needs to push their changes to the central repository (which is usually hosted on a server, and talked to via ssh or the like) and pull changes that other users might have made.

One nice thing is the merge feature. If I've made changes to a file, and you've made changes to the same file in the interim, then mercurial can automatically merge those changes in an intelligent fashion. In cases where changes can't be merged (i.e., we modified the same line in the file), we can use a program like kdiff3 to manually resolve the conflicts; in my experience this happens pretty rarely. Another cool thing is that we also have a record of all changes we've made to all files in the repository since the intialization. This has been a lifesaver in cases where, for example, some model simulations have been working really well, but then in overexuberant exploration I've made some silly edits and lost the working version of the model (yes, I can be that silly sometimes).

By default, committing, pulling and pushing all need to be carried out manually. However, I've been using an extension called autosync that will automatically go through a commit/pull/merge/push cycle regularly. Mine fires off every 10 minutes, so my computers are more or less in constant sync. This avoids one problem with Dropbox, which is that it eagerly syncs across all the crappy auxiliary files that are generated when compiling LaTeX documents. I've got my Mac set up to delete all the auxiliary files after completion, so this mostly prevents this happening. Deleting those auxiliary files does mean each compilation takes longer, but hey, compiling is just really fast these days.

So Dropbox, you've a great service, but I think we should just keep it casual.

Saturday, 10 December 2011

First!

Having read a post by Dorothy Bishop on academic blogging, I've been inspired to start up this blog. For a while now I've been meaning to start one up simply to share code and hacks with others, as I've really found others' posts on technical topics really useful. However, as pointed out in the post, blogging is a great way of communicating directly with the public, and for communicating research that wouldn't make it into a journal. So let's give it a go and see what happens...

SPSS to LaTeX (funk to funky)

Some bits of writing a paper can be fun---finding a good way to present an argument, or coming up with a theory that explains some weird results. Other bits are just plain dull, and some of the dullest must be method and results sections. Transcribing F values, p values and degrees of freedom from your stats package into a paper really is not something that researchers should be spending time on. Furthermore, these are the bits that we as psychologists are getting wrong. Some recent and disturbing evidence comes from Bakker & Wicherts (2011), who showed that an alarming number of papers contain errors in their reporting of statistical results (and these errors are biased towards finding a significant result).

One solution is to automate statistical reporting as much as possible, which in turn implies automating the analysis/modelling process itself. Indeed, a recent movement (see, e.g., http://www.sciencemag.org/content/334/6060/1226.full) urges for reproducible research, whereby data are made available to other researchers along with the precise code that was used to turn those data into the results reported in a scientific paper. To link the analyses with what actually appears in a published article, programs such as R have been integrated with LaTeX via such packages as Sweave. I use MATLAB to run many of analyses, and integration with Sweave hasn't really progressed. Furthermore, I actually call SPSS from MATLAB so I get some of the useful stuff that SPSS prints out (like effect sizes and contrasts), whilst using MATLAB to do the grunt work of scoring up performance. So instead I wrote this addin, which takes Excel output exported from SPSS for a repeated measures ANOVA, and turns it into LaTeX-ready output. It would be straightforward to do the same for between-subjects effects, regression etc.---I just very rarely use these!

Bakker, M. & Wicherts, J. M. (2011). The (mis)reporting of statistical results in psychology journals. Behavior Research Methods, 43, 666-678.