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 / 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 / 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 / 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 / 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 / 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;