Lightweight .emacs

The last couple of years have seen a change in my Emacs setup. Work dictates that I have to use a number of different machines; in the past I’ve tried to give a consistent experience no matter which machine I was working on. Bookmarks, abbreviations, org-agendas were all stored on Dropbox, and an increasingly complicated set of code took into account paths for different operating systems and network setups. 

It came to a point where I seemed to be spending more time on my .emacs files than I was on actually doing anything.  I began to ask myself, was consistency that important?

The answer was no.

So I changed my approach.

I’ve streamlined my init file as much as possible. I now spend my time trying to find a way to use existing features as far as possible, If possible, I write lightweight code to solve a problem,  only installing packages as a last resort.  (take a look at my really simple scrivener mode for an example of this)

I still use packages, of course. I’m not going to stop using org mode or evil or magit, but I don’t need them on every computer. 

As far as my Emacs setup goes, I now only use Dropbox to enable the use of Orgzly and Beorg on my portable devices (I still use it to sync all my other files, of course)

Lastly, I’ve had a love hate relationship with Evernote over the years but I’ve been really impressed by the direction that it’s been going over the past 18 months.  All my records are now stored there, my agenda and editing is all done on Emacs (I sometimes forget that editing was its initial purpose).

Goodbye Simplenote, Hello Again Evernote

We’ve all got a list of our favourite CEOs.

Okay, we haven’t. But if we did, mine would be Ian Small of Evernote.  You can see him here, clearly uncomfortable at being in front of the camera. I rather like him for that. Being good on camera doesn’t mean you can do the job. I’m increasingly wondering if the opposite might be true.

Anyway, read this message Ian Small wrote back in January, stating Evernote’s priorities for the year ahead. I particularly liked this passage:

And honesty requires us to state—straight out—that we can do better with the product you have today than we are currently doing. In fact, we can do better than we have been doing for some years.

He goes on to promise to concentrate on getting the foundations of the product right before adding new features.

Since then he seems to be making good on his promise.  

You might remember this article I wrote in 2016 saying I was leaving Evernote for Simplenote. Well, I’ve now gone back to Evernote. I like the direction things are going. I’m still disappointed with the lack of Linux support but I’ll trade that in for something that’s solid, or at least is attempting to get things right.

And I must admit, I rather like Ian Small’s (rather awkward) style.  Many people seek advancement by promising to make big changes.  They go for the grand gesture and then move on, leaving others to sort out the mess they’ve made. It’s rather refreshing to see someone quietly getting on with the challenge of trying to make something that’s already quite good work just that little bit better.

WordPress Pharma Hack

Someone kindly emailed me to point out that my writing site had been hacked. Links for Cialis were now appearing scattered throughout the text.

A quick Google search revealed that this was a common hack, and was probably the result of some rogue code embedded in a file after a brute force attack. I ran a site security check (there are many free services if you search for them) which suggested that the problem was located in wp-config.php. I could have paid for a clear up, but taking a look at the file in question it was clear the code wasn’t exactly trying to conceal itself. Once snipped out, my site’s performance improved immediately.

… or so I thought.

A few days later, the adverts reappeared. This is a clever hack – snip out the code and it regenerates itself.

There are various flavours of the Pharma Hack, (a search for WordPress Pharma Hack will give you all the details you need and more) the one that hit me had added an innocent looking file: /wp-includes/init.php

I only discovered this after I’d deleted all my themes and plugins and installed fresh versions of wp-admin and wp-includes. When I restarted the site, the following message appeared at the top of the page:

