[email protected]:~$

  • Smart Image Resizing Using Seam Carving

    Seam carving is a fascinating technique to scale up/down an image. Demo This was a web-service. [dead!] http://seam.ashishchaudhary.in:8080/ The code is available at: tocttou/smartresizing Overview of the application (kotlin): https://i.imgur.com/DJv24cT.png The algorithm implementation is available directly at: SeamCarver.kt Results Results are fascinating (mostly). Reduction Expansion Reduction and Expansion Implementation Calculate...

  • Better Error Handling In Kotlin With Either Type

    Here is a nice experiment (borrowed from FP languages). Define the Either type: 1 2 3 4 sealed class Either<out T> { data class Error(val message: String?, val e: Exception) : Either<Nothing>() data class Success<T>(val value: T) : Either<T>() } Any computation that has the potential of erroring out can...

  • Implementing C-Style For-Loops In Kotlin

    Kotlin does not have C-style for-loops. This is fine because I prefer using the idiomatic for-loops (built to use iterators) anyway. But there is a problem: Kotlin does not allow dynamic limiting conditions in its for-loops (discussion).You have to use a while loop to achieve the same functionality. It can...

  • Extending An Object's API With Delegation In Kotlin

    Task: Expose extra API methods for an object. Methods: Derive a new class from the class of that object, implement the extra functionality, make a new object from that new class. This method is suitable in cases where the new class has an “is-a” relationship with the actual class. In...

  • Making Suspend Work On Lenovo Z510

    Suspend never worked with Linux on my Lenovo Z510. Recently I came across this issue while looking for a fix (I use NVIDIA Prime, not Bumbleebee). Suspend now works on my laptop by doing: sudo vim /etc/default/grub Replace GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" with GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=\"!Windows 2013\" acpi_osi=Linux" sudo update-grub Reboot.