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
@baybatu
baybatu / limit-number.py
Created June 26, 2016 06:27
Limiting input number between minimum and maximum values range in Python
def limit(num, minimum=1, maximum=255):
"""Limits input 'num' between minimum and maximum values.
Default minimum value is 1 and maximum value is 255."""
return max(min(num, maximum), minimum)
@baybatu
baybatu / jaxb-cdata-without-escaping.md
Last active July 21, 2016 11:23
Add CDATA block into your XML output without escaping in JAXB
JAXBContext jaxbContext = JAXBContext.newInstance(MyClass.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty("com.sun.xml.internal.bind.characterEscapeHandler", new CharacterEscapeHandler() {
                @Override
                public void escape(char[] ac, int i, int j, boolean flag, Writer writer) throws IOException {
                    writer.write(ac, i, j);
                }
            });
@baybatu
baybatu / java-notserializable-comparator.md
Last active July 25, 2016 08:49
Java'da TreeMap'i serialize ederken alınan NotSerializableException ve çözümü

TreeMap, sıralamada kullanmak üzere bizden bir Comparator nesnesi ister ve bu Comparator nesnesini bir field üzerinde tutar. Eğer TreeMap nesnesine verilen bu Comparator nesnesi Serializable değilse serialization esnasında (cache'e yazma gibi) NotSerializableException alınır. Özellikle anonim sınıf üzerinden oluşturulan Comparator nesnelerine dikkat etmek gerekir.

Çözüm, Comparator sınıfını Serializable olarak işaretlemektir. Anonim olarak oluşturulan Comparator yerine top-level (ayrı sınıf) biçiminde Comparator oluşturup Serializable interface'i ile bu sınıfı Serializable olarak işaretleyebiliriz.

Kaynak: http://stackoverflow.com/questions/20978922/java-unable-to-serialize-a-objects-which-contain-treemaps-with-comparators

@baybatu
baybatu / access-static-constant-thymeleaf.md
Last active August 13, 2020 11:46
Accessing static constant values from Thymeleaf templates.

From expercise project:

<td>
  <input class="form-control" type="text" name="inputValue"
          th:maxlength="${T(com.expercise.utils.Constants).MAX_TESTCASE_VALUE_LENGTH}" />
</td>
@baybatu
baybatu / remove-last-files-by-minute.sh
Created October 30, 2016 16:16
Remove files those created/modified in last 20 minutes
find . -cmin -20 -delete
@baybatu
baybatu / git-branch-contains.md
Created January 30, 2017 20:09
Git command that let you know which branchs contains the specified commit
git branch --contains COMMIT_SHA1
@baybatu
baybatu / bamboo-history-cleaner.js
Created March 17, 2017 17:36
Delete Bamboo Build History
// by Bahtiyar Akbas :)
document.querySelectorAll('.deleteLink').forEach(function(e) {
var http = new XMLHttpRequest();
var url = e.href;
var params = 'atl_token='+getCookieValue('atl.xsrf.token');
http.open('POST', url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {
console.log(http.status);
}
@baybatu
baybatu / tmux-selection-to-clipboard.md
Created April 17, 2017 13:04
Copy selection area into system clipboard in tmux for iTerm2
http://stackoverflow.com/a/38849483
@baybatu
baybatu / xm-play-on-xmp.sh
Created May 6, 2017 15:11
Play *.xm files in xmp
find . -name '*.xm' -exec xmp {} \;
@baybatu
baybatu / spring-boot-main-class-in-pom.xml
Created May 9, 2017 08:00
Telling to maven which class is the main class of a SpringBoot application
<!-- source:http://stackoverflow.com/a/23217203 -->
<properties>
<start-class>com.batuhanbayrakci.acayipApp.BiAcayipApplication</start-class>
</properties>