Resolving network connection issues on Linux Mint (Ubuntu)

So several years after purchasing my smallest form-factor netbook Aspire One I have stumbled upon issue that I couldn’t explain myself. Hopefully this would help somebody and save time it took me to figure out.

Background

The Aspire One was the only netbook with descent (2GB RAM at that time) amount of memory and Linux installation out of box (=minimal support guaranteed). I have used for some time, but than gave up for a while since keyboard proved to be a bit too cramped for my palms and fingers, so extensive use caused some pain. Still it is a nice little piece of hardware that is easy to transport, not expensive (meaning if gets stolen or broken I won’t cry over it :)) and, finally, it is a full-fledged Linux-powered thing with real (althoguh small) keyboard large enough hard disk to host my music collection. All in all, after some time I decided to give it a try.

Continue reading “Resolving network connection issues on Linux Mint (Ubuntu)”

Tips for using JSON WordPress API for JetPack-powered websites

Being a lazy person I prefer to automate as much as possible instead of performing routine work manually. Well, you need to make it once to know what you need to automate, but that is where it stops for me.

So I had a goal of preparing and publishing a number of posts on my (only in Russian for now, sorry) website for motorcycle enthusiasts, where the data could nicely fit into a database and when available it can be wrapped in a template and posted. OK, I need to get the data myself, but publishing tenth of posts is NOT an option. Luckily I had already Jetpack installed, which gave me access to the JSON API.

I will describe separately how to obtain the proper authorization tokens (not sure I can repeat it, it is made for confusion, not sure about security though). When you do have those you can use API. My favorite language of choice for automation is Python, therefore I started typing code before even thinking of selecting a different language.

Continue reading “Tips for using JSON WordPress API for JetPack-powered websites”

Manipulating files with @ sign in a subversion repository

Apparently it was a while ago since I had troubles with infrastructure :), but this time it took too long to leave it unnoticed. Quite some time ago I have created several files in the subversion repository with the ‘|’ character in them, which gave problems checking them out on a Windows… ehm… box (if you can call Surface a box :)).

Continue reading “Manipulating files with @ sign in a subversion repository”

Fixing the ‘Missing required field “updated”‘ error in WordPress TwentyTen theme

When exploring my hobby website in Google WebMaster tools I noticed that all WordPress posts had the same ‘Missing required field “updated”‘ error. After some searching I understood that the proper solution would be to use a child theme (which I already had since I wanted to change the default font of the TwentyTen theme) and I need to change the way the posted date is shown so that it also indicates to Google that it is the update date.

Continue reading “Fixing the ‘Missing required field “updated”‘ error in WordPress TwentyTen theme”

Control touchpad in Ubuntu (Mint) from command line

I have a small netbook where I like to type occasionally drafts of my posts and documents. One of the annoying things is that I regularly seem to be hitting touchpad and unintentionally moving cursor to whatever position in the document it is not hovering over. Unfortunately the existing Fn shortcuts does not seem to be working out of box on Linux Mint. This became so annoying that I started looking around and found that the xinput utility can help. You can look for the list of devices and send corresponding commands.

The list of devices on my Acer Aspire One looks like the following:


? Virtual core pointer id=2 [master pointer (3)]
? ? Virtual core XTEST pointer id=4 [slave pointer (2)]
? ? 2.4G Wireless Mouse id=10 [slave pointer (2)]
? ? ETPS/2 Elantech Touchpad id=13 [slave pointer (2)]

The third “core pointer” device has a pretty obvious “Touchpad” name. Sending corresponding "Device Enabled" command will either enable (1) or disable (0) it.

Finally I have quickly put it in the following script:

#!/bin/sh
DEV_ID=`xinput list | grep Touchpad | awk -F '=' '{print $2}' | cut -f1`

if [ "$1" = "on" ]; then
    echo "Enabling touchpad (id $DEV_ID)"
    xinput set-prop $DEV_ID "Device Enabled" 1
elif [ "$1" = "off" ]; then
    echo "Disabling touchpad (id $DEV_ID)"
    xinput set-prop $DEV_ID "Device Enabled" 0
else
    echo Uknown option, use on/off
fi

Enjoy!

Unable to commit to subversion archive

This was quite annoying. I have tried several commits in a row blaming network connection and all kinds of gremlins. I have updated Ubuntu server, but still getting the same error:


svn: E175008: At least one property change failed; repository is unchanged
svn: E175002: Server sent unexpected return value (400 Bad Request) in response to PROPPATCH request for 'some file name'

What was suspicious that removing one file did not help. Then I have looked in the Apache log file on the server, where I found the following:


Could not get next bucket brigade ...

Searching further brought no direct cure except for an advice to switch antivirus off. Well, yeah, not for my setup.

So the solution was pretty simple. Split the commit in multiple chunks and submit them separately. Basically I have issued several svn revert commands on folders, and voila, it worked! Not very nice if you want to have one commit, but at least you’re not stuck anymore.

It seems that subversion has problems with large commits :(, although that does not result in a clear error.

I hope this helps somebody!

Pylab.show() does not show graph

Nothing showing up when using pylab.show()? Change the default non-interactive ‘agg’ backend to something that can actually show something:

import matplotlib
matplotlib.use('Qt4Agg')

If this fails, on Ubuntu you may need to install Qt first:


sudo apt-get install python-qt4

Enjoy!

Microsoft Surface 2 Pro

Introduction

I always take a portable with me on vacations, trips, visits, etc. One time I did not take anything with me turned to be one of the worst-vacation-ever, so I decided that I’d better take something with me and not use it than spoil another vacation in desperate search for something to work on :). Anyway, I already went through an old BSD-powered subnotebook, a black MacBook (ancient by modern standards, but still serving happily as a Skype station for my wife :)), an iPad (well, not really working machine lacking command line and any sign of development environment, but at least I was able to read/take notes/make kids happy with cartoons :)), Nexus 7 (when iPad went broken) and finally the last-of-the-breed Acer Aspire One D270 Ubuntu-powered netbook. I deliberately spared my MacBook Pro from travel for several reasons, but netbook proved to be a less versatile option, prompting to get a tablet along. Spoiled me. On one of the last business trips I had a business notebook (owned by client), my own one for other projects (I do not mix businesses) and a tablet for on the way. Well. That proved to be an overkill even for a week. So it was time to look for something different. But what?..
Continue reading “Microsoft Surface 2 Pro”

Adding basic logging to your Python script

Whether you like it or not, but there are many situations when you need to add logging information. It is easy to start with some print statements, but what if at certain point you want to put this information to a file? Redirecting output to a file will result in all-or-nothing situation since the contents of the file will be only visible at the end of execution. A more flexible and proper solution would be using a proper logging module.

Continue reading “Adding basic logging to your Python script”

Windows batch files arguments

Since Windows happen to be the platform of choice of my clients for business needs I tend to write also scripts for Windows. Many times I just create small batch files to mimic Unix commands like ls and ll as I forget to type dir instead. Anyway, many times I just want to pass any parameters provided to a batch file to the callee, and I used to have something like

@dir %1 %2 %3

Well, there should be a better way, and there is

@dir %*

and just in case you wander what other options are supported (and there are surprisingly many!), check out

call /?

in Windows command prompt, aka cme.exe.

Enjoy!