Caller info attributes in F# with currying

How to use CallerMemberName, CallerFilePath and CallerLineNumber in F# together with currying. Solution Let’s start with a solution. Instead of a module with functions we declare a class with static methods: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 type Mod() = static member noArg ( [<CallerLineNumber; Optional; DefaultParameterValue(0)>] line : int ) : string = sprintf "Line %d" line static member oneArg ( x : string, [<CallerLineNumber; Optional; DefaultParameterValue(0)>] line : int ) : string = sprintf "Line %d; input %s" line x static member twoArgs ( x : string, [<CallerLineNumber; Optional; DefaultParameterValue(0)>] line : int ) : string -> string = fun y -> sprintf "Line %d; inputs %s, %s" line x y static member threeArgs ( x : string, [<CallerLineNumber; Optional; DefaultParameterValue(0)>] line : int ) : string -> string -> string = fun y z -> sprintf "Line %d, inputs %s, %s, %s" line x y z Hopefully it’s obvious how to create functions which take more arguments.

Programmatically clean up tabs in Firefox

How to use Firefox API for extensions to find and close unwanted tabs. Tabs in Firefox can be manipulated via browser.tabs collection. This collection is available only for extensions. So open about:debugging choose This Firefox and from the list of extensions Inspect one which has permission tabs. I chose uBlock Origin ad blocker since it needs lots of permissions, so I assumed it has tabs permission. Saving open tabs into a variable First we save a list of open tabs into a variable tabs:

Writing high-performance code for JVM in Kotlin

Writing low latency, high througput, garbage-free system? Kotlin is an excellent choice. Inline functions Guaranteed inlining is Kotlin’s major advantage over Java when writing high-performance code: Generic inline functions specialize for primitive types so boxing is avoided. Lambdas given to inline functions are inlined as well so they’re not allocated on the heap. Inlining of lambdas has another interesting consequence: return used inside lambda is inlined as well so it will return from the enclosing function.

Rules for shuffling in Spark SQL

Make your Spark jobs reliable and fast — use shuffle correctly. Avoid shuffle Moving data between cluster nodes is very expensive. So try to reduce number of shuffles to minimum. Eg. in some cases sort-merge join can be replaced by broadcast join. If the data you want to join are too big for single broadcast join (the limit for single broadcast join is 8 GB) you can use several consecutive broadcast joins.

Swift 4: the Good, the Bad and the Lame

How does Swift 4 stand against other popular languages? Should you use Kotlin or F# instead? Good: Retroactive modeling Very nice feature of Swift is that you can make a type to conform to a protocol even if you don’t have access to the source code of the type. This is not possible with interfaces in Kotlin or F#. Good: Tuples with named fields Another very good thing about Swift is the possibility to name fields of tuples.