This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RateLimit | |
{ | |
protected $totalTimestamp = 0; | |
protected $totalCalls = 0; | |
protected $timestamp = 0; | |
protected $calls = 0; | |
protected $limit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]+$'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vcl 4.0; | |
import directors; | |
backend app2 { | |
.host = "10.135.19.167"; | |
.port = "8080"; | |
} | |
backend app3 { | |
.host = "10.135.40.246"; |
OlderNewer