Skip to content

Instantly share code, notes, and snippets.

@carolosf
carolosf / example.kt
Last active January 4, 2022 14:58
kotlin jupyter lets plot simple line and bar charts
%useLatestDescriptors
%use lets-plot
%use krangl
val m = mapOf<String,List<Int>>("x" to listOf(1,2,3), "y" to listOf(3,4,3))
val p = letsPlot(m) + theme(axisTitleX="blank")
val plot = p +
geomBar(color="#579673", stat = Stat.identity) {
x = "x"
y = "y"
@carolosf
carolosf / gist:29b83df7658ff560d7d74755a0579906
Created October 15, 2020 17:58
Install Rancher 2 server with helm using own tls certificate in terraform for airgapped installs
resource "kubernetes_namespace" "cattle-system" {
metadata {
name = "cattle-system"
}
}
resource "kubernetes_secret" "tls-ca-additional" {
metadata {
name = "tls-ca-additional"
namespace = kubernetes_namespace.cattle-system.metadata[0].name
@carolosf
carolosf / talib-example.py
Created January 4, 2019 18:06
Example of how to use ta-lib to plot some financial graphs.
#%%
# Made the following example work in python 3
# https://github.com/mellertson/talib-macd-example/blob/master/talib-macd-matplotlib-example.py
#
# To get it working do the following:
# use anaconda 3 https://www.anaconda.com/download/#linux
# if using manjaro linux install TA-lib from the package manager otherwise lookup instructions on how to install TA-lib on your system
# cd ~/anaconda3/bin; ./pip install pandas_datareader
# cd ~/anaconda3/bin; ./pip install TA-Lib
# cd ~/anaconda3/bin; ./pip install https://github.com/matplotlib/mpl_finance/archive/master.zip
@carolosf
carolosf / intro.py
Created December 11, 2018 23:22
Instructions for getting started with jupyter notebooks on python with visual studio code and code samples
# Download Anaconda https://www.anaconda.com/download/
# Anaconda is a standalone python environment that doesn't mess with your system python and comes with useful libraries pre-installed
# execute anaconda
# cd ~/Downloads
# bash Anaconda3-5.3.1-Linux-x86_64.sh
# rm Anaconda3-5.3.1-Linux-x86_64.sh
# download visual studio code and start it up
# go to extensions tab (win linux: ctrl+shift+x)
# search for and download python extension for vscode
# search for and download jupyter extension for vscode
group 'com.example'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
@carolosf
carolosf / dynamicSorting.kt
Last active May 15, 2018 21:45
Sort objects in Kotlin by dynamically sorted field order
data class User(val id: String, val email: String, val title: String)
val sortedById = {u : User -> u.id}
val sortedByEmail = {u : User -> u.email}
val sortOrder = listOf("id", "email")
val transformedSortOrderListToComparable = sortOrder.map {
when (it) {
"id" -> sortedById //Can inline
@carolosf
carolosf / build.gradle
Last active April 24, 2018 16:18
Kotlin 1.2.31 ElasticSearch 6.2.3 Clean Architecture exercise
buildscript {
ext.kotlin_version = '1.2.31'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@carolosf
carolosf / README.md
Created April 4, 2018 20:31
Useful Command Line
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;
public class CreateMonsterRepositorySql implements CreateMonsterRepository {
private final JdbcTemplate jdbcTemplate;
public CreateMonsterRepositorySql(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
@carolosf
carolosf / midi.sh
Created February 24, 2018 18:17
Nice mappings for FL Studio 12 and my M-Audio Axiom air 32 mini
#!/bin/bash
# Nice mappings for FL Studio 12 and my M-Audio Axiom air 32 mini
# aseqdump -l
# aseqdump -p "Axiom A.I.R. Mini32"
# sudo apt install xdotool
aseqdump -p "Axiom A.I.R. Mini32" | \
while IFS=" ," read src ev1 ev2 ch label1 data1 label2 data2 rest; do
#echo "$srsc $ev1 $ev2 $ch $label1 $data1 $label2 $data2 $rest"
case "$ev1 $ev2 $data1 $data2" in
"Control change 17 127" ) xdotool key space ;;