Skip to content

Instantly share code, notes, and snippets.

View obatiuk's full-sized avatar
🇺🇦
#StandWithUkraine

Oleksii Batiuk obatiuk

🇺🇦
#StandWithUkraine
View GitHub Profile
import java.util.concurrent.Callable;
public class Unchecked {
public static <T> T unchecked(Callable<T> callable) {
try {
return callable.call();
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage(), ex);
}
@obatiuk
obatiuk / Histogram.java
Last active November 24, 2022 05:50
Simple Histogram java class to calculate frequencies and display approximate histogram using the Unicode characters
import static java.lang.Math.floor;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.summingInt;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.IntStream.range;
import java.util.DoubleSummaryStatistics;
@obatiuk
obatiuk / YubiKey-GPG-SSH-guide.md
Created November 24, 2022 05:47 — forked from ageis/YubiKey-GPG-SSH-guide.md
Technical guide for using YubiKey series 4 for GPG and SSH

YubiKey 4 series GPG and SSH setup guide

Written for fairly adept technical users, preferably of Debian GNU/Linux, not for absolute beginners.

You'll probably be working with a single smartcard, so you'll want only one primary key (1. Sign & Certify) and two associated subkeys (2. Encrypt, 3. Authenticate). I've published a Bash function which automates this slightly special key generation process.

@obatiuk
obatiuk / pass.md
Created October 26, 2022 03:43 — forked from abtrout/pass.md
Using password-store with git repository synching

Password-store keeps your passwords (or any other sensitive information) saved in GnuPG encrypted files organized in ~/.password-store. For more information about GPG, consult the GNU Privacy Handbook.

Getting started

To get started, install pass and generate a keypair.

$ brew install pass
$ gpg --gen-key
$ gpg --list-keys

Keybase proof

I hereby claim:

  • I am obatiuk on github.
  • I am obatiuk (https://keybase.io/obatiuk) on keybase.
  • I have a public key ASDyMzcbQ_ZM0prRqugouarviLYpY1LQcf_xuv7zooU_kgo

To claim this, I am signing this object:

@obatiuk
obatiuk / .bashrc
Last active September 8, 2020 20:02
osx basic setup script
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
export PATH=$PATH:$HOME/tools/git-tools
export JAVA_HOME=$(/usr/libexec/java_home)
export GREP_OPTIONS='--color=always'
export GREP_COLOR='1;35;40'
export CLICOLOR=1
alias ll='ls -la'
alias fixcam='sudo pkill "VDCAssistant"'
@obatiuk
obatiuk / tomcat.service
Created February 24, 2017 05:54
Example systemd unit file for tomcat 7.x
# Systemd unit file for tomcat 7.x
[Unit]
Description=Apache Tomcat 7.x Web Application Container
Wants=syslog.target network.target
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/java/latest
@obatiuk
obatiuk / debug.sh
Last active May 26, 2018 07:50
Simple line to enable debug in shell if '-debug' argument is specified
# version #1: enables xtrace if `--debug` argument is supplied
[ -n "$(echo $@ | grep "\--debug")" ] && set -x
# version #2: sets debug variable to 'true' if `--debug` argument is supplied or `xtrace` option is set
debug=false && [ -n "$(echo $@ | grep "\--debug")" ] || [ -n "$(set | grep xtrace)" ] && debug=true
#!/bin/sh
[ -n "$(echo $@ | grep "\-debug")" ] && set -x
date=$(date +%Y-%m-%d-T%H-%M-%S)
host=$(cat /proc/sys/kernel/hostname)
backup_dir="/tmp/${host}-${date}"
mkdir -p ${backup_dir}
@obatiuk
obatiuk / dependency-report.gradle
Created November 22, 2017 19:29 — forked from abesto/dependency-report.gradle
Gradle: multi-project dependency graph
task dependencyReport {
doLast {
def file = new File("project-dependencies.dot")
file.delete()
file << "digraph {\n"
file << "splines=ortho\n"
rootProject.childProjects.each { item ->
def from = item.value
from.configurations.compile.dependencies
.matching { it in ProjectDependency }