Skip to content

Instantly share code, notes, and snippets.

View dimaKudr's full-sized avatar

Dmytro Kudryavtsev dimaKudr

  • Prague, Czech Republic
View GitHub Profile
@dimaKudr
dimaKudr / psql-and-proxy
Created April 4, 2020 20:19
cloud sql proxy
# install psql
brew install libpq
ln -s /usr/local/Cellar/libpq/12.2_1/bin/psql /usr/local/bin/psql
# Mac: install cloud sql proxy
curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.amd64
chmod +x cloud_sql_proxy
# start proxy
# INSTANCE_NAME example - kuber-test-02:us-central1:dev-server
@dimaKudr
dimaKudr / prepare-commit-msg
Created April 4, 2020 20:13
Git hook: prepare commit message
#!/bin/bash
# Include any branches for which you wish to disable this script
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop staging test)
fi
# Get the current branch name and check if it is excluded
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
# Trim it down to get the parts we're interested in
TRIMMED=$(echo $BRANCH_NAME | sed -e 's:^\([^-]*\)-.*:\1:' -e \
@dimaKudr
dimaKudr / sizes.sh
Created May 28, 2016 22:30
Calculates sizes of all subfolders
find . -maxdepth 1 -type d -mindepth 1 -exec du -hs {} \;
@dimaKudr
dimaKudr / JavaStreamExceptions.java
Created October 18, 2015 07:28
Hide checked exceptions in Java Streams
public static <T> T uncheckCall(Callable<T> callable) {
try { return callable.call(); }
catch (Exception e) { return sneakyThrow(e); }
}
public static void uncheckRun(RunnableExc r) {
try { r.run(); } catch (Exception e) { sneakyThrow(e); }
}
public interface RunnableExc { void run() throws Exception; }