Skip to content

Instantly share code, notes, and snippets.

View sklinkert's full-sized avatar

Simon Klinkert sklinkert

View GitHub Profile
@sklinkert
sklinkert / logrotate-ghost.sh
Created December 19, 2021 17:25
Logrotate for Ghost CMS
$ /etc/logrotate.d/ghost:
/var/www/ghost/content/logs/*.log {
weekly
rotate 12
compress
copytruncate
}
@sklinkert
sklinkert / .go
Last active January 29, 2021 20:08
German numbers (format numbers properly)
package main
import (
"fmt"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
func germanNumber(n float64) string {
p := message.NewPrinter(language.German)
@sklinkert
sklinkert / build.gradle.kts
Created September 30, 2020 09:06
PlantUML with Gradle (Kotlin, .kts)
plugins {
id("com.cosminpolifronie.gradle.plantuml") version "1.6.0"
}
// ...
configure<com.cosminpolifronie.gradle.plantuml.PlantUmlPluginExtension> {
receivedRenders.add(
com.cosminpolifronie.gradle.plantuml.PlantUmlReceivedRender(
@sklinkert
sklinkert / mail.go
Created May 5, 2020 22:25
Guess firstname and lastname from mail address
// guessNameFromMail - Examples:
// warren.buffett@gmail.com -> Warren Buffett
// warren-buffett@gmail.com -> Warren Buffett
// warren_buffett@gmail.com -> Warren Buffett
// w-buffett123@gmail.com -> W. Buffett
func guessNameFromMail(mail string) (firstname, lastname string) {
re := regexp.MustCompile(`^([A-Za-z]+)[\-\.\_]([A-Za-z]+)[0-9]*@`)
matches := re.FindAllStringSubmatch(mail, -1)
if len(matches) == 1 && len(matches[0]) == 3 {
firstname := strings.Title(matches[0][1])