Skip to content

Instantly share code, notes, and snippets.

View thomaspoignant's full-sized avatar

Thomas Poignant thomaspoignant

View GitHub Profile
public class RandomLongGenerator {
private final long min;
private final long max;
private RandomIntGenerator(long min, long max) {
this.min = min;
this.max = max;
}
public static RandomLongGenerator between(long max, long min) {
return new RandomLongGenerator(min, max);
}
public ResultType methodName (
FirstArgType firstArg,
SecondArgType secondArg,
ThirdArgType thirdArg)
{
LocalVariable localVariable
= method(firstArg,secondArg);
if(localVariable.isSomething(
thirdArg, SOME_CONSTANT))
{
public ResultType methodName (
FirstArgType firstArg,
SecondArgType secondArg,
ThirdArgType thirdArg){
LocalVariable localVariable
= method(firstArg,secondArg);
if(localVariable.isSomething(
thirdArg, SOME_CONSTANT)) {
doSomething(localVariable);
}
//this way better
class RedTruck implements Truck
//than
class RedTruckImpl implements ITruck
@thomaspoignant
thomaspoignant / SyslogMatrix.md
Last active January 26, 2018 15:42
The matrix of all syslog values

RFC 5424, Section 6.2.

Severity ➡️ 0 1 2 3 4 5 6 7
Facilities ⤵️
kernel (0) 0 1 2 3 4 5 6 7
user (1) 8 9 10 11 12 13 14 15
mail (2) 16 17 18 19 20 21 22 23
system (3) 24 25 26 27 28 29 30 31
security (4) 32 33 34 35 36 37 38 39
@thomaspoignant
thomaspoignant / Pipeline example
Created January 29, 2018 10:58
A pipeline example
#!groovy
//see https://github.com/thomas-poignant/jenkins-pipeline/blob/master/Jenkinsfile_declarative_pipeline for full example
pipeline
{
/**
* agent : name of my jenkins slave
*/
agent { label 'my_jenkins_slace'}
environment
@thomaspoignant
thomaspoignant / detect_who_launch_pipeline.groovy
Created February 7, 2018 13:40
Detect if pipeline is launch manually or not
script
{
//before using this command line you should approve execution on https://jenkins_url/scriptApproval/
launchManually = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) != null
if(launchManually)
{
echo "Manually launch"
}
else
{
@thomaspoignant
thomaspoignant / find_invalid_postgis_polygon.sql
Created June 21, 2018 13:04
Find invalid postgis polygon (postgresql)
/*
Get ids of all invalid postgis polygon in the database
*/
SELECT id
FROM polygones
WHERE st_isvalid(polygone)=FALSE
ORDER BY id;
@thomaspoignant
thomaspoignant / automatic_proxy_setup_from_zscaller.sh
Created July 17, 2018 12:55
Get your proxy configuration in bash directly from zscaller .pac file
PROXY=http://$(curl -q http://pac.zscalertwo.net/XXX/proxypac-prod.pac 2>/dev/null | grep "PROXY" | grep -oP "\b(?:\d{1,3}\.){3}\d{1,3}\b:[0-9]*" | head -n 1)
echo "SETTING PROXY : $PROXY"
export HTTP_PROXY=$PROXY
export HTTPS_PROXY=$PROXY
export http_proxy=$PROXY
export https_proxy=$PROXY
# This command allow to connect to a database threw a bastion
# dns.db.instance = dns to the db instance
# user = user to connect via ssh on the bastion
# dns.bastion = dns to connect the bastion
ssh -i /path/ssh_key/dev.pem -N -L 5432:dns.db.instance:5432 user@dns.bastion