Skip to content

Instantly share code, notes, and snippets.

@Janfy
Janfy / http-client.jsh
Created January 3, 2024 18:22 — forked from gatanaso/http-client.jsh
JShell http client example
import java.net.http.*;
var client = HttpClient.newHttpClient();
var uri = new URI("https://riimusolutions.com");
var request = HttpRequest.newBuilder().uri(uri).build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
/exit
@Janfy
Janfy / heal_gluster.sh
Created March 9, 2021 19:08 — forked from pulecp/heal_gluster.sh
This script looks for gluster volumes, checks their heal statuses and tries to fix all the unhealed files/dirs.
#!/bin/bash
# thanks to Niels de Vos (https://gist.github.com/nixpanic/5460521), this script
# is based on his one
RED='\033[1;31m'
GREEN='\033[1;32m'
NC='\033[0m' # No Color
@Janfy
Janfy / VersionComparator.groovy
Created September 2, 2019 17:57 — forked from founddrama/VersionComparator.groovy
a version comparator (e.g., "1.0.2" < "1.0.10")
def versions = []
def f = new File('mock-version-tags.txt')
f.eachLine { versions << it }
def versionComparator = { a, b ->
def VALID_TOKENS = /._/
a = a.tokenize(VALID_TOKENS)
b = b.tokenize(VALID_TOKENS)
for (i in 0..<Math.max(a.size(), b.size())) {
@Janfy
Janfy / install_git.sh
Created July 14, 2019 20:00
Install git from source
wget https://github.com/git/git/archive/v2.10.2.zip
apt-get install make unzip gcc autoconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
unzip v2.10.2.zip
cd git-2.10.2
make configure
./configure --prefix=/usr/local
make install
git --version
@Janfy
Janfy / bash_regex_match_groups.md
Created January 28, 2017 18:35 — forked from JPvRiel/bash_regex_match_groups.md
Bash regular expression match with groups including example to parse http_proxy environment variable

The newer versions of bash include a regex operator =~

Simple example

$ re='t(es)t'
$ [[ "test" =~ $re ]]
$ echo $?
0
$ echo ${BASH_REMATCH[1]}
es
@Janfy
Janfy / CreateJob.sh
Created July 6, 2016 13:12 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
# Docker Machine for Consul
docker-machine \
create \
-d virtualbox \
consul-machine
# Start Consul
docker $(docker-machine config consul-machine) run -d --restart=always \
-p "8500:8500" \
-h "consul" \
@Janfy
Janfy / gist:a7a7a6f9b41ddf340cea
Last active August 28, 2015 09:19 — forked from rayyildiz/gist:2027501
Generate LiquiBase changeLogs using Groovy
def writer = new FileWriter('sample2.xml')
// Define 2 tables
def tables =[]
def dept = new Table(tableName:'departments')
dept.columns << new Column(name:'id', type:'number(4,0)', nullable:false)
dept.columns << new Column(name:'dname', type:'varchar2(14)', remarks:'Department name')
tables << dept
def emp = new Table(tableName:'employees', remarks:'All employees known in HR system')
@Janfy
Janfy / encode.sh
Created April 28, 2015 07:47
String Encoding in the Shell
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Performs a number of encodings on the first argument string"
echo "Usage: `basename $0` {string}"
exit 1
fi
printf "n# String Scrambles:n"
@Janfy
Janfy / gencert.sh
Last active August 29, 2015 14:15 — forked from bradland/gencert.sh
#!/bin/bash
# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Large portions of this script were taken from the
# following artcile:
#
# http://usrportage.de/archives/919-Batch-generating-SSL-certificates.html
#
# Additional alterations by: Brad Landers
# Date: 2012-01-27