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
baybatu /
Last active Jan 27, 2016
Couchbase view'larındaki sayı formatındaki string alanlara göre arama sorunu ve çözümü

Couchbase view'larında arama yapılacak alan string türünde fakat arama sorgusu(key) sayı formatında ise bu durumda Couchbase'in 1.4.9'a kadar olan java client'ları bu key'i sayı formatında sorguya gönderir ve boş sonuç döner.

Örneğin şöyle bir Couchbase dokümanımız olsun:

	"isim": "Batuhan",
	"numara": "1234"
baybatu / groovy-xml-without-whitespaces.groovy
Created Feb 7, 2016
Write XML into a file without whitespace character in Groovy
View groovy-xml-without-whitespaces.groovy
import groovy.xml.MarkupBuilder
* Produces xml file that has no whitespace character.
* new IndentPrinter(out, "", false) section does all things we need to do.
* Example output:
* <products><product><title>product title</title><price>100</price></product></products>
baybatu / optional-parentheses-uppercase-bug-groovy.groovy
Last active Feb 28, 2016
It is must to use parentheses while calling function or method that starts with an uppercase letter in Groovy 2.4.5
View optional-parentheses-uppercase-bug-groovy.groovy
def foo(arg) {
def Bar(arg) {
foo "berbat"
baybatu /
Last active Mar 2, 2016
Problem of private key file(.p12) not found while Google Analytics API authenticating in WebLogic

I encountered with a problem in WebLogic about to find full path of .p12(private key file) that needs to be specified for Google Analytics API authentication.

My private key file (google_analytics_private_key.p12) was in path '<PROJECT_PATH>/src/main/resources/keys/google_analytics_private_key.p12' in project source. Key loader method was such below and it worked in Tomcat flawlessly but not in WebLogic.

public String getGoogleAccountPrivateKeyFile() {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    URL resource = loader.getResource("/keys/google_analytics_private_key.p12");
    return resource.getFile();
baybatu /
Last active Mar 9, 2016
Running processes associated with each open port.

Shell command that gives running processes associated with each open port.

netstat -tulpn
baybatu /
Last active Apr 21, 2016
Why we must use wrapper type such as Long instead of primitive ones such as long for entity ID in Hibernate?

I ran into similar problem, where I was trying to save an object where his id was a primitive field (long), and at the time of create the object, the id was set to 0 by default, and Hibernate assumed I wanted to update the row with id = 0 (which obviously doesn't exist). My solution was change the id field to Long (wrapper), and that way, when I create a new instance the id is set to null, and Hibernate understands I am inserting a new element to the database. I hope it helps. Thanks.


baybatu / plsql-upsert.sql
Last active Apr 27, 2016
Upsert example in PL/SQL
View plsql-upsert.sql
-- Insert entity into MY_TABLE table using 'entity_id' and 'name' fields if not exists.
-- Otherwise, update row's 'name' field.
WHEN NOT MATCHED THEN INSERT (entitiy_id, name) VALUES (?, ?)
baybatu /
Created Mar 16, 2016
Listing .jar file content from command-line
baybatu / process-old-files-by-lastmodifieddates.groovy
Created Jun 1, 2016
Process files by their last modified dates in Groovy
View process-old-files-by-lastmodifieddates.groovy
// 'delete' is a process example
public void deleteOldFiles(File path) {
long startOfDay = new Date().clearTime().time
path.eachFile { file ->
if (file.lastModified() < startOfDay) {
baybatu /
Last active Jun 6, 2016
Grails'de dosya sunarken alınan "dosya bulunamadı" hatası ve çözümü

Grails'de render metoduna (1) adresindeki file ve fileName parametrelerini vererek kullanıcının istediğimiz dosyayı indirmesini sağlayabiliriz. Fakat eğer tarayıcı "dosya bulunamadı" hatası veriyorsa bu durumda Grails'deki Config.groovy dosyasında bulunan grails.mime.types listesini kontrol etmek gerekir. Eğer indirmek istediğimiz dosya türü için gerekli mime türü bu listede yoksa hata alırız. Örneğin zip dosyası indirtmek istiyorsak bu durumda listeye zip:'application/zip' kaydını girmek gerekir.



You can’t perform that action at this time.