Viral campaigns with maitre

At Trustroots we’re experimenting with virality. I found maître, and it looked awesome. I reached out and they gave us a 50% discount. Great start. We setup the campaign, deployed, and then found a small glitch and had difficulty with our specific use case. Chatted with their support, and by the time I read their reply, they had deployed all three suggestions I made.

They’ve set a whole new bar for exceptional customer service. If you want to run viral campaigns, I highly recommend checking them out via my affiliate link!

Problems with SiteGround

I recently ditched all but one of my dedicated servers and decided to switch to shared hosting for all my PHP / WordPress sites. First I tried TMDHosting, had a serious issue, cancelled that, and then switched to SiteGround. I prepaid for 2 years. Might have been a big mistake.

Site disappeared

First, an entire site disappeared from their server. I had a copy in an old backup, but otherwise the site files and database had disappeared. Their support had nothing useful to say, and suggested it had to be my mistake. Possible, but highly unlikely that I accidentally deleted both the files and the database.

Sites offline

Yesterday I had an issue with permissions. There were 4 .well-known folders in my sites directory that were owned by root. I noticed because the letsencrypt installer didn’t work. Created a ticket, they fixed permissions on 1 of the 4 directories I had listed. I updated the ticket. They replied saying they’d fixed all 4. Many of my sites went down. 403 error.

Solution

I’m travelling in Seville. I was out. I turned around and went back to the apartment, jumped on live chat. They told me that somebody would reply to my ticket within 20 minutes and there was nothing else they could do. I logged in, checked permissions, found one site that worked, and fixed the problem.

Turns out that on several of my htdocs folders, the “other” r-x permissions had been removed. Evidently nginx was unable to access my sites. Today I see a reply to the ticket saying that they didn’t change anything, and they’re glad my sites work again. WTF?

What do I do now?

Two serious failures. The second caused real downtime, albeit a few minutes because I fixed it myself. Any recommendations on a good shared hosting provider? What do I do about my 2 year prepayment?

Social posting from WordPress

Now that composer is shutting down, I’m looking at how to send posts to Facebook, Twitter, and maybe LinkedIn while keeping the original here on my WordPress site.

The most “official” option is JetPack from Automattic, the makers of WordPress. It’s easy to setup, but it doesn’t work perfectly on Twitter for my setup. I spent today trying options, including this plugin. The plugin is a bit complex to setup, but is super powerful. You need to pay for Google+ support though.

The only change I wanted to make to Jetpack was to use the post content as a title on Twitter, when there is no title. So if I post a status update with just a body, that should go to Twitter, not an empty title an a link to the blog post.

I started here. Turns out that approach doesn’t work. Or at least, after 4 hours of debugging, I couldn’t get it to work. No, in fact, I’m 90% sure it doesn’t work after I finally read the Jetpack code. Wow, what a time sink that turned out to be.

Finally, I got it running. I use the publicize_save_meta hook, check if we’re publishing to Twitter, and if we are, and there’s no post title, and no custom message already set, I set the custom message to the post body, trimmed.

O2 DE Multicard Cheat Sheet

Just switched to simplytel.de. Great deals right now, as far as Germany goes. 5GB data, unlimited calls / sms, 1GB of roaming data in the EU, €20/month.

Plus, it includes the option to have 3 sim cards, what they call multicard. Been messing about figuring out how to switch call routing, etc.

*120# – cheat sheet (German)
*121# – show which sims are online
*122# – where are calls routed
*123# – route calls here

*124*P# – set this device priority P (1-3) or 0 to disable, doesn’t seem to work

*125# – route SMS here
*126# – route MMS here

These are all USSD codes which you run on the phones to configure the call routing. I couldn’t get the priority to work, it maybe isn’t supported by simplytel (Drillisch) as a reseller of o2, not sure. I got this info here.

iMac memory upgrade

The memory upgrade from Crucial arrived this morning. After an initial false start and three beeps, we are up and running. Apparently memory has to be paired between slots 1 and 3, and slots 2 and 4. After that hiccup, we’re on fire! Here’s the obligatory before and after shots…

iMac memory beforeiMac memory afterI noticed on the screenshot, that apple actually publish instructions on how to upgrade, fantastic! Now I have ~14GB free, with all my browsers open. Fabulous.

Authenticate sudo with SSH agent

There’s a wonderful package called pam-ssh-agent-auth which allows sudo authentication via the SSH agent. This means no more typing passwords for sudo. Instead, just connect with ssh -A to forward your agent, and then use sudo without a password.

Installation is fairly simple, there are lots of walkthroughs around. First, grab this ppa, then add your SSH pub key to /etc/security/authorized_keys, sudo visudo and add Defaults    env_keep += "SSH_AUTH_SOCK", then edit /etc/pam.d/sudo and add auth sufficient pam_ssh_agent_auth.so file=/etc/security/authorized_keys after the other auth lines.

