Skip to content

Instantly share code, notes, and snippets.

View jan-swiecki's full-sized avatar

Jan Święcki jan-swiecki

View GitHub Profile
@jan-swiecki
jan-swiecki / setup_mvn.sh
Last active April 15, 2021 10:55
Maven mvn setup JFrog password
#!/bin/bash
# go to ~/.m2 or other folder and run ./setup.sh according to below help
if [ -z "$3" ]; then
cat <<EOF
usage: ./setup.sh <jfrog_username> <jfrog_password> <artifactory_url>
example: ./setup.sh my_username my_password https://myjfrogaccount.jfrog.io/artifactory/mymavenrepositroyname
EOF
exit
fi
@jan-swiecki
jan-swiecki / aws-pricing
Last active February 21, 2021 14:04
aws-pricing
#!/bin/bash
set -eo pipefail
if [ -z "$1" ]; then
cat <<EOF
usage:
aws-pricing <instance_type> display pricing per availability zone
aws-pricing --instance-types [pattern] show all available instance types
filtered by optional pattern
@jan-swiecki
jan-swiecki / get_jdbc_connection_url.java
Created February 9, 2021 16:49
get_jdbc_connection_url.java
com.gignative.elexicon.util.ContextProvider.CONTEXT.getBean(org.springframework.jdbc.core.JdbcTemplate.class).getDataSource().getConnection().getMetaData().getURL()
@jan-swiecki
jan-swiecki / session_objects.java
Last active January 14, 2021 15:22
Hibernate session objects
@PersistenceContext
private EntityManager entityManager;
org.hibernate.internal.SessionImpl s = (org.hibernate.internal.SessionImpl)entityManager.unwrap(org.hibernate.Session.class);
s.persistenceContext.collectionsByKey
#!/bin/bash -i
function find_config_path () (
test / == "$PWD" && return || test -f "$1" && echo "$PWD/$1" && return || cd .. && find_config_path "$1"
)
local_awsenv () {
IFS=$'\n'
for a in "$@"; do
[ "$a" == "--save" -o "$a" == "-s" ] && { save_env=1; } || {
@jan-swiecki
jan-swiecki / awsenv
Created September 1, 2020 10:55
awsenv
#!/bin/bash
# Original idea: https://github.com/bartekj/aws-tools
awsenv() {
IFS=$'\n'
for a in "$@"; do
[ "$a" == "--save" -o "$a" == "-s" ] && { save_env=1; } || {
name="$a"
}
done
@jan-swiecki
jan-swiecki / local.sh
Created August 27, 2019 13:48
local.sh
#!/bin/bash
set -eo pipefail
help () {
cat <<EOF
Usage: ./local.bash <action>
Actions
get_version print current version
bump_version bumps version
@jan-swiecki
jan-swiecki / keybase.md
Last active June 25, 2019 22:38
Adding keybase.io proof

Keybase proof

I hereby claim:

  • I am jan-swiecki on github.
  • I am janswiecki (https://keybase.io/janswiecki) on keybase.
  • I have a public key ASAsoFvBg3zpFZUzzQtdve3ZO4eOCQjYDVfyfF2DyvJ3rAo

To claim this, I am signing this object:

@jan-swiecki
jan-swiecki / passphrase_gen.bash
Last active October 10, 2017 14:43
Passphrase generator for linux based on /dev/urandom and dict words available in linux
#!/bin/bash
# Usage: ./passphrase_gen.bash 4 > x && vim x
# We redirect to file and print via vim so no history is saved anywhere.
# Repeat after you get passphrase you like. Memorize it/write it down
# and remove x afterwards.
set -eo pipefail
words=/usr/share/dict/words
# https://serverfault.com/a/214620/216850
@jan-swiecki
jan-swiecki / onFileChange.js
Last active March 4, 2016 14:16
NodeJS `fs.watch` wrapper that checks file SHA1 and prevents multiple callback calls.
/**
* fs.watch wrapper that checks file SHA1
* and prevents multiple callback calls.
*
* Related: http://stackoverflow.com/q/12978924/1637178
*
* Usage is the same as fs.watch
*
* var onFileChange = require("./onFileChange.js");
*