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
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "";
parser.protocol; // => "http:"
parser.hostname; // => ""
parser.port; // => "3000"
parser.pathname; // => "/pathname/"; // => "?search=test"
parser.hash; // => "#hash"; // => ""
ufuk /
Last active Feb 20, 2020 — forked from baybatu/
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;
public class ApplicationContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
jonikarppinen /
Last active Oct 22, 2019
Example of using message resources in Spring Boot service layer code, in as simple way as possible (hopefully!)
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Locale;
ufuk /
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.
package ...configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableAsync;
public class AsyncConfiguration {
ufuk /
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.
import lombok.AllArgsConstructor;
import lombok.Data;
public class LazyDeveloper {
private String firstName;
private String lastName;
joemiller /
Last active May 6, 2019
clone all repos from an org, including private repos
# Reqs: curl, ruby, git
# TOKEN: Create a personal access token here:
# Usage:
# To clone all repos from $ORG into current directory:
# $ curl | TOKEN=<githubtoken> ORG=<orgname> bash
ufuk /
Last active Apr 9, 2019
Performs "verify no more interactions" check automatically for all mock objects (works with Mockito version 2). For detailed description: (Turkish)
import org.apache.commons.lang3.ArrayUtils;
import org.junit.After;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verifyNoMoreInteractions;
dettmering /
Created Jan 30, 2019
BitBar plugin for showing host availability
import os
hosts = [
header = []
ufuk / import-csv-file-from-s3-into-aws-redshift.sql
Created Jan 31, 2019
Import CSV file from S3 into AWS Redshift
View import-csv-file-from-s3-into-aws-redshift.sql
-- Before importing, you need to create table
CREATE TABLE example_table
-- Importing...
COPY example_table
FROM 's3://<BUCKET_NAME>/.../example_table.csv'
CREDENTIALS 'aws_access_key_id=...;aws_secret_access_key=...'
ufuk /
Created Jan 31, 2019
Echo time by timezone in BASH
echo "$(TZ='Europe/Moscow' date +%Y-%m-%d\ %H\:%M)"
# output => 2019-01-31 16:52
You can’t perform that action at this time.