Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Batuhan Bayrakci baybatu

🏠
Working from home
View GitHub Profile
@baybatu
baybatu / tarih-ve-zaman-saklama-onerisi.md
Last active Oct 5, 2022
Tarih ve zamanların veritabanında saklanmasıyla alakalı bir öneri
View tarih-ve-zaman-saklama-onerisi.md

Tablolarda tarih ve zamanı ayrı kolonlarda tutmak hatalı sorgulama yapma ihtimalini artırır. Arama için verilen bir zamanın değerini değiştirip arama yapılıyorsa bu durumda bug çıkma ihtimali var. Örnek tablo verisinin şu şekilde olduğunu düşünelim:

id tarih zaman
1 09/12/2021 23:50
2 09/12/2021 23:52
3 09/12/2021 23:55
@baybatu
baybatu / schedule-with-asyncio-eventloop.py
Last active Oct 5, 2022
I'm using schedule(https://github.com/dbader/schedule) library for simple scheduled job needs. However it does not have built-in asyncio support and cannot run coroutines as job. So, this scheduler example shows how to use schedule library with asyncio coroutines.
View schedule-with-asyncio-eventloop.py
import asyncio
import functools
from schedule import Scheduler
class AsyncScheduler(object):
"""
schedule (https://github.com/dbader/schedule) and asyncio integration example.
Jobs are executed in asyncio event loop without blocking another tasks.
View pywebio.md
@baybatu
baybatu / export-psql-to-csv-file.md
Created Feb 16, 2022
export psql query result to csv file
View export-psql-to-csv-file.md
\copy (select column1, column2 from mytable) To '/tmp/dump.csv' With CSV DELIMITER ',' HEADER
@baybatu
baybatu / nifi-test-el.groovy
Created Sep 29, 2021
Nifi Expression Language Tester
View nifi-test-el.groovy
// usage: groovy nifi-test-el.groovy '${now():toNumber():minus(3999900000):format("yyyy-MM-dd HH:mm:ss", "GMT")}'
// source: https://community.cloudera.com/t5/Community-Articles/Testing-NiFi-Expression-Language-with-Groovy/ta-p/247208
@Grab(group='org.apache.nifi', module='nifi-expression-language', version='1.4.0')
import org.apache.nifi.attribute.expression.language.*
def cli = new CliBuilder(usage:'groovy testEL.groovy [options] [expressions]',
header:'Options:')
cli.help('print this message')
cli.D(args:2, valueSeparator:'=', argName:'attribute=value',
'set value for given attribute')
@baybatu
baybatu / use-git-profile-by-directory.md
Created Jun 30, 2021
Using git profiles by current directory
View use-git-profile-by-directory.md

~/.gitconfig:

[includeIf "gitdir:~/workspace/project1/**"]
    path = .gitconfig.project1
[includeIf "gitdir:~/workspace/project2/**"]
    path = .gitconfig.project2

~/.gitconfig.project1:

@baybatu
baybatu / delete-index-by-pattern-in-es.py
Created Jun 10, 2021
delete index by pattern in Elasticsearch with Python
View delete-index-by-pattern-in-es.py
# usage
# python delete-index-by-pattern-in-es.py http://ES_HOST:9200 my-es-index-*
# indexes matched with pattern you entered will be deleted
from elasticsearch import Elasticsearch
import sys
es_host = sys.argv[1]
index_pattern = sys.argv[2]
print(f"es_host:{es_host} ; index_pattern:{index_pattern}")
@baybatu
baybatu / use-local-pod-on-demo-project.md
Last active Apr 26, 2021
use local ios pod on a demo project
View use-local-pod-on-demo-project.md

harray-ios-sdk projesini local'deki demo bir ios projesinde kullanabilmek icin adimlar:

  • localde bi ios projesi olustur (orn: batuiostest)
  • Kullanacagin modulun (harray-ios-sdk) kaynak kodlarini bu projenin icine kopyala
  • Ana dizinde Podfile olustur (ruby kodu icerecek) ve sunu koy:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'batuiostest' do
@baybatu
baybatu / delete-redis-keys-by-pattern.md
Last active Sep 17, 2021
Delete Redis keys by pattern
View delete-redis-keys-by-pattern.md