I deployed it all with puppet, but I think that’s everything.

Easy GitHub backup with curl

We just deleted an old private GitHub repository. Before we did, I wanted a copy of the issues. Turns out, it’s super simple with curl. Of course, you can backup the repository itself very easily like:

git clone git@github.com:user/repo.git
git clone git@github.com:user/repo.wiki.git

Then to get the issues, first I created a new personal API token on GitHub. Then, took a minute to figure out, but you use that as the username with a blank password or a password of x-oauth-basic. Then the curl command looks like:

curl -u 'access_token:x-oauth-basic' https://api.github.com/repos/user/repo/issues

If you got everything right (which I didn’t the first 5 or 10 times…) you should get a JSON document containing the issues of that repo. There will probably be multiple pages. Personally, I used curl -sSi and piped to less, then I saw the links for page 2 and 3 in the headers. I repeated the process by hand and dumped all three pages into .json files.

There are tools available to automate this, but the whole thing took me less than 15 minutes by hand.

Octocat Pumpkin

Recalibrate the Hubsan X4

If, like me, you’re too lazy to watch the video, here’s the steps:

  1. Turn on as normal, put the Hubsan in expert mode (press right control stick down)
  2. Push left control stick to fully bottom right
  3. Move right stick fully from left to right back and forth
  4. When lights blink, the drone has calibrated

When the X4 is not staying still while hovering, this can help a lot.

Advanced CrashPlan backup strategy

Some lessons I’ve learned in my year and a half with CrashPlan. Please note, this is an advanced guide to CrashPlan. You have been warned. I assume you’re already familiar with CrashPlan and understand their backup sets, etc.

This post covers several topics (and I might update it later if I remember or discover more).

  • cron vs anacron
  • backup speed
  • file selection verification

Cron vs Anacron

Personally, I consider this a bug, and one that CrashPlan ought to have fixed a long time ago. When configuring “Verify selection every”, if you choose a number of days and a time of the day (which is the default), your backup verification will only happen if your computer is on at the scheduled time. Ala cron.

However, if you choose a number of hours < 24, and your computer is off at the scheduled time, the backup verification will run as soon as the computer is on again after the scheduled time. Ala anacron.

Bottom line, for your most important data, set the verification to run every 23 hours and accept that it’ll happen at inconvenient times of the day.

Backup speed

For a long time I felt like CrashPlan took forever to run backups. Eventually, more than a year after using the service, I decided to investigate. I found some excellent articles.

tl;dr Change the advanced settings. If you’re backing up compressed media, turn off compression. For backup sets that rarely change, change “Data de-duplication” to minimal.

I discovered this after I decided add ~500GB of media on a USB disk to my backup sets. After making these changes, the backup took about 6 weeks instead of 3 months! I regularly saw upload speeds of >6Mbps on connections that would support it, I was moving a lot during the 6 week upload period!

File selection verification

This is an optimisation I’m only now figuring out nearly 2 years into my CrashPlan adventure. If you’re backing up a large folder of very infrequently changing data, put it into its own backup set. For example, I backup ~500GB of audio and ebooks. I almost never add to the collection.

By putting this into a separate backup set from my photos I can run a manual file verification of the photos without also waiting for the verification of 1’000s of book files which I know have not changed. My advice is the more backup sets the better.

Note that if you split one backup set into multiple smaller sets, you will lose the history, including any deleted files, previous versions, etc. Best to set this up from the beginning. But remember CrashPlan is a backup system, and it should not be confused with external storage.

Conclusion

CrashPlan’s java app is horrible. It’s slow, ugly, and a PITA to use. If I could find a better alternative, I’d switch in a heartbeat, I have zero loyalty to CrashPlan. However, having said that, as of my last research, CrashPlan is simply the only contender in the market. The defining characteristics for me are:

  • Client side encryption with key that is unknown to my backup provider.
  • Sensible pricing (unlimited space, 10 computer family plan for $150/yr).
  • Indefinite retention of external drive backups (BackBlaze for example deletes these after 30 days, or after 6 months if your computer is off, even while you continue paying, completely outrageous).
  • Cross platform, even if I only actually use OSX, the idea that I can also backup a Linux based server is a necessity with a 10 machine plan.

Find me another service that has these features and I’m there. In the meantime, I continue to use CrashPlan and endure its peculiarities and shortcomings.

Samsung Note 10.1 2014

I recently got a Samsung Note 10.1 2014 edition tablet. I wanted to replace paper note taking. I’ve been in a lot of meetings recently, and I write notes, mostly to aid in remembering the points, I rarely actually refer to them. Aside from the need to always have paper and pen, this was generating a substantial amount of paper. So I did a little research, and settled on the Note 10.1. The NotePro, essentially the same device in a 12.1 inch size, was interesting, but felt less portable, and too heavy to easily hold in one hand.

