Skip to content

Instantly share code, notes, and snippets.

@darius-sas
darius-sas / sonarqube-git-analysis.sh
Last active June 13, 2023 07:21
Execute Sonarqube on a Git repo
#!/bin/bash
set -e
# For example, you can generate these with `git tag --sort=creatordate`
tags=(commit1 commit2 ...)
# Some projects wont compile otherwise
JAVA_8_HOME=/path/to/java8
# Sonarqube needs a recent version of java to run
JAVA_17_HOME=/path/to/java8
@darius-sas
darius-sas / dtw-example.R
Created April 27, 2022 07:08
Dynamic Time Warping in R (DTW)
# Example of using the dtw library
# This code is not mine.
library(dtw)
idx<-seq(0,6.28,len=100);
query<-sin(idx)+runif(100)/10;
t1 <- c(0, 0.5, 0)
t2 <- c(-1, 0, -1)
t3 <- c(-1, 0, 1)
@darius-sas
darius-sas / DTW.java
Created April 27, 2022 07:06
Dynamic Time Warping in Java (DTW)
package io.github.cawfree.dtw.alg;
/**
* A class that implements the awesome Dynamic Time Warping algorithm.
* Absolutely all credit for this implementation goes to the developers of the Gesture and Activity Recognition Toolkit, (GART).
* @http://trac.research.cc.gatech.edu/GART/browser/GART/weka/edu/gatech/gart/ml/weka/DTW.java?rev=9
**/
public final class DTW {
/** Defines the result for a Dynamic Time Warping operation. */
@darius-sas
darius-sas / main-branch.sh
Created May 12, 2021 08:08
Get the main branch of a Git repository
# From https://stackoverflow.com/questions/55266918/how-to-get-main-git-branch-name-from-command-line
# Original author: tukusejssirs (StackOverflow)
# Current local branch name
git rev-parse --abbrev-ref HEAD
# Output: branch
# Remote branch name that is tracked by current local branch
git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)
# Output: origin/branch
@darius-sas
darius-sas / parallel.sh
Last active March 25, 2021 14:33
Run jobs in parallel in bash
#!/bin/bash
# Copied from https://milhouse.dev/2015/11/20/writing-a-process-pool-in-bash/
# Define the pool size (aka number of processes to run concurrently)
POOL_SIZE=4
parallel() {
local proc procs
declare -a procs=() # this declares procs as an array