Skip to content

Instantly share code, notes, and snippets.

@valtoni
valtoni / property_facility.groovy
Created July 2, 2018 10:46
Facility to read and write scaped values to properties file
class Property {
def static Properties instance
public static readProps(String file_name_prop) {
if (!file_name_prop) throw new Exception("You must provide filename to read properties: this is a static method")
def file_prop = new File(file_name_prop)
if (!file_prop.exists()) {
throw new Exception("The file ${file_name_prop} must exists")
}
@valtoni
valtoni / oracle_freespace.sql
Created July 2, 2018 15:31
Shows oracle tablespace free space
select
fs.tablespace_name "Tablespace",
(df.totalspace - fs.freespace) "Used MB",
fs.freespace "Free MB",
df.totalspace "Total MB",
round(100 * (fs.freespace / df.totalspace)) "Pct. Free"
from
(select
tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
@valtoni
valtoni / git-delete-without-upstream.sh
Created July 20, 2018 19:49
Script to delete branches without remote upstream
#!/bin/sh
while read branch; do
upstream=$(git rev-parse --abbrev-ref $branch@{upstream} 2>/dev/null)
if [[ $? == 0 ]]; then
echo $branch tracks $upstream
else
echo $branch has no upstream configured
git branch -D $branch
if [ -z $? ]; then
@valtoni
valtoni / issue-certificate.ssh
Created August 11, 2018 16:28
Complete path to create a certification and PKCS12 format file to be used in tomcat or another server
#!/bin/bash
NAME_KEY=key
FILE=${NAME_KEY}
PRV_KEY_HEX=${FILE}.hex64.key
PRV_KEY=${FILE}.pem
CERT_REQUEST=${FILE}.csr
CERTIFICATE=${FILE}.crt
PKCS12_FILE=${FILE}.pkcs12
@valtoni
valtoni / get-latest-tag-on-git.sh
Created August 17, 2018 11:21 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@valtoni
valtoni / Exercise 6.4.lua
Last active November 1, 2018 16:33
Programming in Lua 4th edition. Chapter 6: Functions
-- Exercise 6.4: Write a function to shuffle a given list. Make sure that all permutations are equally probable.
function q4(...)
items = table.pack(...)
itemsr = {}
for i=1,#items do
math.randomseed(os.time())
pick = math.random(#items)
print("Picked item:", pick)
table.insert(itemsr,items[pick])
table.remove(items, pick)
@valtoni
valtoni / generate_pks_company_keyrings.sh
Created April 2, 2019 22:57
Script to generate a lot of things: private, public key, certificates with SHA1 and SHA256 cyphers, pkcs12 keyrings with only these generated keys and full keyrings with company customized keychain
COMPANY_CERT=certnew
COMPANY_CERT_ORIGINAL=${COMPANY_CERT}.p7b
COMPANY_CERT_NAME=company_certificates.cer
COMPANY_CERT_PKCS7_DER=${COMPANY_CERT}.der.p7b
COMPANY_CERT_PKCS7_PEM=${COMPANY_CERT}.pem.p7b
PRIVATE_KEY=private
PRIVATE_KEY_LEN=2048
PUBLIC_KEY_EXPIRY_DAYS=365
PUBLIC_KEY=public
CERTIFICATE_REQUEST=request
@echo off
SETLOCAL
if "%1%"=="" (
echo Please, fill JDK exe installer as first parameter
exit /B
)
set z7="C:\Program Files\7-Zip\7z.exe"
@valtoni
valtoni / listfiles.awk
Created August 14, 2019 19:01
Display in kibibytes the sum of all files in current directory
ls -lap | grep -v / | awk '{
size = size + $5;
}
END {
print size/1024
}'
@valtoni
valtoni / mac_flutter_proto.sh
Created November 28, 2019 02:13
Install Protobuf at flutter on Mac
# Install protobuf
brew install protobuf
brew install swift-protobuf
flutter pub global activate protoc_plugin
echo '
# Flutter binaries
export FLUTTER_HOME="$HOME/work/apps/flutter"
export DART_HOME="$FLUTTER_HOME/bin/cache/dart-sdk"
export PATH="$PATH":"$FLUTTER_HOME/bin":"$FLUTTER_HOME/.pub-cache/bin":"$DART_HOME/bin"' > $HOME/.bashrc