vankuik.nl

Last edit

Added:

> [[Weblog_entries_2017]]


Latest weblog entries

2019-07-15 Generic parameter subject could not be inferred

In a condensed form, I had the following SwiftUI code:

    struct Input {
        var someString = "OH HAI"
    }
    struct ContentView : View {
        @State private var input = Input()
        
        var body: some View {
            TextField("Enter string", text: $input.someString)
                .textFieldStyle(.roundedBorder)
                .padding()
        }
    }

Then I changed someString to a computed property:

    struct Input {
        var someString: String {
            return "OH HAI"
        }
    }

This results in the following error: "Generic parameter 'Subject' could not be inferred". It took me ten minutes to realize what was the problem: I forgot to add a setter.

2019-04-23 ISO date on macOS

To print the current date in ISO 8601 format on macOS:

  $ date +%Y-%m-%dT%H:%M:%S
  2019-04-23T14:44:46

To print it with the timezone information, append %z.

  $ date +%Y-%m-%dT%H:%M:%S%z
  2019-04-23T14:44:42+0200

Note that in the last case, you're missing the colon in the timezone bit. To correct this, we'll need to do some bash wizardry:

  $ zone=$(date +%z);datetime=$(date +%Y-%m-%dT%H:%M:%S); echo $datetime${zone:0:3}:${zone:3:2}
  2019-04-23T14:44:42+02:00

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

Plus I use the Shadowfox to style Firefox a bit more to the liking of macOS Mojave's Dark theme.

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

  @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
  @-moz-document url(chrome://browser/content/browser.xul){
	  #TabsToolbar #tabbrowser-tabs .tabbrowser-tab:not([pinned]) .tab-close-button {
		-moz-box-ordinal-group: 0 !important;
		-moz-margin-start:-4px !important;
		-moz-margin-end:4px !important;
	  }
  }

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.

More...

Weblog Archive

Weblog entries 2017

Weblog entries 2016

Weblog entries 2015

Weblog entries 2014

Weblog entries 2013

Weblog entries 2012

Weblog entries 2011

Weblog entries 2010

Weblog entries 2009

Weblog entries 2008

Weblog entries 2007

Weblog entries 2006

Weblog entries 2005

Weblog entries 2004

All weblog entries

Articles

Articles, chronologically (latest first). This is pretty old stuff.

Scribblings

Not yet finished. Maybe will never be finished. Maybe they'll get deleted. Who knows?

Programming:

System administration:

Others:

Files: