Skip to content

Instantly share code, notes, and snippets.

View cengizhancaliskan's full-sized avatar
:bowtie:

Cengizhan Çalışkan cengizhancaliskan

:bowtie:
View GitHub Profile
@cengizhancaliskan
cengizhancaliskan / dynamically_call.py
Created November 18, 2019 13:42
Python call functions dynamically with getattr
class Cleaner(object):
def clean_name(self):
pass
cleaner = Cleaner()
for method_name in methods:
getattr(cleaner, method_name)()
### More Objective way
@cengizhancaliskan
cengizhancaliskan / has_cyrillic.py
Last active November 13, 2019 05:55
Python has cyrillic, has chinese, get non chinese/cyrillic
# Reference: https://unicode-table.com/en/blocks/
# https://docs.oracle.com/cd/E29584_01/webhelp/mdex_basicDev/src/rbdv_chars_mapping.html
import re
def has_cyrillic(word):
# https://unicode-table.com/en/blocks/cyrillic/
# Languages: russian, ukrainian, bulgarian
return bool(re.search('[\u0400-\u04ff]', word))
@cengizhancaliskan
cengizhancaliskan / locustfile.py
Created November 4, 2018 13:58
Locust example
# -*- coding: utf-8 -*-
from locust import HttpLocust, TaskSet, task
class FirstTestClass(TaskSet):
# @task attribute' methodumuzun task olduğunu belirtmek için kullanıyoruz.
@task
def index(self):
self.client.get("/locustio/locust")
@cengizhancaliskan
cengizhancaliskan / most-useful-postgresql-command.csv
Last active April 22, 2022 15:05
Sık kullanılan postgresql komutları
Komut Açıklama
\q Çıkış yapmanızı sağlar.
\x Çıktıları genişletir.
\H Çıktıları html olarak verir.
\a Çıktıları hizalar.
\s Komut geçmişinizi listeler.
\g Bir önceki komutunuzu çalıştırır.
\c yada \connect [ VERITABANI_ADI [ KULLANICI_ADI ] [ HOST ] [ PORT ] ] Başka bir veritabanına bağlanmak için kullanılır.
\l Veritabanlarını listeler.
\l+ Veritabanlarını detaylı listeler. (veritabanı boyutunu da verir)
@cengizhancaliskan
cengizhancaliskan / default.vcl
Created June 8, 2018 07:37
varnish 4 config for symfony 3.x
vcl 4.0;
# Based on: https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl
import std;
import directors;
backend server1 { # Define one backend
.host = "127.0.0.1"; # IP or Hostname of backend
.port = "80"; # Port Apache or whatever is listening
.max_connections = 300; # That's it
vcl 4.0;
import directors;
backend app2 {
.host = "10.135.19.167";
.port = "8080";
}
backend app3 {
.host = "10.135.40.246";
@cengizhancaliskan
cengizhancaliskan / mysqldump.sh
Created March 13, 2018 12:02
Mysqldump bash
#!/bin/bash
echo "Starting the backup script..."
ROOTDIR="/backup/mysql/"
YEAR=`date +%Y`
MONTH=`date +%m`
DAY=`date +%d`
HOUR=`date +%H`
SERVER="444.333.222.111"
BLACKLIST="information_schema performance_schema"
ADDITIONAL_MYSQLDUMP_PARAMS="--skip-lock-tables --skip-add-locks --quick --single-transaction"
# Local
CREATE USER 'ryan'@'localhost' IDENTIFIED BY 'babel';
GRANT ALL PRIVILEGES ON *.* TO 'ryan'@'localhost' WITH GRANT OPTION;
# Anywhere
CREATE USER 'ryan'@'%' IDENTIFIED BY 'babel';
GRANT ALL PRIVILEGES ON *.* TO 'ryan'@'%' WITH GRANT OPTION;
@cengizhancaliskan
cengizhancaliskan / mysql-s3-backup
Created January 1, 2018 21:33
MySql S3 Backup
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /srv/www
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@cengizhancaliskan
cengizhancaliskan / clean remove kibana
Created December 31, 2017 12:13
os x clean remove kibana
# checks to see if running
launchctl list | grep kibana
# remove autostarts
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.kibana.plist
launchctl remove homebrew.mxcl.kibana
# remove all process
pkill -f kibana