Skip to content

Instantly share code, notes, and snippets.


Bahadir Tasdemir tasdemirbahadir

Block or report user

Report or block tasdemirbahadir

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
tasdemirbahadir /
Created Apr 3, 2019
Convert java.util.Date time zone between UTC and Turkish time zones.
private static final ZoneId TURKEY_ZONE_ID = ZoneId.of("Turkey");
private static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC");
public static Date convertTurkeyToUTC(Date date) {
return Date.from(date.toInstant().atZone(UTC_ZONE_ID).toLocalDateTime().atZone(TURKEY_ZONE_ID).toInstant());
public static Date convertUTCToTurkey(Date date) {
return Date.from(date.toInstant().atZone(TURKEY_ZONE_ID).toLocalDateTime().atZone(UTC_ZONE_ID).toInstant());
tasdemirbahadir / LyricsFor99BottlesOfBeer.kt
Last active Oct 9, 2018
My 99 Bottles of Beer Lyrics in Kotlin PL. Aided with the source:
View LyricsFor99BottlesOfBeer.kt
fun main(args: Array<String>) {
fun printSongLyrics(bottlesSize: Int) {
if (bottlesSize < 0) {
println("Do not enter negative values!")
tasdemirbahadir / Java8ListToMapWithDuplicateKeys
Created Jul 5, 2018
Java8 -> Convert list to a map where list contains duplicate keys
View Java8ListToMapWithDuplicateKeys
.collect(Collectors.groupingBy(AnObject::getKeyField, toDescSortedList()))
.map(list -> list.get(0))
.collect(Collectors.toMap(AnObject::getKeyField, AnObject::getValueField));
private static <AnObject> Collector<AnObject,?,List<AnObject>> toDescSortedList() {
return Collectors.collectingAndThen(
Collectors.toCollection(ArrayList::new), list -> {
View jquery_bindfirst.js
// source:
// [name] is the name of the event "click", "mouseover", ..
// same as you'd pass it to bind()
// [fn] is the handler function
$.fn.bindFirst = function(name, fn) {
// bind as you normally would
// don't want to miss out on any jQuery magic
this.on(name, fn);
tasdemirbahadir / gist:24a13440c01c148d8e43d336add49c5a
Created Jan 13, 2017
Java Object Collection To String With Delimiter and Optional Field Usage For Object Values
View gist:24a13440c01c148d8e43d336add49c5a
* Convert list to string with delimiter
* @param <T> class of the collection
* @param values Given long values
* @param classTypeParam Pass class type to get fields, do not set null
* @param fieldName Name of the field of the object to get value of
* @param delimiter Given delimiter
* @return ({1L,3L,5L} + Long.class + null + ",") --> ("1,3,5")
* ({{id:1},{id:2},{id:3}} + ObjectClass.class + "id" + ",") --> ("1,2,3")
tasdemirbahadir /
Last active Jul 28, 2016
Using Threads Via Spring Services
* By the design pattern below, you can easily run any code blocks on a Service in Spring MVC.
* This provides a easy usage way of threads, high code maintainability and readability.
public class SpringServiceThread {
public class ThreadService {
tasdemirbahadir / RecordsWithBooleanIndicatesIfContainsOneOfOneToManyRecords.sql
Last active Jul 28, 2016
Check if records have any record inside a one-to-many relation table or not
View RecordsWithBooleanIndicatesIfContainsOneOfOneToManyRecords.sql
t.field2, is not null contains_record
table t
(select tom.* from table_one_to_many_relation tom where = 1) contains on contains.table_id =
tasdemirbahadir /
Last active Jul 28, 2016
Set Nullable Value to the PreparedStatement Easily
/** Design pattern below provides setting nullable values to the prepared statement easily
* Set nullable value to PreparedStatement
* @param ps PreparedStatement object
* @param value Value to set
* @param type Type of the value at DBMS (ex: Types.VARCHAR)
* @param index Index of the value inside query string
* @return Given PreparedStatement object with the value set
* @throws SQLException
* @throws TypeConstraintException If the type of the given value not found
You can’t perform that action at this time.