See it in action at bl.ocks.org.
This file contains hidden or 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
| class Primes extends Iterable[Int] { | |
| import scala.collection.mutable.ListBuffer | |
| var primes = ListBuffer[Int]() | |
| var ints = Iterator.from(2) | |
| def iterator = new Iterator[Int] { | |
| def hasNext = true | |
| def next:Int = { | |
| ints.dropWhile(n => primes.exists(n % _ == 0)) | |
| primes += ints.next | |
| primes.last |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # quickly toggle between brightness levels | |
| # put this in your path and run it using a gnome keyboard shortcut | |
| # i have it bound to Ctrl-F5 | |
| import dbus | |
| bus=dbus.SessionBus() | |
| proxy=bus.get_object('org.gnome.PowerManager','/org/gnome/PowerManager/Backlight') | |
| cl = int(proxy.GetBrightness(dbus_interface='org.gnome.PowerManager.Backlight')) | |
| if cl < 20: |
NewerOlder