Skip to content

Instantly share code, notes, and snippets.

@raychenon
raychenon / Slugify.kt
Last active January 11, 2022 06:26
Slug transforms a raw text (ex: title) into a pretty URL
import java.text.Normalizer
/**
* Extension function
*/
fun String.slugify(): String =
Normalizer
.normalize(this, Normalizer.Form.NFD)
.replace("[^\\w\\s-]".toRegex(), "") // Remove all non-word, non-space or non-dash characters
.replace('-', ' ') // Replace dashes with spaces
package main
import (
"fmt"
"strconv"
"strings"
)
func dec2hex(dec int) string {
color := dec * 255 / 100