Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Batuhan Bayrakci baybatu

🏠
Working from home
View GitHub Profile
View grep-excluding.sh
| grep -v "sen gelme ulan ayı"
@ufuk
ufuk / JpaEntityQueryBuilder.java
Last active Nov 16, 2020
Easy to use query builder for JPA Criteria API
View JpaEntityQueryBuilder.java
package ...;
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;
@ufuk
ufuk / ApplicationContextHolder.java
Last active Oct 20, 2020 — forked from baybatu/getting-spring-bean-from-unmanaged-area.java
Utility bean for getting Spring beans from static context.
View ApplicationContextHolder.java
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 / find-out-slower-tests.sh
Last active Dec 28, 2016
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.
View find-out-slower-tests.sh
#!/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 / find-out-stale-branches.sh
Last active Oct 31, 2017
Lists git branches ordered by last change time to find out which ones are stale branches.
View find-out-stale-branches.sh
#!/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 / ComparingUtils.java
Last active Sep 2, 2020
Fluent API for comparing two Comparables.
View ComparingUtils.java
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;
@livacengiz
livacengiz / detail.md
Last active Jul 30, 2018
Otomat Hackathon Detaylar
View detail.md

alt text

Nedir?

Creative coding (yaratıcı programlama) işlevsel olmasından çok yaratıcılığı ön plana çıkarmak için bilgisayar programları yazma işine verilen isimdir. Ortaya çıkan sonuçlar işitsel, görsel ya da başka herhangi bir formda olabilir.

Otomat, sürekli CRUD uygulamalar yapmaktan sıkılmış geliştiriciler olarak birlikte çok ilginç projeler geliştireceğimiz bir hackathon/creative coding partisi. 19-20 Kasım tarihlerinde (gece dahil) bir araya gelerek çok güzel görsel/işitsel ürünler üretip, çok güzel sohbetler edeceğiz.

Neler yapacağız?

Ne yapmak istiyorsanız! Yapılacak şey ve konu üzerine herhangi bir sınırlandırmamız yok. Ama etkinlik günü söyleyeceğimiz bazı teknik sınırlandırmalarımız olacak :) Bireysel olarak ya da grup olarak katılımak konusunda serbestsiniz. Hatta en güzeli herkesle yardımlaşmanız :)

@ufuk
ufuk / StartEndTimeWithJodaTime.java
Created Oct 24, 2016
Joda-Time library provides us a Virtual Clock utility named "DateTimeUtils". This is a demonstration for mocking start-end times.
View StartEndTimeWithJodaTime.java
import org.joda.time.DateTime;
public class StartEndTimeWithJodaTime {
private DateTime startTime;
private DateTime endTime;
public void process() {
startTime = DateTime.now();
@ufuk
ufuk / LazyDeveloper.java
Last active Jun 27, 2019
Just another reason to why you shouldn't use Lombok, in another saying another reason to why you should write unit tests: You have two fields in your class. Fields are in the same type. You use @AllArgsConstructor to auto-generate your all args constructor. It works for a moment, until you change the order of the field.
View LazyDeveloper.java
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LazyDeveloper {
private String firstName;
private String lastName;
@ufuk
ufuk / HowToGetHttpServletRequestAndResponseProgrammatically.java
Created Oct 6, 2016
To get the request and response objects in Spring MVC projects you can use this code
View HowToGetHttpServletRequestAndResponseProgrammatically.java
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpServletRequest httpServletRequest = servletRequestAttributes.getRequest();
HttpServletResponse httpServletResponse = servletRequestAttributes.getResponse();
You can’t perform that action at this time.