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 / RateLimit.php
Created September 9, 2017 13:54
php rate limiter
<?php
class RateLimit
{
protected $totalTimestamp = 0;
protected $totalCalls = 0;
protected $timestamp = 0;
protected $calls = 0;
protected $limit;
@cengizhancaliskan
cengizhancaliskan / pngtojpg.sh
Created September 24, 2017 09:19
Png to Jpeg for imagemagick
#!/bin/bash
dir="/Users/cengizhan/images"
find $dir -type f -name '*.png' -print0 | while IFS= read -r -d '' file; do
convert "$file" "${file%.*}.jpg"
rm -f $file
echo "$file converted"
done
@cengizhancaliskan
cengizhancaliskan / country_to_tr.py
Created November 11, 2017 21:57
python turkish location
import sys
import re
import json
import unidecode
def slugify(text):
text = unidecode.unidecode(text).lower()
return re.sub(r'\W+', '-', text)
if (sys.version_info[0] < 3):
@cengizhancaliskan
cengizhancaliskan / Slug in MySQL
Created November 25, 2017 19:58
Generate slug in mysql
# generate slug
UPDATE table_name SET slug = replace(trim(lower(name)), ' ', '-');
# check irregular slug..
SELECT * FROM table_name WHERE slug NOT RLIKE '^([a-z0-9]+\-)*[a-z0-9]+$';
@cengizhancaliskan
cengizhancaliskan / gist:f76efdf35a508aa026cf62e58cc49b75
Created December 22, 2017 18:21
os x clean remove elasticsearch
# checks to see if running
launchctl list | grep elasticsearch
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
launchctl remove homebrew.mxcl.elasticsearch
pkill -f elasticsearch
rm -f ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
@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
@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
# 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 / 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"
vcl 4.0;
import directors;
backend app2 {
.host = "10.135.19.167";
.port = "8080";
}
backend app3 {
.host = "10.135.40.246";