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 / 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
#!/bin/bash
set -eo pipefail
. ./uninstall.sh
echo "$script_line" >> ~/.bashrc
mkdir -p "$HOME/.local/var/venv/"
@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 / docker-machine-install-docker-compose.sh
Created March 11, 2016 12:48
Installs docker-compose inside docker-machine
#!/bin/sh
# Installs docker-compose inside docker-machine
DOCKER_COMPOSE_VERSION=1.6.0
# Download docker-compose to the permanent storage
echo 'Downloading docker-compose to the permanent VM storage...'
sudo mkdir -p /var/lib/boot2docker/bin
sudo curl -sL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /var/lib/boot2docker/bin/docker-compose
@jan-swiecki
jan-swiecki / problem4.hs
Last active August 29, 2015 14:20
Problem4
-- Write a function that given a list of non negative integers,
-- arranges them such that they form the largest possible number.
-- For example, given [50, 2, 1, 9], the largest formed number is 95021.
-- Source: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
import Data.List
intCombinations :: [Int] -> [Int]
intCombinations xs = map (read.concat.(map show)) (permutations xs)
-- usage: solve [50, 2, 1, 9]