This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pairup a seq | |
// [email protected] | |
object Pairup | |
{ | |
def main(args: Array[String]): Unit = | |
{ | |
println("hello") | |
val a = List(1, 2, 3, 4, 5, 6) //even | |
val b = pairup(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
translate from Scala by [email protected] | |
http://vkostyukov.ru/posts/combinatorial-algorithms-in-scala/ | |
*/ | |
extension Collection | |
{ | |
func combinations(_ n: Int) -> [[Element]] | |
{ | |
guard self.count > 0 else {return [[Element]]()} | |
guard n <= self.count else {return [[Element]]()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// approximate the fraction of a real | |
// Created by psksvp on 22/7/20. | |
print(approximateFraction(0.5)) | |
print(approximateFraction(0.5454)) | |
print(approximateFraction(0.75)) | |
print(approximateFraction(0.333333)) | |
print(approximateFraction(0.888888888888)) | |
print(approximateFraction(0.0123456789)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I put in the make file from https://stackoverflow.com/questions/33370175/how-do-i-completely-rename-an-xcode-project-i-e-inclusive-of-folders | |
It was originally written by https://stackoverflow.com/users/7641654/pietro-basso | |
__USE AT YOUR OWN RISK, ALWAYS BACK UP before doing this. You must read the post before using this.__ | |
The makefile needs `ack` and `rename` which can be install with `brew install ack rename` | |
put this file the project directory then run `make -f renameXcode.makefile OLD_NAME="oldname" NEW_NAME="newname"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension String | |
{ | |
func intIndex(of s: String) -> Int? | |
{ | |
if let r = self.range(of: s) | |
{ | |
return self.distance(from: self.startIndex, to: r.lowerBound) | |
} | |
else | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open the file */etc/default/grub* with a text editor with sudo | |
change the line | |
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" | |
to | |
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor" | |
saved, then run |