Skip to content

Instantly share code, notes, and snippets.

View ThanosFisherman's full-sized avatar

Thanos Psaridis ThanosFisherman

View GitHub Profile
@khoubyari
khoubyari / gist:121ae53fa83e23c0424938290cf5483f
Created May 11, 2017 21:43
How to configure the Async executor in Spring Boot
// reference: http://www.baeldung.com/spring-async , http://javasampleapproach.com/java-integration/start-spring-async-spring-boot
...
//in ExecutorConfig.java
@Configuration
@EnableAsync
public class AsyncConfiguration {
@Bean(name = "myAsyncExecutor")
public Executor asyncExecutor() {

How To - Upload and add Images to markdown files in Gist

Markdown files allow embedding images in it. However it requires the image to be hosted at some location and we can add the url of the image to embed it.

Example: ![Alternate image text](https://someurl/imagelocation/image.png)

We can use services like imgur or other services to host the images and use the hosted URL.

@mwolfson
mwolfson / touchHelper_ItemTouchHelperAdapter.java
Last active August 19, 2021 13:48
Interfaces, and ItemTouchHelper.Callback implementation to assist in adding Swipe based gestures (Drag & Drop, Swipe to Dismiss) to a RecyclerView.
/*
* Copyright (C) 2015 Paul Burke
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@myhandleout
myhandleout / Fibonacci.java
Created April 8, 2017 02:10
Java 8 / Lambda approach to generate fibonacci series.
import java.util.List;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
public class Fibonacci {
/**
* Java 8 / Lambda approach to generate fibonacci series.
* Fibonacci always start as classic (e.g. 0, 1, 1, 2, 3, 5)
* @param series Number of how many fibonacci number should be generated
@nickbutcher
nickbutcher / MainActivity.java
Last active August 20, 2021 16:15
A quick sample of the new physics-based animation library added in Support Library 25.3.0 docs: https://developer.android.com/reference/android/support/animation/package-summary.html output: https://twitter.com/crafty/status/842055117323026432
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.alexstyl.myapplication;
import android.content.res.Resources;
import android.support.annotation.StringRes;
class AndroidStringResources implements StringResources {
private final Resources resources;
AndroidStringResources(Resources resources) {
@NWuensche
NWuensche / SearchWithStreams.java
Last active July 24, 2021 05:30
DFS and BFS in Java 8 style
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* @author Niklas Wünsche
@alexjlockwood
alexjlockwood / vd_pause.xml
Last active September 28, 2022 04:59
VectorDrawable definitions for play, pause, and record icons
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportHeight="12"
android:viewportWidth="12">
<!-- This path draws two green stroked vertical pause bars. -->
<path
android:pathData="M 4,2.5 L 4,9.5 M 8,2.5 L 8,9.5"
@mrsarm
mrsarm / CompletableFutureGreeting.java
Created November 8, 2016 17:36
Java 8+ CompletableFuture example with error handling
CompletableFuture.supplyAsync(()-> {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException("Error sleeping", e);
}
if (System.currentTimeMillis()%2==0) {
throw new RuntimeException("Even time..."); // 50% chance to fail
}
return "Hello World!";
@riggaroo
riggaroo / MainActivity.java
Last active July 15, 2020 12:30
Online Presence with Firebase and Android based off article https://firebase.googleblog.com/2013/06/how-to-build-presence-system.html . Read the article as it explains the whole .onDisconnect().removeValue() nicely.
private void initialiseOnlinePresence() {
final DatabaseReference onlineRef = databaseReference.child(".info/connected");
final DatabaseReference currentUserRef = databaseReference.child("/presence/" + userId);
onlineRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Log.d(TAG, "DataSnapshot:" + dataSnapshot);
if (dataSnapshot.getValue(Boolean.class)){
currentUserRef.onDisconnect().removeValue();
currentUserRef.setValue(true);