Skip to content

Instantly share code, notes, and snippets.

@zabetak
zabetak / str_dec_hive_mssql_mysql.csv
Created December 2, 2021 13:10
String decimal comparisons/arithmetic in Hive, MySQL, MSSQL
QID Hive 1.2.0 Hive 3.1.0 MySQL MSSQL 2017
Q1 false true 1 false
Q2 false false 0 false
Q3 true true 1 ERROR
Q4 false true 1 true
Q5 false true 1 ERROR
Q6 true true 1 false
Q7 false false 0 false
Q8 false true ERROR ERROR
Q9 true true 1 false
@zabetak
zabetak / str_dec_queries.csv
Last active December 2, 2021 12:48
String/Decimal representative queries
ID Query
Q1 select decimal_col=string_col from dec_str_tbl
Q2 select decimal_col='12000000000000000000' from dec_str_tbl
Q3 select decimal_col=12000000000000000000.5BD from dec_str_tbl
Q4 select decimal_col=12000000000000000000.5 from dec_str_tbl
Q5 select string_col=12000000000000000000.5BD from dec_str_tbl
Q6 select string_col=12000000000000000000.5 from dec_str_tbl
Q7 select string_col='12000000000000000000.0' from dec_str_tbl
Q8 select 12000000000000000000.5BD='12000000000000000000' from dec_str_tbl
Q9 select 12000000000000000000.5='12000000000000000000' from dec_str_tbl
@zabetak
zabetak / reviews_per_quarter.sql
Created October 13, 2020 08:17
Counts the number of (contributor) reviews per committer for a specific quarter
-- The SQL below counts exclusively reviews of non-committers.
SELECT count(*) reviews, committer
FROM
(SELECT c.author author,
c.committer committer,
CASE
WHEN c.author_timestamp > phonebook.first_commit THEN 1
ELSE 0
END is_committer
FROM git_commits c
@zabetak
zabetak / commits_per_quarter.sh
Last active October 9, 2020 21:50
Count the number of commits per quarter having a message that ends up with parentheses and certain specific characters
#!/usr/bin/env bash
for (( year=$1; year<=$2; year++ ))
do
echo -n "Q1 $year:"
git log --oneline --after="$year-01-01" --until="$year-04-01" | grep "([[:alnum:] ,\.]\+)$" | wc -l
echo -n "Q2 $year:"
git log --oneline --after="$year-04-01" --until="$year-07-01" | grep "([[:alnum:] ,\.]\+)$" | wc -l
echo -n "Q3 $year:"
git log --oneline --after="$year-07-01" --until="$year-10-01" | grep "([[:alnum:] ,\.]\+)$" | wc -l
@zabetak
zabetak / README.md
Created July 21, 2020 11:31
Show assembly code generated by the JVM

This document outlines how you can print the assembly code generated by the JVM. It relies on the -XX:+PrintAssembly VM option available since java7 and requires also -XX:+UnlockDiagnosticVMOptions.

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly MyClassFile

In order to print assembly code you need a disassembler plugin such as FCML. If you are running on Linux you may be able to install directly the required libraries (hsdis-amd64.so) via a package manager.

In Ubuntu you can type the following command:

/**
* A Query that needs to be bound to a value before it can be executed.
*
* The query can take many forms depending on the value which is bound at each
* time. The same value should always lead to the same query. Normally, before
* executing the query a concrete value must be set via {@link #setValue(Object)}
* method although some implementations may decide to return a query even the
* value is not set.
*/
public abstract class ParameterizedQuery extends Query
@zabetak
zabetak / gist:fcb0b842772cad7cd2e2083926853028
Created March 15, 2019 16:49
Obtain a rough equivalent of Class#getName for all subtypes of a java Type
# Using IntelliJ select the desired type (e.g., java.lang.Number) and open subtypes hierarchy.
# Using the toolbar in the Hierarchy window click the button to export the hierarchy into a file.
# The exported file (let's call it init.txt) should look like below:
Number (java.lang)
Float (java.lang)
MutableInt (org.apache.commons.lang3.mutable)
MutableInt (org.apache.commons.lang3.mutable)
BigFraction (org.apache.commons.math3.fraction)
BigFraction (org.apache.commons.math3.fraction)
BigFraction (org.apache.commons.math3.fraction)