How to define optional methods in Swift protocol?

1. Using default implementations (preferred). protocol MyProtocol { func doSomething() } extension MyProtocol { func doSomething() { /* return a default value or just leave empty */ } } struct MyStruct: MyProtocol { /* no compile error */ } Advantages No Objective-C runtime is involved (well, no explicitly at least). This means you can conform … Read more

What is the difference between ‘SAME’ and ‘VALID’ padding in tf.nn.max_pool of tensorflow?

If you like ascii art: “VALID” = without padding: inputs: 1 2 3 4 5 6 7 8 9 10 11 (12 13) |________________| dropped |_________________| “SAME” = with zero padding: pad| |pad inputs: 0 |1 2 3 4 5 6 7 8 9 10 11 12 13|0 0 |________________| |_________________| |________________| In this example: … Read more

Is functional GUI programming possible? [closed]

The Haskell approach seems to be to just wrap imperative GUI toolkits (such as GTK+ or wxWidgets) and to use “do” blocks to simulate an imperative style That’s not really the “Haskell approach” — that’s just how you bind to imperative GUI toolkits most directly — via an imperative interface. Haskell just happens to have … Read more

href=”tel:” and mobile numbers

When dialing a number within the country you are in, you still need to dial the national trunk number before the rest of the number. For example, in Australia one would dial: 0 – trunk prefix 2 – Area code for New South Wales 6555 – STD code for a specific telephone exchange 1234 – … Read more

JavaScript console.log causes error: “Synchronous XMLHttpRequest on the main thread is deprecated…”

This happened to me when I was being lazy and included a script tag as part of the content that was being returned. As such: Partial HTML Content: <div> SOME CONTENT HERE </div> <script src=”https://stackoverflow.com/scripts/script.js”></script> It appears, at least in my case, that if you return HTML content like that via xhr, you will cause … Read more

How do you attach a new pull request to an existing issue on github?

Adding a pull request to an existing upstream issue is easy assuming you forked using the normal github means. Simply reference the issue in your commit message using any of the supported keywords: close closes closed fix fixes fixed resolve resolves resolved For example: “this commit fixes #116” The text referencing the issue does not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)