Passing optional callback into Swift function

Update for Swift 3/4: An optional is no longer a boolean expression, and the deprecated func dismissModalViewControllerAnimated(animated: Bool) is no longer available in Swift. Simply declare the completion parameter as an optional closure, and pass it on to func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) which takes an optional closure as well: … Read more

Function to remove accents in postgreSQL [duplicate]

Use the unaccent module that ships with PostgreSQL. somedb=# CREATE EXTENSION unaccent; CREATE EXTENSION somedb=# SELECT unaccent(‘Hôtel’); unaccent ———- Hotel somedb=# SELECT * FROM table WHERE lower(unaccent(table.id)) = lower(‘Jose’); And speed things up a bit by generating an accentless, lower-cased index: somedb=# CREATE INDEX CONCURRENTLY ON table (lower(unaccent(id)));

Good explanation of “Combinators” (For non mathematicians)

Unless you’re deeply into theory, you can regard the Y combinator as a neat trick with functions, like monads. Monads allow you to chain actions, the Y combinator allows you to define self-recursive functions. Python has built-in support for self-recursive functions, so you can define them without Y: > def fun(): > print “bla” > … Read more

How to pass variable length arguments as arguments on another function in Golang?

Ah found it…functions that accept variable length arguments are called Variadic Functions. Example: package main import “fmt” func MyPrint(format string, args …interface{}) { fmt.Printf(“[MY PREFIX] ” + format, args…) } func main() { MyPrint(“yay %d %d\n”,123,234); MyPrint(“yay %d\n “,123); MyPrint(“yay %d\n”); }

Call a function in another script when executing using ‘Run With PowerShell’

In the worker file change to this: . “c:\scratch\b.ps1” ShowMessage “Hello” As @RoiDanton mentioned below: Attention when using relative pathing: Don’t forget to prepend a dot before the path . “.\b.ps1”. The first dot is an operator used to modify the scope and in that context it has nothing to do with paths. See Dot … Read more

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