Skip to content

Instantly share code, notes, and snippets.

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

Batuhan Bayrakci baybatu

🏠
Working from home
View GitHub Profile
@ufuk
ufuk / ComparingUtils.java
Last active September 2, 2020 13:41
Fluent API for comparing two Comparables.
public class ComparingUtils {
public static <T extends Comparable<T>> ComparisonBuilder<T> is(T comparable) {
return new ComparisonBuilder<>(comparable);
}
public static class ComparisonBuilder<T> {
private Comparable<T> subject;
@ufuk
ufuk / find-out-stale-branches.sh
Last active October 31, 2017 08:35
Lists git branches ordered by last change time to find out which ones are stale branches.
#!/bin/bash
# DESCRIPTION
# -----------
#
# Produces CSV output like this:
#
# LAST CHANGE TIME, TIME ELAPSED, AUTHOR, BRANCH
# 2017-01-16 14:56:26 +0000, 3 months ago, john.doe@example.com, origin/bug-fix-1
# 2017-01-23 18:27:53 +0300, 2 months ago, john.doe@example.com, origin/new-feature-1
@ufuk
ufuk / find-out-slower-tests.sh
Last active January 5, 2021 09:48
Lists test classes descending ordered by elapsed time to find out which ones are slower than others. Run this BASH script at project's root.
#!/bin/bash
# Run tests
mvn clean test --fail-never
# Print header
echo
echo "TEST NAME, TESTS COUNT, FAILURES COUNT, ERRORS COUNT, SKIPPED COUNT, TIME ELAPSED"
# Prepare report
@ufuk
ufuk / ApplicationContextHolder.java
Last active December 17, 2022 14:16 — forked from baybatu/getting-spring-bean-from-unmanaged-area.java
Utility bean for getting Spring beans from static context.
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class ApplicationContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@ufuk
ufuk / JpaEntityQueryBuilder.java
Last active January 8, 2023 17:38
Easy to use query builder for JPA Criteria API
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.query.criteria.internal.path.PluralAttributePath;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.repository.support.PageableExecutionUtils;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
@ufuk
ufuk / grep-excluding.sh
Created February 8, 2017 11:17
Grep Excluding
… | grep -v "sen gelme ulan ayı"
@kencharos
kencharos / Comp.java
Created February 17, 2017 10:35
CompletableFuture sample(with simple error handling)
package com.example;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Comp {
public static void main(String[] args) {
@ufuk
ufuk / AsyncConfiguration.java
Last active December 10, 2022 21:43
The easy way to disable @ Async annotation for test contexts. Same approach can be used to disable @ Scheduled annotation as well.
package ...configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableAsync;
@Configuration
@EnableAsync
@Profile("!test")
public class AsyncConfiguration {
@pudquick
pudquick / hi_groob.py
Created July 14, 2017 13:48
Search my gists ;p
#!/usr/bin/python
from Foundation import NSWorkspace, NSURL
import urllib
def show_gists():
NSWorkspace.sharedWorkspace().openURL_(NSURL.URLWithString_('https://gist.github.com/search?q=%40pudquick&ref=searchresults'))
def search_gists(search_string):
NSWorkspace.sharedWorkspace().openURL_(NSURL.URLWithString_('https://gist.github.com/search?q=%%40pudquick+%s&ref=searchresults' % search_string))
@Bonno
Bonno / README.md
Last active August 11, 2023 14:13
Opening multiple SSH sessions with iTerm automatically. To be used in an Automator flow.

Create a new Automater flow

Add 'Service'. Service receives 'no input' in 'iTerm'. Add 'Run AppleScript'.