Skip to content

Instantly share code, notes, and snippets.

View kouzouigh's full-sized avatar

Ouzouigh Kamel kouzouigh

View GitHub Profile
@kouzouigh
kouzouigh / AlgDT.scala
Created July 16, 2021 13:22 — forked from mbbx6spp/AlgDT.scala
An introduction to algebraic data types (basics) in Scala...some things need to get cleaned up, but only after you grasp the basics. Part 1
package net.susanpotter.algdt
sealed trait Order {
def execute: Unit // ignore that Unit return type is not a great idea...
}
case class MarketOrder extends Order {
def execute {
println "executing market order"
}
@kouzouigh
kouzouigh / presenter.kt
Created April 11, 2021 13:46 — forked from lievendoclo/presenter.kt
Presenter in Clean Architecture
// shared datastructures
data class ResponseModel(val value: String)
data class JsonResponse(val jsonValue: String)
// example 1
interface FooUseCase {
fun <T> T doSomething(presenter: (ResponseModel -> T))
}
@kouzouigh
kouzouigh / ZipUnzip.groovy
Created April 8, 2021 09:14 — forked from bitsnaps/ZipUnzip.groovy
Zip and UnZip files using Groovy
import java.util.zip.*
String zipFileName = "file.zip"
String inputDir = "logs"
def outputDir = "zip"
//Zip files
ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(zipFileName))
new File(inputDir).eachFile() { file ->
@kouzouigh
kouzouigh / docker-compose.yml
Created September 21, 2020 13:43 — forked from brunosimioni/docker-compose.yml
Docker Compose to Prometheus, PushGateway and Grafana setup
version: '2.1'
networks:
monitor-net:
driver: bridge
volumes:
prometheus_data: {}
grafana_data: {}
//http://chrisbroadfoot.id.au/2008/08/06/groovy-threads/
//http://docs.groovy-lang.org/latest/html/gapi/groovy/transform/Synchronized.html
//https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/findOfflineSlaves.groovy
import java.util.concurrent.locks.ReentrantLock
ReentrantLock.metaClass.withLock = {
lock()
try {
it()
@kouzouigh
kouzouigh / HttpClientAutoConfiguration.java
Created May 4, 2020 07:35 — forked from jkuipers/HttpClientAutoConfiguration.java
Spring Boot auto-configuration example for an Apache Components HTTP client and its usage in all RestTemplates created by the RestTemplateBuilder, plus trace logging support
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateCustomizer;
@kouzouigh
kouzouigh / PostgreSQL_index_naming.rst
Created September 19, 2019 13:40 — forked from popravich/PostgreSQL_index_naming.rst
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@kouzouigh
kouzouigh / notifySlack.groovy
Created May 14, 2019 08:27 — forked from dschaaff/notifySlack.groovy
jenkins pipeline library for slack notifications with nice formatting
#!/usr/bin/env groovy
/**
* notify slack and set message based on build status
*/
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.model.Actionable;
@kouzouigh
kouzouigh / Jenkinsfile
Created September 14, 2018 23:28 — forked from merikan/Jenkinsfile
Some Jenkinsfile examples
Some Jenkinsfile examples
@kouzouigh
kouzouigh / openssl-cheat.sh
Created July 23, 2018 09:52 — forked from alvarow/openssl-cheat.sh
OpenSSL and Keytool cheat sheet
# Generate a new key
openssl genrsa -out server.key 2048
# Generate a new CSR
openssl req -sha256 -new -key server.key -out server.csr
# Check certificate against CA
openssl verify -verbose -CApath ./CA/ -CAfile ./CA/cacert.pem cert.pem
# Self Signed