Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Bernard fb64

  • Toulouse, FRANCE
View GitHub Profile
View decrypt.sh
#!/bin/sh
for i in `openssl list-cipher-commands`
do
RES="decrypt/${i}.gif"
openssl $i -d -in $1 -out $RES -pass pass:$2
if [ $? -eq 0 ]; then
echo "OK"
else
rm -rf $RES
fi
@fb64
fb64 / BitmapExtension.kt
Last active Jan 7, 2019
Bitmap extension to compresse Bitmap to ByteArray with a maximum size
View BitmapExtension.kt
import android.graphics.Bitmap
import java.io.ByteArrayOutputStream
fun Bitmap.compressToByteArray(maxSize: Long, stepQuality: Int = 5): ByteArray? {
try {
val byteArrayOutputStream = ByteArrayOutputStream()
var compressionQuality = 100
var byteArray: ByteArray?
do {
if (compressionQuality <= 0) return null
@fb64
fb64 / build.gradle
Created Nov 11, 2018
gragle build configuration for creating new elastic plugin
View build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.elasticsearch.gradle:build-tools:6.4.3"
}
}
@fb64
fb64 / CacheConfiguration.kt
Last active Mar 27, 2018
Workaround to load infinispan config from classthpath with spring-boot jcache configuration.
View CacheConfiguration.kt
import org.infinispan.configuration.parsing.ParserRegistry
import org.infinispan.jcache.embedded.JCacheManager
import org.infinispan.manager.DefaultCacheManager
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.cache.CacheProperties
import org.springframework.cache.annotation.EnableCaching
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.net.URI
import javax.cache.CacheManager
@fb64
fb64 / haproxy.conf
Created Jul 26, 2017 — forked from thpham/haproxy.conf
test config haproxy for gRPC loadbalancing
View haproxy.conf
global
tune.ssl.default-dh-param 1024
defaults
timeout connect 10000ms
timeout client 60000ms
timeout server 60000ms
frontend fe_http
mode http
View letsencrypt-renew-haproxy.sh
#!/bin/bash
#run certbot to renew certificate
certbot renew --pre-hook "service haproxy stop" --post-hook "service haproxy start"
#update certificate file for haproxy
DOMAIN='your-domain.com' sudo -E bash -c 'cat /etc/letsencrypt/live/$DOMAIN/fullchain.pem /etc/letsencrypt/live/$DOMAIN/privkey.pem > /etc/haproxy/certs/$DOMAIN.pem'
@fb64
fb64 / ec2-host-from-tag-to-env-vars.sh
Last active Jan 26, 2017 — forked from marcellodesales/ec2-host-from-tag-to-env-vars.sh
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
View ec2-host-from-tag-to-env-vars.sh
######
# Author: Marcello de Sales (marcello.desales@gmail.com)
# Description: Create Create Environment Variables in EC2 Hosts from EC2 Host Tags
#
### Requirements:
# * Install jq library (sudo apt-get install -y jq)
# * Install the EC2 Instance Metadata Query Tool (http://aws.amazon.com/code/1825)
#
### Installation:
# * Add the Policy EC2:DescribeTags to a User