Skip to content

Instantly share code, notes, and snippets.

@mskoroglu
mskoroglu / LocaleSortingExtensions.kt
Last active July 6, 2022 09:34
Kotlin extension functions for sorting by locale(lang, country)
// Example: cities.sortedWithLocaleBy(Locale("tr")) { it.name }
inline fun <T, R : Comparable<R>> Iterable<T>.sortedWithLocaleBy(
locale: java.util.Locale,
crossinline selector: (T) -> R?
) = sortedWith(compareBy(java.text.Collator.getInstance(locale), selector))
// Example: cities.sortedWithLocaleByDescending(Locale("tr")) { it.name }
inline fun <T, R : Comparable<R>> Iterable<T>.sortedWithLocaleByDescending(
locale: java.util.Locale,
crossinline selector: (T) -> R?
@TYsewyn
TYsewyn / index.html
Created January 27, 2018 15:46
Visualizing your Spring Integration Components & Flows
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Visualizing your Spring Integration Components &amp; Flows</title>
<script type="text/javascript" src="http://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript" src="http://d3js.org/d3-selection-multi.v1.min.js"></script>
<style>
@elktros
elktros / lcdPi.py
Created August 31, 2017 08:47
Interfacing 16x2 LCD with Raspberry Pi
#!/usr/bin/env python
import RPi.GPIO as GPIO
from time import sleep
# Define GPIO to LCD mapping
LCD_RS = 7
LCD_E = 8
LCD_D4 = 25
LCD_D5 = 24
LCD_D6 = 23
@magnetikonline
magnetikonline / README.md
Last active June 22, 2024 13:35
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
#
# Mar 2013 Yad Smood
# VCS
YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 28, 2024 21:36
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname