Monday 24 February 2020

dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib

Trying to run an older version of PHP via homebrew for development of an old codebase I get an error that libcrypto.1.0.0 is not found:

/usr/local/Cellar/php@5.6/5.6.40/bin/php -v
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /usr/local/Cellar/php@5.6/5.6.40/bin/php
  Reason: image not found
zsh: abort      /usr/local/Cellar/php@5.6/5.6.40/bin/php -v

Easily sorted by installing an appropriate libcrypto like so:
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

And it's working!
/usr/local/Cellar/php@5.6/5.6.40/bin/php -v
PHP 5.6.40 (cli) (built: Apr 23 2019 11:14:34)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Friday 4 January 2019

Unix Timestamp Tool

My top googled search terms are probably 'unix timestamp' or 'unix timestamp converter'.  Because I work a lot with time series data that is stored in integer timestamp format, I'm always using one of a couple of online tools for converting those timestamps back to a human readable form or going the other way, getting a timestamp from a date.

I get frustrated with these tools as they don't do what I want and most times I need to manipulate the timestamp further to get the timestamp of the start of an hour or minute interval so I decided to create my own tool - unixtime.ninja

I now keep my unixtime.ninja window almost permanently for converting my timestamps 😀

Monday 20 August 2018

Mac OS X High Sierra: Bluetooth Not Available

Last year my MacBook Pro developed an issue where the internal keyboard / trackpad would become intermittent.  You could get it to work if you pressed a certain place on the bottom panel.

It was under warranty so eventually I sent it in to Apple to get repaired, they replaced the 'top board' and while they were at it they replaced the screen because some of the anti-glare coating had rubbed off in places.

Since it came back I had an issue where Bluetooth will just stop working, sometimes at random times, mostly about a minute after waking from sleep.  Some say it's a software issue, I diagnose a hardware issue - the Broadcom bluetooth adapter (presented as a USB device) just disappears from the device list.  My theory is that during the first repair it may not have been reseated in the socket securely.

So I got myself a £5 toolkit from eBay that includes the 'pentalobe' (that's a star to you and me) driver I needed to open the case, got it open, identified the Bluetooth / WLAN card, pulled it out, cleaned the contacts and put the whole thing back together again.

So far so good.  I've been able to walk away and wake up my MacBook from sleep a long while later by wiggling the Magic Mouse, something I've not been able to do for months. 😀😀😀

Thursday 27 July 2017

How Big is 'At Scale'?

I see the term 'at scale' being used a lot on tech/engineering blogs - "You need to do it like this when you run your app at scale", "We had to do this to make it work at scale" etc etc.

But what exactly determines that I am doing something at scale?

How do you quantify that?  There's no SI unit for scale like the 'Double Decker Bus' or the 'Olympic Swimming Pool'.  I like to think that if my systems break either due to the amount of traffic they're being asked to handle or the amount of data I've asked them to query then I'm probably running my systems 'at scale'.

Today I read the excellent ebook Scaling PHP Applications.  The blurb on the website makes the proud claim "Scale PHP 5.6 (and 7), nginx, haproxy, MySQL 5.6, Redis, and Memcache to 10K req/second".

That sounds like an upper limit for 'at scale' - 10,000 requests per second.

I'm sure I've seen my systems consistently handle more than 10k req/s.  Sure enough, my monitoring graphs are showing peak HTTP traffic of 25k req/s - that's 2.5x 'at scale'.  I call this 2.5 Xscale.

Taking a function of the number of requests handled and the service uptime, I got some stats from my system:

nginx - 14,227 req/s (1.4 Xscale)
php-fpm - 10,999 req/s (1.09 Xscale)
memcached - 93,221 cmd/s (9.3 Xscale)

Thursday 29 June 2017

Apple Magic Keyboard 2 on Linux

Annoyingly, the Apple Magic Keyboard 2 is only recognised as a generic Bluetooth hid keyboard so the Fn and shortcut keys don't work correctly (using hid-generic kernel module).

I've started work on a set of patches for the hid-apple kernel module to add support for this keyboard.

Using Wireshark to sniff the Bluetooth packets, I've found the following are emitted as Fn KeyDown and KeyUp events:

Fn KeyDown: a1 01 00 00 00 00 00 00 00 00 02
Fn KeyUp:   a1 01 00 00 00 00 00 00 00 00 00

I'm going to attempt to add these as a customisation in the hid-apple module and see how I get on.

Monday 2 January 2017

External USB Audio on Raspberry Pi 3

The rpi3 could see the USB audio device but not be able to enable it. The following errors were observed in dmesg:

[    4.214503] snd_bcm2835: unknown parameter 'index' ignored
[    4.470103] snd-usb-audio 1-1.2:1.0: cannot find the slot for index 0 (range 0-0), error: -16
[    4.470134] usb 1-1.2: cannot create card instance 0
[    4.470164] snd-usb-audio: probe of 1-1.2:1.0 failed with error -16
[    4.470823] usbcore: registered new interface driver snd-usb-audio

It looks like a conflict with the card index of the internal sound codec. Because I don't want to use the interval sound codec I just blacklisted the module to prevent it from loading by adding:

blacklist snd_bcm2835

To the configuration file /etc/modprobe.d/rpi-blacklist.conf