Journal

2018-12-29 Firefox extensions I can not live without

My current list of Firefox extensions on my Mac is as follows:

  • Dark Reader
  • Disable WebRTC
  • I don't care about cookies
  • uBlock Origin

And finally to fit things in perfectly, put this bit in your userChrome.css to move the tabbar close button to the left:

    .tabbrowser-tab:not([pinned]) .tab-close-button {
        -moz-box-ordinal-group: 0 !important;
        -moz-margin-start:-4px !important;
        -moz-margin-end:4px !important;
    }

You could use the Shadowfox style for a darker user interface. And furthermore, if you run your OS in dark mode, then Firefox will follow this reasonably well. However as of 2019-09-02 there are still things left to be desired; upon opening a new tab, it sometimes flashes white. To fix this:

  • Go to "about: config" and set browser.display.background_color to #000000
  • Add the following lines to your userChrome.css file:
  #browser vbox#appcontent tabbrowser, #content, #tabbrowser-tabpanels, 
  browser[type=content-primary],browser[type=content] > html {
      background: #1D1B19 !important
  }

Note that userChrome.css might soon be ignored and you'll need to enable it manually.

Source: https://fedidat.com/640-dark-newtab-firefox/

2018-08-27 Two useful Xcode shortcut keys

I found out about two extremely useful Xcode shortcut keys: Ctrl+Cmd+[ or ] to cycle through the active target, and Ctrl+Option+Cmd+[ or ] to cycle through devices.

2018-05-15 Non-existing dates

One William Woodruff wrote a blog entry in 2015 about non-existing dates: https://blog.yossarian.net/2015/06/09/Dates-That-Dont-Exist

I'm sad to say that Foundation allows you to construct these supposedly illegal Gregorian dates :(

    import Foundation
    var dateComponents = DateComponents()
    dateComponents.day = 6
    dateComponents.month = 10
    dateComponents.year = 1582
    dateComponents.timeZone = TimeZone(abbreviation: "UTC")
    if let date = Calendar(identifier: .gregorian).date(from: dateComponents) {
        print(date)
    } else {
        print("Not a date")
    }

The above Swift code can be pasted into a playground. Supposedly, it shouldn't print the date but it does. This is a pretty obscure corner case of course.

2018-03-16 overview of font sizes when using Dynamic Type

If you want to support Dynamic Type in your iOS app, and I think you should, then one possible route is to roughly map the built-in text styles to the point sizes that your design specifies. The following page on the Apple website lists all text styles along with their point size:

https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/

2018-01-11 Navigationbar below statusbar on iOS 10

I had the strangest issue today. When testing my current app on iOS 10, the navigation bar would sit below the status bar. In other words, the navigation bar would be 44 pixels high, instead of 64 pixels. On iOS 11, this issue wasn't present.

This happened because our app does not use storyboards, and we used the following AppDelegate.swift:

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
        var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            let mainViewController = ViewController()
            let navigationController = UINavigationController(rootViewController: mainViewController)
            self.window?.rootViewController = navigationController
            self.window?.makeKeyAndVisible()
            
            return true
        }
    }

The problem is, that the window property is initialized too early. Moving it to didFinishLaunching fixes the problem:

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
        var window: UIWindow?
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            self.window = UIWindow(frame: UIScreen.main.bounds)
            let mainViewController = ViewController()
            let navigationController = UINavigationController(rootViewController: mainViewController)
            self.window?.rootViewController = navigationController
            self.window?.makeKeyAndVisible()
            
            return true
        }
    }

More...