A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Faster count(*) in postgres

For an approximate count you can do:

SELECT reltuples FROM pg_class WHERE oid = 'schema_name.table_name'::regclass;

(replacing schema_name and table_name)

(source)

How to REALLY disable game center on iphone

How to prevent annoying game center login prompt (or freezing and popups if you're logged in):
  • Log out of game center
  • Start game center
  • Instead of logging in, create a new Apple ID (bottom of game center logon screen). Doesn't matter what you create as this is bogus. You are now logged into game center with a different ID than you use for other features such as the App Store
  • Log out of game center
  • Start a game, press cancel, and exit the game
  • Do this three times, and game center will prompt you if you want to disable it. Select yes.

For then on, you'll never be prompted for game center logon, or get the game center notifications.

If you download a new app from the App Store, it will use your original Apple ID, which is the behaviour you want.

Confirmed working for iOS6.

(source)

Poor notification features on iPhone

The notifications on iPhone are really poor compared to Android or Blackberry.

First of all, the list of default sounds are all so horrible! They irritate my ears. Why not include some soft and pleasing sounds as well as the loud and harsh ones?

On my android I used the vibrate function to discretely notify me of an incoming message. On iPhone the vibration is so loud that it can be heard by the entire room, it's as loud as the notifications themselves - what's the point in that?

Then there's a central list of notifications settings. But lots of apps (even Apple's built-in apps) don't allow you to configure the notification sound from that list, e.g.:

  • Built-in clock's Timer function. Not in the notifications list, only configurable in-app, and limited to a set of loud, harsh sounds. "Buy More Tones"...? Yeah, right. Why can't I choose my own sounds for this?
  • Built-in clock's Alarm function. Again, only configurable in-app. At least here I can "Pick a song" and use any mp3 I can come up with. But no vibrations possible.
  • WhatsApp - only has a switch to turn sounds on/off. Notifications are in the app, and severely limited to one of seven loud, irritating sounds that are impossible for me to use at work. And there is no custom vibration possible. Okay, maybe this one's not Apple's fault, but I was perfectly happy with notification in the Android version of this app.

Why is it important that all apps appear in the notifications list? Simply because any improvements to the central notification functionality will then be usable with those apps. If it's not in the list, it will be left behind with a lame in-app out-of-date feature-less custom notification system.

In the accessibility settings you can set the LED to flash when a message comes in, but it only flashes once! Not very useful - what if you miss it? On Blackberry you can make it keep flashing until you see the message.

In the Sounds section of iPhone settings, there's "Sounds and Vibration Patterns". An excellent feature where I can tap the screen to design a vibration pattern pleasing to me, such as a vibration hard enough to be felt by me, but soft enough so no-one can hear it. Unfortunately there are some fatal flaws in the feature:
(1) It only lists Apple's built-in apps, plus Twitter and Facebook (i.e. no WhatsApp). Why isn't this feature connected to the central notifications list?
(2) It's damn difficult to tap in the right way to produce the vibration I want. I need to be able to design the vibration using numbers like some apps on other platforms: On for 100ms, off for 1000s, on for 100ms, etc.

These are killer features for me and ultimately they will prevent me from using the iPhone for any length of time. I'm sure things will be slightly better with iOS7, but I'm sure Apple's built-in apps will still fail to integrate consistently with any new central notification features.

Gmail on iPhone "username or password is incorrect"

"The user name or password for imap.gmail.com is incorrect"

To fix, go here and enable access:
http://www.google.com/accounts/DisplayUnlockCaptcha

But what you really want to do is create a one-time application-specific password:
  • Go to Google account settings: https://www.google.com/settings/account
  • Click "security"
  • Click "Manage your application specific passwords"
  • Create a new password and use that on your device
(source)

Sync Google contacts with iPhone

iOS 7 should just work when you add a Google mail account.

iOS 5 or 6:
Settings > Mail, Contacts, Calendars > Add Account... > Other > Add CardDAV Account

(source)

Change the date of a git commit

Author date:

git commit --amend --date="Wed Feb 16 14:00 2011 +0100"

Commit date:

GIT_COMMITTER_DATE="Wed Feb 16 14:00 2011 +0100" git commit --amend

You've got to love git.

(source)

Query installed packages on Ubuntu

Ubuntu uses debian packages, not RPMs so yum isn't relevant.

List all packages:
dpkg-query -l

Display summary info for a package:
dpkg-query -s package_name

Display files installed by a package:
dpkg-query -L package_name

Instant message notifications on Linux

Pidgin

Pidgin is an IRC client for Linux and Windows.

By default, pidgin's notifications on Linux that someone is messaging you are not very visible, they're in the title bar of the application, and can easily be missed.

There's a plugin included that causes the notifications to pop-up using libnotify, but they only appear from a short time and are not customisable, so are also easy to miss. "notify-send" is one command to send notifications using libnotify.

Growl is a notification system (originally for Mac) designed to be customised with a particular display style. There's a growl plugin (written in Perl) on the official Pidgin plugins page, but it seems to be designed to work with growlnotify, which doesn't run on Linux.

There's a port of growl for Linux (the daemon). To send it notifications you can use growl_notify.pl which is a wrapper for Growl::GNTP, the Growl protocol. The growl plugin mentioned above could be modified to use growl_notify.pl.

You could then choose your desired display style for Growl, e.g. something that stays on top of other windows and can't be missed.

There's also a prototype notification plugin that uses zenity, a package that displays simple dialog boxes that are much harder to miss.
To use it, download this pidgin zenity plugin, put it in your ~/.purple/plugins directory (create it if it doesn't exist), and it will appear in your Pidgin plugins list.
As it's a prototype, it will currently notify for every message in a conversation, but you may prefer being notified too much rather than too less. Email the developer if you want it to be improved.

Skype

It's also easy to miss incoming Skype messages. But Skype has an "Execute the following script" option for incoming chat messages. That can be set to something like this:

/usr/bin/zenity --warning --title "Skype message" --text "You have received a message in Skype"