For its intended purpose, I’m extremely satisfied. The S Note application is excellent. It has a few quirks, like only having on default page which must be either portrait or landscape, but aside from that, it’s very good. The pen feels good writing on the screen, not quite as good as a ballpoint on paper, but certainly good enough for extended writing sessions.

I got a case with a hand strap. Turns out this is an excellent feature. When I’m holding the tablet portrait (subject to this bug), the handle makes it possible to hold the tablet with one hand and write on it with the other. It’s too big to hold in one hand without this strap, so I had to always put it down on something in order to write on it. The case was a big improvement, and I’m happy with the quality of the case so far.

The tablet includes a one year subscription to Evernote premium. I’ve installed Evernote on my mac (was going to do that anyway), and now my handwritten notes are synced automatically from tablet to laptop (and phone). If one ignores the concerns over privacy in having all my data unencrypted on an American corporation’s servers, it’s absolutely fabulous! 🙂

I haven’t used the tablet much for browsing the web. Firefox is my browser of choice, and it’s pretty poor on a tablet. The interface doesn’t change much from the phone, despite the extra screen space. Chrome is slightly better, but doesn’t sync my tabs, etc with Firefox on my laptop.

Bottom line, for its intended use of note taking, the tablet has worked out great. I’m very happy with it, and the other stuff it can do is an added bonus. It is an expensive note taking device, but automatic syncing was a huge win over solutions like the Boogie Board or Livescribe where notes have to be manually downloaded onto the computer.

Experiments with anonymous email

We recently received a letter from a German lawyer alleging a copyright violation. Time to say auf wiedersehen to internet surveillance and censorship! 🙂

Many VPN providers accept payment with bitcoin. Some have zero log retention policies. Current front runner is ironsocket. But they all need an email address. So, how to get a reasonably anonymous email address?

I first tried Hushmail. Free signup, easy. But, I need to login every 3 weeks or my account is suspended, and the only way to get it back is to upgrade and pay $35/year. Too expensive.

Second step was MailFence. They need an existing email to verify my account, but they accepted my hushmail address, and maybe they’d accept a mailinator address. Account is free, doesn’t appear to expire, but doesn’t support POP / IMAP.

How to use it?

I’m wondering how far to go. I could create clean email addresses via tor, pay for a VPN with bitcoin, and in theory, have an untraceable VPN account. However, every time I connect, my originating IP would be visible, and so I’d be easily trackable. Given all of that, maybe a totally clean email address is overkill. There’s also the anonymity of the bitcoins to think about…

Privacy

Impress Remote on OSX

I was looking for ways to control a presentation from an android phone. Turns out LibreOffice has this baked right in, it’s called Impress Remote, it’s free, it’s open source, and (in theory anyway) it’s awesome!

Turns out, LibreOffice 4.1.5.3 would not auto update to 4.2, I had to download version 4.2 manually and install it as normal. Version 4.1.5.3 on OSX wouldn’t work over bluetooth or WiFi. Since upgrading to 4.2 I’m delighted to report that WiFi works. Bluetooth still doesn’t work, but apparently WiFi is faster anyway.

It’s really a smart system. I can see the slides on my phone, there’s an inbuilt timer (although only small letters), and swiping the screen advances the slide (about a second later). Here’s hoping it works for tonight’s presentation on Reputation Coin! 🙂

Small, stacked join / part messages in Colloquy

Colloquy is my IRC client of choice since switching to OSX. In busy channels, my screen can be overrun with messages telling me who joined and left the channel. I wanted, not to hide these, but to make them much smaller, and put them all on one line.

It turns out that it’s possible to modify Colloquy’s appearance with CSS. Awesome, CSS and I are old pals. Took me a while to figure it out, but here’s the code.

.event {
font-size: 0.5em;
float: left;
/*opacity: 0.7;*/
}
.envelope {
clear: both;
}

Open Preferences, then Appearance, then option click Customize Style… and the CSS file will be opened in your editor of choice. Then type /reload style in a channel to see the new style in action. Here’s the obligatory before and after screenshots.

Colloquy_PartJoin_beforeColloquy_PartJoin_after

Super simple git deployments

First time using git to push to a web server. Thanks to this, it works.

Mostly as a record for myself, here’s how I set it up.

Starting on the web server:

mkdir foo
cd foo
chmod g+s .
git init
git config receive.denyCurrentBranch ignore

Then add the following to .git/hooks/post-receive

#!/bin/bash
cd ..
env -i git reset --hard

Now chmod +x .git/hooks/post-receive.

Finally, on my local machine:

git remote add web user@host:/path/to/foo/.git/
git push web master

This works on Ubuntu because the default umask is 0002. Umasks are set per user / process, not on the filesystem, so if you have a umask problem, you’ll have to solve it!

Styling PaperTrail log output

We use papertrail to aggregate log data from our servers. Awesome tool. I wrote a simple GreaseMonkey script which highlights the names of our servers. Very easy to do. Could equally have built it in Stylish, but I already use GM, so that’s how it went. Here’s the code as per a request from Henry.

// ==UserScript==
// @name Papertrail styles
// @namespace http://www.callum-macdonald.com/code/
// @description Add some custom colours to our papertrail output
// @include https://papertrailapp.com/*events*
// @author Callum Macdonald
// @copyright 2012 by Callum Macdonald
// @license GPL v3+
// @version 0.1
// @lastupdated 2012-08-29
// @grant GM_addStyle
// ==/UserScript==

// Simply inject an extra style element
GM_addStyle("\
#event_list li[data-system='foo'] .system a { background-color: red; }\
#event_list li[data-system='bar'] .system a { background-color: blue; }\
#event_list li[data-system='ba1'] .system a { background-color: yellow; }\
#event_list li[data-system='ba2'] .system a { background-color: green; }\
#event_list li[data-system='ba3'] .system a { background-color: purple; }\
");

FindMyCar works

My first mobile app now actually works! At first I had issues because getCurrentPosition doesn’t actually fire up the GPS in PhoneGap, but I switched to using watchPosition instead and that seems to work well enough. It’s crude, but hopefully it’s good enough for my personal use and will save me a little time. Updated info here including a QR code.

cordova add platform android unexpected error

I ran into a strange problem with cordova. When running cordova platform add android I got this error:

[Error: An error occured during creation of android sub-project. An unexpected error occurred: “$ANDROID_BIN” create project –target $TARGET –path “$PROJECT_PATH” –package $PACKAGE –activity $ACTIVITY >&/dev/null exited with 1
Deleting project…]

Turned out, the problem was a space in the name of my app. So I restarted the app and instead of calling it Find My Car I called it FindMyCar and then it worked. Strange but true.

My first Android app

In a little over 3 hours I’ve built my first ever Android app. In fairness, I had already installed the Android SDK previously, so all I did this time was brew install node && npm install cordova and then a bit of farting around to get it working. Eventually, I found cordova run android, which is a big help. Build, install and run the app on an attached phone. Genius.

My next step is to figure out the whole Play Store upload nonsense. I guess I’ll talk to Kasper about that. I might also shoot for the App Store and one or two others also, thanks to the unlimited free open source builds on build.phonegap.com.

It’s called FindMyCar and it has two buttons. Park, and Find. When I park, I hit park, and it remembers where the car is. Then later when I’m lost I hit find and boom, it launches a map / radar / etc with the location of the car. I’ll test it over the coming days. If you’re eager to try it yourself, see code or the apk. Obligatory screenshot:

FindMyCar

Deleting WordPress spam comments in MySQL

Working on a project with more than 200k spam comments in the WP database. Trying to use the “empty spam” button in WordPress just doesn’t work, it deletes a few tens of thousands before hitting the 30 second PHP timeout.

I searched around and found a few suggestions to delete from the wp_comments table. However, that ignores the 3x as many rows in the wp_commentsmeta table if you’re using akismet. This query does the job, although for 200k comments it does take a while!

DELETE c, m FROM wp_comments AS c LEFT JOIN wp_commentmeta AS m ON m.comment_ID = c.comment_ID WHERE c.comment_approved = 'spam';

Mandrill MX: Invalid

I’m experimenting with Mandrill and every domain I’ve added, including some I added months ago, were showing “MX: Invalid”. The MX records were in place, for one domain, they were in place before I added the domain to Mandrill.

When their support helpdesk got back to me, the solution was simple. I had to click the “Test” button next to each domain. What a PITA. I waited a couple of days to click a damn button that I found no reference to in their documentation. Bah humbug.

Oh well, it’s working now. 🙂

Security Update Notifier

A while back I installed apticron to get an email when updates were outstanding on our servers. However, it emails for all updates, and there are updates released every day, which means I get one email per server per day, useless noise that I end up ignoring.

Today I built a solution, security-update-notifier. It’s a very simple (crude!) shell script that can be scheduled with cron to generate an email each day when there are security updates pending. It relies on apt-check, part of the update-notifier package.

We manage our machines with puppet, so I built my first ever public puppet module, a simple wrapper around the script. Tomorrow morning at 4:44am I’ll hopefully get an email for one server. I’ve left one with updates outstanding, one with only non-security updates outstanding, and one up to date, to test each case. Fingers crossed.