Skip to content

Instantly share code, notes, and snippets.

@diewland
Created May 5, 2021 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diewland/f58313e566b36609de02536d83c1314d to your computer and use it in GitHub Desktop.
Save diewland/f58313e566b36609de02536d83c1314d to your computer and use it in GitHub Desktop.
Sleep in 8-bit style
fun sleep8bit (second: Int, width: Int=10, callback: (String)->Unit) {
val d = (second * 1000 / width ).toLong()
(1..width).forEach {
Thread.sleep(d)
val progress = "[${"#".repeat(it)}${" ".repeat(width-it)}]"
callback(progress)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment