Skip to content

Instantly share code, notes, and snippets.

View aoudiamoncef's full-sized avatar
🏠
Working from home

Moncef AOUDIA aoudiamoncef

🏠
Working from home
View GitHub Profile
@aoudiamoncef
aoudiamoncef / AndroidTravisCI.travis.yml
Last active November 7, 2017 14:04
Android continuous integration using Travis CI (build, unit tests and connected tests using AVD)
# For more informations, please read official documentation -> https://docs.travis-ci.com/user/languages/android/
sudo: false
language: android
jdk: oraclejdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
@aoudiamoncef
aoudiamoncef / AndroidTravisCIWithAVD.travis.yml
Created November 7, 2017 13:44
Android continuous integration using Travis CI (build, unit tests and connected tests using AVD)
sudo: required
language: android
jdk: oraclejdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
cache:
@aoudiamoncef
aoudiamoncef / RxLiveData.kt
Created August 3, 2018 07:13 — forked from rubixhacker/RxLiveData.kt
Kotlin extension functions to convert LiveData to and from a Flowable
// Add the following to your build.gradle file
// implementation "android.arch.lifecycle:reactivestreams:1.0.0-beta1"
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.LiveDataReactiveStreams
import io.reactivex.Flowable
/**
@aoudiamoncef
aoudiamoncef / introspection-query.graphql
Created January 27, 2019 02:20
GraphQL schema introspection query.
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
@aoudiamoncef
aoudiamoncef / getResourceFileAsString.java
Last active June 11, 2023 09:36
Spring Boot read file from resources
public String loadFile(final String pathResource) {
try (final InputStream is = new ClassPathResource(pathResource).getInputStream()) {
// To be customized
return IOUtils.toString(is, "UTF-8");
} catch (final Exception e) {
final String errorMessage = "Error loading file ";
// Could be more specific
throw new RuntimeException(errorMessage + e);
}
}
@aoudiamoncef
aoudiamoncef / DataLoaderConfig.java
Last active January 9, 2023 11:00
GraphQL Java Dataloader Redis generic Cachemap (Spring Boot 2 )
@Configuration
public class DataLoaderConfig {
@Autowired
private RedisCacheRepository<String, ObjectId, Home> homeByObjectIdCacheMapRepository;
@Autowired
private RedisCacheRepository<String, String, Home> homeByStringCacheMapRepository;
@Bean
public DataLoaderRegistry dataLoaderRegistry() {
@aoudiamoncef
aoudiamoncef / MavenJacocoSonarQube.xml
Last active April 30, 2024 11:20
Maven Jacoco(0.8.3) && SonarQube(7.7) integration with unit && integration tests
...
<properties>
...
<sonar.scanner.maven.version>3.6.0.1398</sonar.scanner.maven.version>
<sonar.host.url>http://localhost:9000</sonar.host.url>
<sonar.projectName>lahzouz</sonar.projectName>
<sonar.language>java</sonar.language>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
@aoudiamoncef
aoudiamoncef / CacheProvider.java
Last active June 9, 2024 01:44
GraphQL Java Spring Boot 2 configuration with queries cache(Caffeine)
@Component
public class CacheProvider implements PreparsedDocumentProvider {
@Autowired
private AppProperties appProps;
@Override
public PreparsedDocumentEntry getDocument(ExecutionInput executionInput, Function<ExecutionInput, PreparsedDocumentEntry> computeFunction) {
final Cache<String, PreparsedDocumentEntry> cache = Caffeine.newBuilder()
.maximumSize(appProps.getCache()
@aoudiamoncef
aoudiamoncef / OkHttp3SslByPass.java
Created June 26, 2019 11:01
OkHttp3 Ssl ByPass
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
String authType) {
}
@aoudiamoncef
aoudiamoncef / logback-spring.xml
Last active July 4, 2019 15:47
Spring Logback heavy JSON logging with size and time based rolling policy
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="APPLICATION_NAME" value="lahzouz"/>
<property name="LOG_PATH" value="/var/log/lahzouz/${APPLICATION_NAME}"/>
<property name="FILE_PREFIX" value="${APPLICATION_NAME}"/>
<property name="PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %magenta([%thread]) %highlight(%level) %cyan(%logger{36}) - %message%n%xException"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder>