KISS

Keep It Simple Stupid

Playing any video from firefox with mpv and youtube-dl

| comments

Modern browsers are very complicated programs, especially because they also need to be secure to protect users from countless threats on the interwebs. That means that the plugins functionality is necessarily quite limited. Firefox used to have XUL extensions, allowing to have the powerful vimperator; but from Firefox 57, only WebExtensions API is supported. There is a replacement for vimperator written with the WebExtensions API: tridactyl, however it’s more limited.

Lots of websites now provide video content. But sometimes videos have ads, sometimes the player’s interface is inconvenient, or the video is blocked on the page even though it can be loaded if you know the link. youtube-dl is an amazing program that can download videos from dozens of websites. How do you make it work with your current tab in Firefox?

Result builder example for validation in swift

| comments

My recent (2020?!) post introduced an idea for lightweight validation in swift that can gather all the errors that failed the validation.

This post is a continuation where I implement a result builder for this validation so that it would look a bit cleaner:

1
2
3
4
all {
    foo == bar <?> "Incompatible operations"
    baz == 42 <?> "Unexpected baz"
}

How to save and restore application data on iOS Simulator quickly

| comments

I had a post a long time ago describing the usage of directory hardlinks in order to easily access, backup and restore the container of your application on the iOS Simulator: Persistent application container directories in iOS Simulator. Obviously now it’s an APFS era (enforced by apple) and I’m not sure if it has directory hardlinks anymore. So I have another, simpler way to backup app containers.

git hook to insert ticket number

| comments

Updated on 2021-06-02: An extended version of the script is described here: Checkout PR script.

We have a rule on the project where every commit (and PR) should include the ticket number that it’s related to; by convention, it goes at the beginning of the commit message’s title, e.g. “US123: Display relative date when it’s closer than one day”. The rule also extends to the branch name, e.g. userStory/US123_display_relative_date. This makes it convenient to automate the insertion of the ticket number into the commit message, which is possible to do locally using git hooks.

Cannot type password on the screensaver screen in OS X 10.14

| comments

A small note about an annoying bug I encountered about a year ago.

I think this was new to OS X 10.14. When I locked the screen (using Caps Lock+S that ran a service to launch screen saver from the command line, where Caps Lock is mapped to Cmd+Ctrl+Opt+Shift with Karabiner-Elements; yes, it’s that complicated on OSX, there is no system shortcut to launch screen saver) and sometimes the password field couldn’t be focused, I couldn’t type anything. No key combinations or hot corners worked. The mouse cursor flickered when I moved it, it wanted to hide all the time, but moving made it visible. And this happened pretty often, a couple times a week on average.

It might have been an issue with XScreensavers; I didn’t use other screensavers at the time, so I don’t know if they had the same issue.

Removing ClearcutUploader errors when using GMaps iOS SDK

| comments

I worked on an iOS application that used the Google Maps SDK and noticed a bunch of logging when I backgrounded the application complaining that it couldn’t connect to some server:

1
2
3
4
5
6
7
8
9
2021-04-17 00:42:48.543716+0300 MyApp[73170:12130630] [connection] nw_socket_connect [C7.1:3] connect failed (fd 23) [64: Host is down]
2021-04-17 00:42:48.543851+0300 MyApp[73170:12130630] [] nw_socket_connect connect failed [64: Host is down]
2021-04-17 00:42:48.545236+0300 MyApp[73170:12130630] Connection 7: received failure notification
2021-04-17 00:42:48.545564+0300 MyApp[73170:12130630] Connection 7: failed to connect 1:64, reason -1
2021-04-17 00:42:48.545708+0300 MyApp[73170:12130630] Connection 7: encountered error(1:64)
2021-04-17 00:42:48.548091+0300 MyApp[73170:12130630] Task <170493E8-F704-4578-AB47-7B9CE76064B1>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:64])
2021-04-17 00:42:48.951902+0300 MyApp[73170:12128623] Task <170493E8-F704-4578-AB47-7B9CE76064B1>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=64, NSUnderlyingError=0x600003ccb360 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=64, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <170493E8-F704-4578-AB47-7B9CE76064B1>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <170493E8-F704-4578-AB47-7B9CE76064B1>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://play.googleapis.com/log/batch, NSErrorFailingURLKey=https://play.googleapis.com/log/batch, _kCFStreamErrorDomainKey=1}

And this is just one instance of it; typically it would be repeated a dozen times.

/sdcard “Permission denied” on Android

| comments

I’ve found some old notes about rooting a Motorola G4 Android phone and a puzzling issue I stumbled upon then. It may be useful to someone even though I couldn’t reproduce it now and don’t remember all the details.

I had a Moto G4 phone and it’s possible to officially unlock its bootloader in order to root it, remove some preinstalled (goog’s) crap and possibly install another firmware (Android is notoriously bad with software updates, Motorola was not very bad, they had occasional security updates). I followed one of the unlocking and rooting guides online: backed up as much stuff as I could (which is not much on a non-rooted phone), unlocked the bootloader by getting a code from Motorola, replaced the boot image, flashed TWRP, installed SuperSU, and replaced the kernel with ElementalX G4 because something didn’t work with the stock one.

Then I installed ABBYY Lingvo in the new system, but it was crashing on startup. I discovered that its directory on the internal storage (which I believe was in /sdcard/Android/) was empty and was trying to adb push it from the backup, but got “permission denied”. In fact, I couldn’t create any directory on /sdcard/. The permissions and owner on the directory were correct. Searching online didn’t find a solution, I tried a number of things, even editing platform.xml to change a setting. However when I booted into TWRP, I could write files to SD card fine.