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
View gist:4dc603b56399918bfb54
import re
import csv
import urllib
class Parse:
params = re.compile('(?P<key>[\S]*)=\{(?P<value>[\S]*)\}')
prep = re.compile('(?P<key>[\S]*)=(?P<value>[\S]*)')
@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();
@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 / 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
View grep-excluding.sh
| grep -v "sen gelme ulan ayı"
@ufuk
ufuk / AsyncConfiguration.java
Last active May 31, 2017
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 {
@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 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 / 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 ...
@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))
You can’t perform that action at this time.