Skip to content

Instantly share code, notes, and snippets.

@m-cakir
m-cakir / PropertyLogger.java
Created June 9, 2021 10:10 — forked from sandor-nemeth/PropertyLogger.java
Spring Boot - Log all configuration properties on application startup
package io.github.sandornemeth.spring;
import java.util.Arrays;
import java.util.stream.StreamSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.AbstractEnvironment;
@m-cakir
m-cakir / LogFile.udl.xml
Created October 27, 2020 11:28 — forked from mmdemirbas/LogFile.udl.xml
Custom log file syntax highlighting for Notepad++
<NotepadPlus>
<UserLang name="LogFile" ext="log">
<Settings>
<Global caseIgnored="yes" />
<TreatAsSymbol comment="no" commentLine="no" />
<Prefix words1="no" words2="no" words3="no" words4="no" />
</Settings>
<KeywordLists>
<Keywords name="Delimiters">[(0])0</Keywords>
<Keywords name="Folder+"></Keywords>
@m-cakir
m-cakir / singleton.dart
Created November 23, 2019 22:43 — forked from theburningmonk/singleton.dart
Using Dart's factory constructor feature to implement the singleton pattern
class MyClass {
static final MyClass _singleton = new MyClass._internal();
factory MyClass() {
return _singleton;
}
MyClass._internal() {
... // initialization logic here
}
final View target = findViewById(R.id.target);
// Create path you would like your view to follow
Path p = new Path();
RectF circle = new RectF(0, 0, 400f, 400f);
p.arcTo(circle, 0, 180);
p.arcTo(circle, 180, 180);
final PathMeasure pm = new PathMeasure(p, false);
@m-cakir
m-cakir / AppLifecycleTracker.java
Created February 17, 2019 18:22 — forked from devqmr/AppLifecycleTracker.java
How to detect when an Android app goes to the background and come back to the foreground
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.util.Log;
/**
* Created by Ahmed AbuQamar on 12/17/17.
*
*
@m-cakir
m-cakir / RequestAndResponseLoggingFilter.java
Last active January 24, 2019 12:34 — forked from int128/RequestAndResponseLoggingFilter.java
Spring Web filter for logging request and response
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
@m-cakir
m-cakir / FragmentArgumentDelegate.kt
Created December 7, 2018 14:20 — forked from yanngx/FragmentArgumentDelegate.kt
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
@m-cakir
m-cakir / Spring_propagations.md
Created July 30, 2018 08:38 — forked from rponte/Spring_propagations.md
Differences between PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED propagation in Spring transactions
  • PROPAGATION_REQUIRES_NEW starts a new, independent "inner" transaction for the given scope. This transaction will be committed or rolled back completely independent from the outer transaction, having its own isolation scope, its own set of locks, etc. The outer transaction will get suspended at the beginning of the inner one, and resumed once the inner one has completed.

Such independent inner transactions are for example used for id generation through manual sequences, where the access to the sequence table should happen in its own transactions, to keep the lock there as short as possible. The goal there is to avoid tying the sequence locks to the (potentially much longer running) outer transaction, with the sequence lock not getting released before completion of the outer transaction.

  • PROPAGATION_NESTED on the other hand starts a "nested" transaction, which is a true subtransaction of the existing one. What will happen is that a savepoint will be taken at the start of the nested transaction. I
@m-cakir
m-cakir / pom.xml
Created July 26, 2018 10:02 — forked from timmolderez/pom.xml
Adding dependencies to local .jar files in pom.xml
If you'd like to use a .jar file in your project, but it's not available in any Maven repository,
you can get around this by creating your own local repository. This is done as follows:
1 - To configure the local repository, add the following section to your pom.xml (inside the <project> tag):
<repositories>
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
@m-cakir
m-cakir / CustomResponseEntityExceptionHandler.java
Created May 23, 2018 12:31 — forked from matsev/CustomResponseEntityExceptionHandler.java
Generic response error handling using @ControllerAdvice
@ControllerAdvice
public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
List<ObjectError> globalErrors = ex.getBindingResult().getGlobalErrors();
List<String> errors = new ArrayList<>(fieldErrors.size() + globalErrors.size());
String error;
for (FieldError fieldError : fieldErrors) {