I have an external drive attached to the USB hub on my Thunderbolt Display that I use to clone my laptop's internal drive every night using the schedule feature of SuperDuper!. At the appointed time, SuperDuper! will mount the external drive, clone the internal drive and then unmount the external drive again which is very convenient. However, whenever I plug in my laptop, the drive automatically mounts. This doesn't particularly worry me, but when I… continue reading.
I've recently merged a PR by Stephen to rst2df that reformats the entire codebase to align with PEP 8. As rst2pdf is over a decade old, this has resulted in a lot of changes to the files which now have Stephen's name attached. This affects git blame. For example: git blame -L 137,145 rst2pdf/findfonts.py e753c71eb (roberto.alsina 2008-09-05 14:49:24 +0000 137) d56705e4f (roberto.alsina 2009-10-30 15:07:05 +0000 138) # So now we have a font we know… continue reading.
I recently received a MySQL dump file where the various tables in it had foreign keys to each other. I usually restore with this command: mysql –login-path=rob < dump.sql but this generated the error: ERROR 1217 (23000) at line 288805: Cannot delete or update a parent row: a foreign key constraint fails It turns out that the easiest way to solve this is to use the –init-command switch to set foreign keys off for this… continue reading.
I have a handy bash script that transcodes videos using Don Meton's video_transcoding tools. This script was written in a hurry and one limitation it had was that it re-transcoded any source file even if the output file already existed. The script looked like this:
for file in "$source_dir"/*.mkv; do
./transcode.sh "$file" "$output_dir"
What it should do is only run transcode.sh if the output file doesn't exist, so I updated it. Parameter expansion to the rescue! I needed to extract the base… continue reading.
When working on test code on my computer, I usually use the built-in PHP server (php -S) which works nicely. Every so often, I need access to MySQL and I use Docker to temporarily create a MySQL server for me. This is how I do it. The magic command is:
$ docker run --name mysql \
-e MYSQL_USER=rob -e MYSQL_PASSWORD=123456 -e MYSQL_DATABASE=bookshelf \
-p 3306:3306 -d mysql/mysql-server:5.7
This creates a Docker container called "mysql" on port 3306. We pass three environment variables: MYSQL_USER, MYSQL_PASSWORD & MYSQL_DATABASE which are our credentials and… continue reading.
We now have 4 Amazon Echo devices in the house, and, inspired by a demo LornaJane gave me at DPC, I have decided to write some skills for it. This article covers what I learnt in order to get my first Swift skill working. Our bins are collected by the council every other week; one week it's the green recycling bin and the other week, it's the black waste bin. Rather than looking it up,… continue reading.
This too me longer to find than it should have done, so I'm writing it here for future me. When you install CouchDB, it is in a mode where anyone can do anything with the database including creating and deleting databases. This is called "Admin Party" mode which is a pretty cool name, but not what I want. Creating admin users To create a user in 1.6 (I've not used 2.0 yet, but assuming it's… continue reading.
I recently had some trouble with verifying an SSL in PHP on a client's server that I couldn't reproduce anywhere else. It eventually turned out that the client's IT department was presenting a different SSL certificate to the one served by the website. To help me diagnose this, I used this command line script to display the SSL certificate: getcert.sh
echo | openssl s_client -showcerts -servername !$ -connect $1:443 2>/dev/null \
| openssl x509 -inform pem -noout -text
Running it against mozilla.org, the start looks like this:
$ getcert mozilla.org
Version: 3 (0x2)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert High Assurance EV CA-1
Not Before: Nov 24 00:00:00 2015 GMT
Not After : Dec 29 12:00:00 2016 GMT
Subject: businessCategory=Private Organization/188.8.131.52.4.1.3184.108.40.206.3=US/220.127.116.11.4.1.318.104.22.168.2=California/serialNumber=C2543436/street=650 Castro St Ste 300/postalCode=94041, C=US, ST=California, L=Mountain View, O=Mozilla Foundation, CN=www.mozilla.org
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (2048 bit)
Modulus (2048 bit):
In my case, I… continue reading.
I recently discovered the -i switch to curl! I have no idea why I didn't know about this before… Curl is one of those tools that every developer should know. It's universal and tends to be available everywhere. When developing APIs, I prefer to use curl to view the output of a request like this:
$ curl -v -H "Accept: application/json" https://api.joind.in/
* Trying 22.214.171.124...
* Connected to api.joind.in (126.96.36.199) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: api.joind.in
* Server certificate: Gandi Standard SSL CA 2
* Server certificate: USERTrust RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET / HTTP/1.1
> Host: api.joind.in
> User-Agent: curl/7.43.0
> Accept: application/json
< HTTP/1.1 200 OK
< Date: Sun, 15 May 2016 11:05:27 GMT
< Server: Apache
< X-Powered-By: PHP/5.6.4
< Access-Control-Allow-Origin: *
< Content-Length: 363
< Content-Type: application/json; charset=utf8
* Connection #0 to host api.joind.in left intact
-v is for verbose and so you get told all the information you could possibly want. However, usually, I… continue reading.
The Swift application that I'm currently developing gets data from Twitter and I was struggling to get a valid auth token. To solve this, I wanted to see exactly what I was sending to Twitter and so opened up Charles on my Mac to have a look. As my application is running within a Vagrant box running Ubuntu Linux, I needed to tell it to proxy all requests through Charles. To do this, you set… continue reading.