Skip to content

Instantly share code, notes, and snippets.

Oleksii Batiuk obatiuk

Block or report user

Report or block obatiuk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View backup-openwrt.sh
#!/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 Nov 22, 2017 — forked from abesto/dependency-report.gradle
Gradle: multi-project dependency graph
View dependency-report.gradle
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 }
@obatiuk
obatiuk / clean-git-history.sh
Created Oct 7, 2017
Makes current commit in master the only initial commit in git (e.g. deletes all history)
View clean-git-history.sh
#!/bin/sh
# Source: https://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository/13102849#13102849
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D master # Deletes the master branch
git branch -m master # Rename the current branch to master
git push -f origin master # Force push master branch to github
@obatiuk
obatiuk / .bashrc
Last active Feb 16, 2019
osx basic setup script
View .bashrc
[ -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 / debug.sh
Last active May 26, 2018
Simple line to enable debug in shell if '-debug' argument is specified
View debug.sh
# 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
@obatiuk
obatiuk / Histogram.java
Last active Jun 19, 2017
Simple Histogram java class to to calculate frequencies and display approximate histogram using the Unicode characters
View Histogram.java
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 / .gtkrc-eclipse
Created May 17, 2017 — forked from andrioli/.gtkrc-eclipse
Config to make Eclipse Juno icons and tabs look small and nice in Linux
View .gtkrc-eclipse
# Create a new file in your home directory called .gtkrc-eclipse
# call eclipse with this command:
# Gtk2 forced:
# export SWT_GTK3=0
# env GTK2_RC_FILES=/usr/share/themes/<YourTheme>/gtk-2.0/gtkrc:/home/<YourUser>/.gtkrc-eclipse '/path_to_eclipse/eclipse'
# In your Eclipse directory find the file 'e4_default_gtk.css'
# In this file there's a CSS class:
@obatiuk
obatiuk / shred
Created Mar 11, 2017
folder shred example
View shred
#!/bin/bash
if dialog=`zenity --window-icon=warning --question --title="Secure Delete" --no-wrap --text="Are you sure you want to securely delete:\n\n $1\n\nand any other files and folders selected? File data will be overwritten and cannot be recovered."`
then /usr/bin/srm -fllrv "$@"| zenity --progress --pulsate --text="File deletion in progress..." --title="Secure Delete" --auto-close
fi
@obatiuk
obatiuk / tomcat.service
Created Feb 24, 2017
Example systemd unit file for tomcat 7.x
View tomcat.service
# 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 / check-url.sh
Created Feb 21, 2017
This script prints HTTP code for the supplied url
View check-url.sh
#!/bin/bash
url=$1
# Make a HEAD request to the supplied URL
code=$(curl $url -s -L -I -o /dev/null -w '%{http_code}')
if [ $code != "200" ]; then
# Some servers might reject HEAD requests. Downloading 1st byte of the data to get a code
code=$(curl --max-filesize 1 $url -s -L -o /dev/null -w '%{http_code}')
fi
echo $code
You can’t perform that action at this time.