Skip to content

Instantly share code, notes, and snippets.

/*
* This is an example of making a CSS animated color property for
* the theme-switch component (https://github.com/mahozad/theme-switch).
* This gist is referenced in the documentation of the component.
* Currently, only Chromium-based browsers (Chrome, Opera, Edge, etc.) support this.
* See https://stackoverflow.com/a/63848864 for more information.
* For a real-world example, see https://mahozad.ir/android-pie-chart/
* and its source code on https://github.com/mahozad/android-pie-chart/blob/website/docs/styles.css
*/
@mahozad
mahozad / scraper.main.kts
Last active December 3, 2021 12:46
A Kotlin script to scrape a phrase from a dynamic page using Selenium and jsoup (mentioned in a Stack Overflow post)
#!/usr/bin/env kotlin
/**
* A Kotlin script for extracting (scraping) a phrase from a dynamic page.
* NOTE: Download and place the executable [Chrome driver](https://chromedriver.storage.googleapis.com/index.html) beside this script.
* See [this stackoverflow post](https://stackoverflow.com/a/69974518/8583692) for more information.
* Alternatively, use the [WebDriverManager](https://github.com/bonigarcia/webdrivermanager) library.
*/
@file:JvmName("Scraper")
@mahozad
mahozad / hello.main.kts
Last active November 30, 2021 09:31
Kotlin script hello world example. Can be run from the command line with `kotlin hello.main.kts` command. Ensure Kotlin compiler is installed on your machine and is added to the PATH. You can also run the script with `hello.main.kts` command on Linux given Kotlin is available in /usr/bin/env/.
#!/usr/bin/env kotlin
println("Hello World!")
@mahozad
mahozad / NumberUtilsFix.java
Last active March 27, 2020 12:19
The fix for the bug in NumberUtils class in Thymeleaf
private static DecimalFormatSymbols computeDecimalFormatSymbols(
final NumberPointType decimalPointType, final NumberPointType thousandsPointType, final Locale locale) {
Validate.notNull(decimalPointType, "Decimal point type cannot be null");
Validate.notNull(thousandsPointType, "Thousands point type cannot be null");
Validate.notNull(locale, "Locale cannot be null");
final DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
switch (decimalPointType) {