Skip to content

Instantly share code, notes, and snippets.

@pete21
pete21 / EnumConverter.kt
Created May 9, 2024 04:49 — forked from nex3z/EnumConverter.kt
Kotlin Enum with Custom Property and Converter
abstract class EnumConverter<in V, E: Enum<E>>(
private val valueMap: Map<V, E>
) {
fun fromValue(value: V): E? = valueMap[value]
fun fromValue(value: V?, default: E): E = valueMap[value] ?: default
}
inline fun <V, reified E: Enum<E>> buildValueMap(keySelector: (E) -> V): Map<V, E> =
enumValues<E>().associateBy(keySelector)
@pete21
pete21 / encrypt_openssl.md
Created July 16, 2019 14:56 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@pete21
pete21 / genetic_function.py
Created October 26, 2018 20:09 — forked from xav-b/genetic_function.py
Genetic optimization of a trading strategy for zipline backtester
import time
import random
import math
import numpy as np
import logbook
log = logbook.Logger('Optimization')
from neuronquant.network.transport import ZMQ_Dealer