Skip to content

Instantly share code, notes, and snippets.

Batuhan Bayrakci baybatu

Block or report user

Report or block baybatu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ufuk
ufuk / ComparingUtils.java
Last active Nov 24, 2017
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;
@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 / 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 / ApplicationContextHolder.java
Last active Sep 10, 2019 — 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;
View grep-excluding.sh
| grep -v "sen gelme ulan ayı"
@ufuk
ufuk / AsyncConfiguration.java
Last active Sep 10, 2019
The easy way to disable @ Async annotation for test contexts. This can be used to disable @ Scheduled annotation as well.
View AsyncConfiguration.java
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 Jul 14, 2017
Search my gists ;p
View hi_groob.py
#!/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 / learn-which-process-has-allocated-the-tcp-port.sh
Last active Mar 23, 2018
Learn which process has allocated the TCP port (for example "8080")
View learn-which-process-has-allocated-the-tcp-port.sh
lsof -i tcp:8080
# Example output:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# java 86935 ...
@ufuk
ufuk / TurkishNumberUtils.java
Last active Jun 5, 2018
Utils for converting numbers to Turkish words
View TurkishNumberUtils.java
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"};
@dettmering
dettmering / ping.1m.py
Created Jan 30, 2019
BitBar plugin for showing host availability
View ping.1m.py
#!/usr/local/bin/python3
import os
hosts = [
'google.com',
'microsoft.com'
]
header = []
You can’t perform that action at this time.