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 / TurkishNumberUtils.java
Last active November 13, 2020 07:55
Util for converting whole numbers to Turkish words
public final class TurkishNumberUtils {
private static final String SPACE = " ";
private static final String EMPTY = "";
private static final String[] PERIOD_NAMES = {EMPTY, "bin", "milyon", "milyar", "trilyon", "katrilyon", "kentilyon"};
private static final String[] UNITS_TEXTS = {EMPTY, "bir", "iki", "üç", "dört", "beş", "altı", "yedi", "sekiz", "dokuz"};
@ufuk
ufuk / learn-which-process-has-allocated-the-tcp-port.sh
Last active March 23, 2018 11:30
Learn which process has allocated the TCP port (for example "8080")
lsof -i tcp:8080
# Example output:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# java 86935 ...
@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'.

@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))
@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 {
@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 / grep-excluding.sh
Created February 8, 2017 11:17
Grep Excluding
… | grep -v "sen gelme ulan ayı"
@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 / 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 / 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