Skip to content

Instantly share code, notes, and snippets.

View emresaracoglu's full-sized avatar
:atom:
"Every software system is flawed... Every coder is corrupt"

Emre Saraçoğlu emresaracoglu

:atom:
"Every software system is flawed... Every coder is corrupt"
View GitHub Profile
@servergrove
servergrove / backup_mysql.sh
Created January 24, 2012 16:13
Script to backup MySQL
# Configuration.
date=`date +%Y-%m-%d`
bk_dest='/var/archives/mysql'
log_file=$bk_dest/bk_mysql-${date}.log
mysql_cmd='/usr/bin/mysql'
mysqldump_cmd='/usr/bin/mysqldump'
dbuser=root
dbpass=`cat /etc/.mysqlpasswd`
@m4tthumphrey
m4tthumphrey / CronSchedule.php
Last active May 23, 2022 11:29
CronSchedule.php - Allows one to parse a cron expression into human readable text.
<?php
/*
* Plugin: StreamlineFoundation
*
* Class: Schedule
*
* Description: Provides scheduling mechanics including creating a schedule, testing if a specific moment is part of the schedule, moving back
* and forth between scheduled moments in time and translating the created schedule back to a human readable form.
*
* Usage: ::fromCronString() creates a new Schedule class and requires a string in the cron ('* * * * *', $language) format.
@denji
denji / nginx-tuning.md
Last active April 11, 2024 06:45
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@chales
chales / db-connect-test.php
Last active June 3, 2023 01:01
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@luckyshot
luckyshot / geoip.php
Last active November 13, 2020 17:58
PHP - Geolocalization by IP address
<?php
define('GEOIP_CACHE_TIME', 5184000); // 5184000 = 60 days
/**
* Returns the country of an IP address
* If IP is cached and less than 2 months old, otherwhise requests it to geoplugin.com API
*
* @string $ip The IP address
* @bool $justcountry If you want the full array or just the country
@ve3
ve3 / Encryption.js
Last active August 10, 2023 10:51
Encrypt and decrypt between programming languages (PHP & JavaScript). (Newer version here https://gist.github.com/ve3/b16b2dfdceb0e4e24ecd9b9078042197 )
/**
* Encryption class for encrypt/decrypt that works between programming languages.
*
* @author Vee Winch.
* @link https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs Reference.
* @link https://github.com/brix/crypto-js/releases crypto-js.js can be download from here.
*/
class Encryption {
@kshitiz621
kshitiz621 / whois.php
Created March 19, 2019 07:44
PHP code to get WHOIS information of a domain
<?php
/*************************************************************************
php easy :: whois lookup script
==========================================================================
Author: php easy code, www.phpeasycode.com
Web Site: http://www.phpeasycode.com
Contact: webmaster@phpeasycode.com
*************************************************************************/
$domain = $_GET['domain'];