Skip to content

Instantly share code, notes, and snippets.

Avatar

Ondrej Zizka OndraZizka

View GitHub Profile
@OndraZizka
OndraZizka / parseCommaDelimitedMap.kt
Created Jul 8, 2020
Parser - Map from comma separated pairs, in Kotlin
View parseCommaDelimitedMap.kt
fun parseCommaDelimitedMap(str: String): Map<String, String> {
if (str == null) return null
val pairs = str.split(',').map { it.trim() }.filter { it.contains(':') }
.map {
val parts = it.split(':', limit = 2)
Pair(parts[0], parts[1])
}
.associate { it }
return pairs
@OndraZizka
OndraZizka / switch.sh
Created Apr 10, 2020
Switch - simple linux alternative to Alternatives. Switches between versions of apps.
View switch.sh
#####################################################################################################
#
# This script creates switches between the versions of various tools,
# found in /mnt/jqa/sw/tools/ (curently hard-coded).
#
# Usage:
# $ switch maven 2.1.0
# $ mvn ...
#
# Installation:
@OndraZizka
OndraZizka / LogTransformer.java
Last active Oct 18, 2019
LogTransformer (fixes the scrabled log)
View LogTransformer.java
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
View video_preview.html
<!--
Tutorial code for: http://www.binpress.com/tutorial/generating-nice-movie-previews-with-ffmpeg/138
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<a href="https://www.youtube.com/watch?v=v1uyQZNg2vE" target="_blank" class="video-preview" data-frames="100" data-source="http://i.imgur.com/BX0pV4J.jpg"></a>
@OndraZizka
OndraZizka / CSI-2-picamera.py
Last active Jul 30, 2020
OpenCV, Python, camera, Raspberry Pi
View CSI-2-picamera.py
# sudo apt-get install python-picamera
import picamera
from time import sleep
camera = picamera.PiCamera()
camera.capture('image.jpg')
camera.start_preview()
camera.vflip = True
camera.hflip = True
@OndraZizka
OndraZizka / GatlingMavenPluginDocs.md
Last active May 11, 2018
Gatling Maven plugin documentation (gatling-maven-plugin)
View GatlingMavenPluginDocs.md

Gatling Maven plugin docs

Since the official Gatling Maven plugin page is missing more info than it contains, here's the output of $ mvn gatling:help -Ddetail=true -Dgoal=test:

gatling:test

Available parameters:

  • bodiesFolder (Default: ${project.basedir}/src/test/resources/bodies)
@OndraZizka
OndraZizka / MavenPomManagement.md
Last active Apr 16, 2018
Maven POM management guidelines
View MavenPomManagement.md

To keep the POMs (project object models) sane and maintainable, here's my suggestion of a few simple rules.
As with many other things in development - a bit more work for whoever does the changes that will save a lot of work to future maintainers.

  • Define dependency versions in <dependencyManagement>.
  • If there are multiple dependencies from one project, define the version in properties.
    • Version properties are named version.{artifactId}.
  • If you exclude a transitive dependency, write a comment why.
  • Group dependencies by their purpose and origin:
    • Test deps, platform deps (Dropwizard), In-house deps (CSL), project deps (that is, other modules of the same project).
  • Don't clutter the pom.xml with explicitely stating the defaults, e.g. <packaging>jar</packaging> or <relativePath>../pom.xml</relativePath>.
@OndraZizka
OndraZizka / switchHeadphones.sh
Last active May 4, 2021
Bluetooth headset - switch between quality sound + no mic (A2DP) and crappy sound and mic (HSP/HFP)
View switchHeadphones.sh
#!/bin/bash
#### Restart Bluetooth
if [ "$1" == "resetBT" ] ; then
sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
exit;
fi;
#### Toggle listen/speak
if [ "$1" == "" -o "$1" == "toggle" ] ; then
@OndraZizka
OndraZizka / CITC-CI-MavenManagedVersisons.seq.txt
Last active Feb 24, 2018
CITC CICD for sequencediagram.org
View CITC-CI-MavenManagedVersisons.seq.txt
title Collab CI pipeline
space
==Commit verification job - project integration tests \n\nAlternative 2 - version metadata resolved by leveraging Maven.== #gold
entryspacing 0.4
#actor Space for widening the source box...............................
actor Commiter
participant "Stash\n" as Stash #DodgerBlue
@OndraZizka
OndraZizka / repull.sh
Last active Nov 29, 2017
Git + Maven fetch, clean, pull, build, rebase, build and push script.
View repull.sh
#!/bin/bash
REBASE_ONTO_BRANCH="develop"
REBASE_ONTO_REMOTE="upstream"
STARTING_COMMIT=$(git rev-parse HEAD)
STARTING_BRANCH=(git rev-parse --abbrev-ref HEAD)
GO_INTO_CONFLICT="";
if [ "$1" == "force" ] ; then
GO_INTO_CONFLICT="true";