Category Archives: Software

WordPress Blogroll Links Import Fix & Google Spreadsheet to OPML Generator

In order to bulk import a list of titles & URLs for my friend’s blogs into wordpress, I created a google spreadsheet and then used an open-source opml-generator to turn the spreadsheet into OPML and import it into WordPress.

The hosted version at http://opml-generator.appspot.com/ was not working for me as of Aug. 2015, so I fixed it and ran it locally. Here are the fixes I made.

To Run

I had to install the google app engine python SDK, https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python

Also, I had to install django-utils and python 2.7

$ sudo pip install django-utils
$ sudo apt-get install python2.7-dev

Then, simply use the appserver included with the google app engine python SDK, give it this project’s directory

$ /path/to/google_appengine/dev_appserver.py /path/to/opml-generator

The happy output should look like

INFO     2015-08-17 03:30:37,516 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO     2015-08-17 03:30:38,341 sdk_update_checker.py:257] The SDK is up to date.
INFO     2015-08-17 03:30:38,373 api_server.py:205] Starting API server at: http://localhost:40380
INFO     2015-08-17 03:30:38,375 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2015-08-17 03:30:38,376 admin_server.py:118] Starting admin server at: http://localhost:8000

and go to http://localhost:8080/

Enter the URL, the title, and the “opml” url should automatically populate.

Changes

Then I had to make a few changes to make app.yaml recognize the django-utils was needed, that I was using python 2.7,

$ vi app.yaml
threadsafe: no
runtime: python27

libraries:
- name: django
  version: "1.5"

I created the URL via “Share” > “Share with Others” > “Anyone can view” and it looked like

https://docs.google.com/spreadsheets/d/1GXkKX74boMLia2lIVwgN0E

It appears that the original code works with old google docs urls, which look like:

https://spreadsheets2.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0Ah0xU81penP1dGlQbGZ6Si03M0ZOQTd2ZzRfUmdUTmc&output=html

Thus, I modified base.html to find the document key appropriately.

//var ssKey = ssUrl.split('key=')[1];
var ssKey = ssUrl.split('/d/')[1]; console.log(ssKey); 
//ssKey = ssKey.split('&')[0]; 
ssKey = ssKey.split('/pubhtml')[0];

Note: I also threw out some printouts to console.log to figure all this out. They can be found by using Chrome or Firefox, Ctrl-Shift-C, and going ot the “Console” tab.

Screenshot from 2015-08-16 23:50:09

I also edited the output URL which, for localhost, did not include the port.

//var opmlUrl = 'http://' + window.location.hostname + '/opml?sskey=' + ssKey + '&wsid=od6'; 
var opmlUrl = 'http://' + window.location.hostname + ':8080/opml?sskey=' + ssKey + '&wsid=od6';

Output OPML Format

In the end, I looked at the output OPML and think I should probably have just made the file by hand / with vim macros… it would have been easy enough. But I got to take a peek at Google App Engine, so that was nice.

Here’s what the OPML looks like, if you’re interested in creating it more manually instead of installing google app engine etc. etc. to run this code:

<?xml version="1.0" encoding="utf-8" ?>
<opml version="1.1">
 <head>
  <title>MITERS</title>
 </head>
 <body>
   <outline text="MITERS">
    <outline title="MITERS | MIT Electronics Research Society" xmlUrl="http://miters.mit.edu/blog/feed/"/>
    <outline title="nk | Nick Kirkby" xmlUrl="http://nkirkby.scripts.mit.edu/nk/feed/"/>
  </outline>
 </body>
</opml>

Or in screenshot form

Screenshot from 2015-08-16 23:31:43

WordPress Import Blogroll Fix

The error: when you try to import the OPML file into WordPress, it says “All done!” but when you check the blogroll manager, no links were actually imported.

Screenshot from 2015-08-16 23:34:13

The fix: Super simple. Just change all the instances of xmlUrl in the OPML file into htmlUrl .

Screenshot from 2015-08-17 18:27:12

Tada! The links now import properly 🙂

Fixing “Docky crashes on suspend or unplug” in Ubuntu 14.04

in short

download and install this deb file; or do it yourself in just seven lines (see below)! 🙂

intro

On Ubuntu 14.04, my docky crashes extremely often (on any power status changes — suspend, disconnecting from the charger, etc.).

The fix has been known for a while, but after several months and no new Docky package (perhaps it is no longer maintained?), I decided to dig in and figure out how to fix this.

This time I googled it, and someone else had written up how to apply the fix to source code, build, and re-install. Turns out to only take a handful of lines! Here, I’m documenting with pictures.

Basically, we apply the one-liner fix using the “classic” instructions here How to download, modify, build and install a Debian source package? .

Ready?

Fixing Docky

Let’s get the source and edit the file “Docky.Services/Docky.Services/SystemService.cs”, as described in “Comment 2 for bug 1309706“:

apt-get source docky
cd docky-2.2.0/
vim Docky.Services/Docky.Services/SystemService.cs

For me, the fix was on line 281. Change

[Interface(UPowerName)]

to

[Interface("org.freedesktop.DBus.Properties")]