include_once(.../public_html//wp-includes/init.php) [function.include-once]: failed to open stream: No such file or directory in .../public_html/wp-config.php on line 93

Checking line 93 of wp-config showed the offending line (I’ve surrounded it with **s):

** include_once(ABSPATH . '/wp-includes/init.php'); ** 
require_once(ABSPATH . 'wp-settings.php');//Disable File Edits
define('DISALLOW_FILE_EDIT', true);  

I removed the line, reset my passwords, including the database passwords, reinstalled my plugins and (hopefully) that’s it.

I should have noticed this sooner, of course, but I’ve not been blogging recently as I’ve been concentrating on finishing my next novel.

Even so, I must hold my hands up and admit that I’ve not given my sites the attention they deserve. I’ve installed some security software following a quick search for WordPress security plugins on Google, I’ll take some time to monitor what’s going on in future.

Map AltGr to Alt on Linux

All I wanted was to make my AltGr key to work the same as my Alt key…

As my poor hands continue to struggle with RSI, I’ve been looking at ways to make my typing more efficient. One thing that occurred to me was to fix something that had bugged me for ages: the fact that I never use AltGr on my keyboard. Things would be easier if it acted like Alt. It would certainly make it more comfortable to hit M-x and M-g in Emacs

And so I searched and searched for ways to do this. The simplest way I found was to type the following command into the terminal:

setxkbmap -option altwin:meta_alt

But how to run that at startup?

My Arch Linux setup uses the i3 window manager, which is called from ~/.xinitrc. Adding setxkbmap -option altwin:meta_alt to the beginning of ~/.xinitrc did the trick.

That doesn’t work on Ubuntu 16.04, however. The easiest way there is to use dconf editor.

sudo apt-get install dconf-editor if you’ve not already got it, then navigate to org|gnome|desktop|input-sources and choose xkb-options.

Insert the following in the value box: ['altwin:meta_alt']

… and that’s it.

RSI, Tendonitis, Carpal Tunnel Syndrome…

I suppose it was inevitable that after so much time spent writing stories and articles and programming, I would suffer from Repetitive Strain Injury.

I’ve taken care of myself over the years: making sure I set up my work station properly, doing exercises, buying a suitable chair, using an ergonomic keyboard. Even so, things are getting more uncomfortable…

So now I’ve taken three further steps, as follows:

i3wm

I’ve installed the i3 tiling window manager on my Ubuntu setup. (Here’s an article on why you should use a tiling window manager)

I’ve used i3 for some time on my Arch Linux setup, mainly for speed and simplicity. As it has become apparent that using the mouse gives me the greatest amount of pain, it seems sensible to do anything to reduce its use. The i3 desktop is the perfect solution. It allows you to do nearly everything using the keyboard, which has the added bonus of increasing productivity.

I now deliberately push the mouse away from the keyboard so as to lead me not into temptation whilst I work. Doing this has encouraged me to learn the shortcut keys for applications such as Chrome and even things like VLC and Spotify. If I’m honest, it’s only laziness that’s stopped me learning them in the past: I could have searched for the Chrome shortcuts at any time, but it was easier just to use the mouse.

i3wm sits nicely on top of Ubuntu. Installing on Ubuntu is a great way to get used to using it, as you have the fallback of logging into Unity when you need it.

Evil Mode

If you read my blog, you’ll know I’m an Emacs user. However, as I said in this blog entry, you have to admit that vi has a great set of key bindings. I do my planning and structural editing in Emacs – there’s nothing faster – but When it comes down to plain text editing I find the vi commands easier on my poor hands. That’s why I use evil-mode.

I’ve set up my .emacs file (see below) so that I can turn evil-mode on or off by pressing F6. I’ve also added code which I found on Stack Overflow that causes evil-mode to go to Emacs mode when I press any insert command. Switching between modes allows me to get the best of both editors. For example, I much prefer vi’s ma and `a to set a mark and jump to it, rather than Emacs’s rather cumbersome C-x r SPC a. Points marked in vi are remembered no matter how often you turn on and off evil-mode in a session.

Dictation Software

Lastly, I’ve taken the plunge and bought voice recognition software, the software used to dictate this blog entry, as a matter of fact. On the plus side, it saves using my hands, on the minus side, Dragon Naturally Speaking only comes in a Windows version. I suppose I should have a look at installing it on Linux using Wine.

I’m finding using Windows 10 extremely depressing experience. Still, I’m only there long enough to dictate notes. After that it’s back onto Linux and Emacs where I use my precious hands to do the editing. I’m currently clocking myself on Emacs, comparing my typing rate with my dictation rate. It will be interesting to see which is faster. I’m having to get used to thinking my thoughts then speaking them rather than just typing and thinking at the same time. I wonder if it will have an effect the creative process? More on that another time…

.emacs and evil-mode

(require 'evil) ;; installed using Elpa

;;  The following ensures j,k for up and down follow visual-line-mode 
(define-key evil-normal-state-map (kbd "<remap> <evil-next-line>") 'evil-next-visual-line)
(define-key evil-normal-state-map (kbd "<remap> <evil-previous-line>") 'evil-previous-visual-line)
(setq-default evil-cross-lines t)

;; i a o etc go to emacs mode 
(defalias 'evil-insert-state 'evil-emacs-state)

;; Turn on and off evil-mode
(global-set-key (kbd "<f6>") 'evil-mode)
(global-set-key (kbd "C-M-z") 'evil-mode)

Goodbye Evernote, Hello Simplenote

Simplenote launched a client for Linux at the end of March, 2016. As a longstanding Evernote premium user, frustrated initially by the fact there’s no Linux client, and then frustrated even more by the fact I could no longer get the Windows client to run under WINE, I thought I’d give it a look.

As the name implies, Simplenote is simpler than Evernote. No notebooks, no reminders, no support for pictures.

In fact the only thing Simplenote handles is text, and that’s its great strength. Sticking to tiny text files means that notes load and sync quickly. Also, the whole experience doesn’t seem as cluttered as Evernote has become with its "all things to all people" approach.

Sticking to text means that Simplenote does a few things extremely well. It has Markdown support built in, for example. I write most of my Evernote notes using markdown format, but Evernote has a habit of adding extra hidden formatting that only becomes obvious when those notes are opened in Draft or Stackedit (it also throws in odd whitespace characters when I copy notes across to Emacs)

Simplenote allows you to download a zip file of all your notes, and its at this point the advantage of sticking to text only really hits home: the files downloaded are text files. That sounds obvious, but it means that rather than picking your way through xml or whatever, you can open an individual note in your favourite text editor and start editing. It’s that simple.

Keeping things text also reduces memory usage, which in turn allows Simplenote to add a history feature – pull back a slider and see previous versions of your notes.

There are some things that aren’t quite there… For example, although you can tag notes in Simplenote, I’ve yet to find a way to filter multiple tags, something that is essential if you want to replicate Evernote’s notebook stacks, which I do.

In summary then, Simplenote does a lot of things better than Evernote, but it’s not a full Evernote replacement.

So which will I be using in future?

No question. Simplenote, for the sole reason that it has the Linux client. It’s not just a question of what to do when there’s no internet connection, it’s also a question of speed. Chrome is so big nowadays it takes an appreciable amount of time to load. Add to that the occasional hiccup when changing between notes on a web browser and the benefits of having a client become obvious.

I wrote this blog entry on Evernote. It may be the last one I do…

EXIF: WordPress Images Appear Rotated

I recently encountered a problem with images appearing rotated whilst updating the latest posting in the How Writers Write feature on this WordPress powered website.

The images looked fine whilst I was editing the page, but when previewed they appeared rotated.

Searching online showed this to be a known problem, all to do with EXIF data. You can read more about EXIF data by following this link to How-To Geek

The WordPress problem seems to be that the images are recorded with one orientation and then displayed with the rotation stored in the EXIF data added to them.

The easiest way I’ve found to get the images displaying properly is to first strip the EXIF data and then to rotate them appropriately before uploading. There are instructions on the How-To Geek link above on how to strip EXIF data in Windows.

It’s a lot simpler in Ubuntu or similar.

First, install exiftool

sudo aptitude install exiftool

Exiftool allows you to look at the EXIF data in an image as follows

exiftool someImage.jpg

We want the data stripped. Copy your images to a directory (I just copy them to my pristine desktop) and then run the following command

me@comp:~/Desktop$ exiftool -all= -overwrite_original -ext jpg .

And that’s it. Time for a cup of tea.

Upgraded to Windows 10 and Ubuntu 15.10

… and that’s it.

Absolutely no problems at all. I didn’t even have to reinstall GRUB as some sites warned me I’d have to.

That’s a dual boot machine, partitioned flash drive.

I don’t know what else to say, I almost feel cheated. Both upgrades took about 15 minutes.

Looks like I’ve got no excuses for not filling in my tax return now.

Ubuntu 15.04 + Chillblast Fusion Quasar

I’ve installed Ubuntu 15.04 on my new PC with little difficulty. The machine came with 64bit Windows 8.1 pre-installed, I partitioned the SSD and HDD drives appropriately and Ubuntu went on with no problems…

… once I’d managed to get the usb drive with the installer to boot in the correct mode.

Windows had been installed in legacy boot mode, the usb kept booting in UEFI mode. First I changed the BIOS settings so that devices booted in legacy mode only. This meant that the PC wouldn’t boot from the usb at all. I eventually found an option in the BIOS to force boot from usb and everything went fine.

So far everything is working okay apart from printing from usb (network printing is fine) and Geeknote connection to Evernote. I did have problems getting the Linux Spotify client to work, but the following post gave a solution: http://www.webupd8.org/2015/04/fix-missing-libgcrypt11-causing-spotify.html

I hope the above is of some use to someone!

Update 10/5/15: Had to download the latest hp-lip to get usb printing working. All sorted now

Codes that Changed the World: Fortran

Before Fortran there was no poetry in programming

The BBC are doing a a very interesting radio series on programming languages called Codes that Changed the World, starting with this one on Fortran.

I learned Fortran 77 at university as part of my maths degree. What most sticks in my memory are the dreadful videos we were made to watch featuring a male programmer trying to explain concepts to his dumb girlfriend. That we found the videos offensive goes without saying. I (and many others) stopped going to the lectures and taught ourselves using the text book.

What really puzzled me was why they showed the videos in the first place. Even the lecturer used to apologise for them, saying they were dreadfully old fashioned, but they can’t have been that old. I went to university in 1984. Now, when did Fortran 77 come out, I wonder?