Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Poignant thomaspoignant

View GitHub Profile
View RandomLongGenerator.java
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);
}
View bracketSameLine.java
public ResultType methodName (
FirstArgType firstArg,
SecondArgType secondArg,
ThirdArgType thirdArg){
LocalVariable localVariable
= method(firstArg,secondArg);
if(localVariable.isSomething(
thirdArg, SOME_CONSTANT)) {
doSomething(localVariable);
}
View bracketAtTheLine.java
public ResultType methodName (
FirstArgType firstArg,
SecondArgType secondArg,
ThirdArgType thirdArg)
{
LocalVariable localVariable
= method(firstArg,secondArg);
if(localVariable.isSomething(
thirdArg, SOME_CONSTANT))
{
View InterfaceNaming.java
//this way better
class RedTruck implements Truck
//than
class RedTruckImpl implements ITruck
@thomaspoignant
thomaspoignant / SyslogMatrix.md
Last active Jan 26, 2018
The matrix of all syslog values
View SyslogMatrix.md

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
View 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 Feb 7, 2018
Detect if pipeline is launch manually or not
View detect_who_launch_pipeline.groovy
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 / export_dokuwiki
Last active Mar 1, 2018
Dokuwiki, export all pages with one command line. The result is all the wiki pages and files in html
View export_dokuwiki
wget \
--recursive \
--no-clobber \
--page-requisites \
--no-check-certificate \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--no-parent \
--domains yourdomain.com \
@thomaspoignant
thomaspoignant / find_invalid_postgis_polygon.sql
Created Jun 21, 2018
Find invalid postgis polygon (postgresql)
View find_invalid_postgis_polygon.sql
/*
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 Jul 17, 2018
Get your proxy configuration in bash directly from zscaller .pac file
View automatic_proxy_setup_from_zscaller.sh
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