See pictures below.

Before

dockysrc

After

dockysrc-fixed

Build it~

sudo apt-get build-dep docky
dch -i

This last step is to update the package number. I don’t know anything about this, but it auto-inserted a new package number so I just wrote a quick comment and called it good.

dockysrc-dch

debuild -us -uc -b
sudo dpkg -i ../docky_2.2.0-2ubuntu1_all.deb

Whoo! That’s it 🙂

Deb File

Here’s my file: https://drive.google.com/open?id=0B9r0HZeoMbmgVDhubWxFM0doMms

and its SHA sum follows, although obviously just doing the seven command-line steps above yourself is easy and way more secure…

nrw@nrw-PC:~/docky-2.2.0$ sha256sum ../docky_2.2.0-2ubuntu1_all.deb
92f631efbeabd85496b359de6884dc21061b6d52ee8a4b34759c5dd8960e7146

Redmine Backlog Tweaks (via Tampermonkey/Greasemonkey): Highlight My Backlog

My coworkers wrote a script that, via a Chrome/Firefox plugin (Tampermonkey/Greasemonkey respectively), highlights the items on a Redmine backlog that belong to you and also puts in parenthesis at the top how many of the points on the sprint are yours.
Before:Screenshot from 2015-07-30 14:53:50After:Screenshot from 2015-07-30 14:53:27The scripts, written by Tom and Abra, can be found at https://arvados.org/projects/arvados/wiki/Highlight_my_backlog , and my version (combining the two and adding in a strong orange color + larger and different font) can be found as follows:

// ==UserScript==
// @name         Highlight my redmine backlog
// @namespace    https://arvados.org/projects/arvados/wiki/Highlight_my_backlog
// @version      0.1b
// @description  Highlights issues assigned to you in redmine Backlogs view and
//               puts in parens the total point count you have for each sprint.
// @author       Tom Clegg, Abram Connelly
// @match        https://arvados.org/rb/master_backlog/*
// @grant        none
// ==/UserScript==

$.ajax('/my/account', {success: function(data, _, _) {
    var key = $('#api-access-key',data).text();
    var url = '/issues.json?assigned_to_id=me&limit=100';
    var ajaxopts = {
        dataType: 'json',
        headers: {'X-Redmine-API-Key': key},
        success: dopage
    };
    $.ajax(url, ajaxopts);
    function dopage(data, _, _) {

        var my_sprint_info = {};

        for (var i=0; i<data.issues.length; i++) {

            if ("fixed_version" in data.issues[i]) {
              var sprint_id = data.issues[i].fixed_version.id;
              var sprint_name = data.issues[i].fixed_version.name;
              if (!(sprint_id in my_sprint_info)) {
                  my_sprint_info[sprint_id]={"story_points" : 0, "sprint_id" : sprint_id, "sprint_name" : sprint_name };
              }
              if ("story_points" in data.issues[i]) {
                my_sprint_info[sprint_id].story_points += data.issues[i].story_points;
              }
            }

            $('#story_'+data.issues[i].id).css({
                'background':'#F49C54', //orange
                'font-family':'URW Bookman L, serif',
                'font-size':'1.2em',
            });
        }

        if (data.total_count > data.offset + data.limit) {
            $.ajax(url + '&offset=' + (data.offset + data.limit), ajaxopts);
        }

        for (var sprint_id in my_sprint_info) {
            var cur_pnt = $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text();
            cur_pnt += " (" + my_sprint_info[sprint_id].story_points +")";
            $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text(cur_pnt);
        }
    }
}});

Step-by-Step Greasemonkey Install

1. Install Greasemonkey: https://addons.mozilla.org/en-us/firefox/addon/greasemonkey/

2. Create a file with the contents above ending in “.user.js”

3. Double-click the file and Greasemonkey will install it

For more details, see http://www.orangenarwhals.com/2015/02/step-by-step-greasemonkey-script-to-remove-ui-elements-for-screenshots/ .

Step-by-Step Tampermonkey Install

1. Install Tampermonkey: https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en

2.  Go to the tampermonkey icon and click “Add a new script…”Screenshot from 2015-07-15 05:10:49

3. Copy-and-paste the code in and ctrl-s to save (or click the floppy disk)

Screenshot from 2015-07-15 05:11:31

If you want to edit the script, just go to Dashboard and click the script name to open up the editor.

Screenshot from 2015-07-15 05:11:11

Backstory

At work (Curoverse), we are all Arvados contributors (and open-source data and computation workflow management platform) and use the open-source Redmine to keep track of our open issues, tickets, and bugs.

We chose to use Redmine and merely mirror on Github, instead of using Github Issues, because Github itself is not open-source and we prefer to own our own data. In particular, since we operate in sprints, we use the backlog feature a lot. However, I’d been struggling to adopt Redmine, since it was impossible to use as a to-do list.

But my co-workers made a greasemonkey / tampermonkey browser plugin that highlights your tasks & how many points are assigned to you, which makes the whole system way more usable.

See the original link, https://arvados.org/projects/arvados/wiki/Highlight_my_backlog, for more details about the Redmine API and features you could add  to this script 🙂