Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
He is trying to focus :)

Emre Saracoglu emresaracoglu

🎯
He is trying to focus :)
View GitHub Profile
@kshitiz621
kshitiz621 / whois.php
Created Mar 19, 2019
PHP code to get WHOIS information of a domain
View whois.php
<?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'];
@ve3
ve3 / Encryption.js
Last active Sep 1, 2021
Encrypt and decrypt between programming languages (PHP & JavaScript).
View Encryption.js
/**
* 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 {
View easy_encrypt_decrypt_strings_with_javascript_with_unicode_support.js
String.prototype.normalise_to_ascii = function(){return unescape(encodeURIComponent(this)); }
String.prototype.normalise_to_unicode = function(){return decodeURIComponent(escape(this)); }
String.prototype.crypt_symmetric = function(key){
var me = this + ""; //unlink reference
key = Number(String(Number(key))) === key ? Number(key) : 13; //optionaly provide key for symmetric-like-""encryption"".
me = me.split('') //to array of characters.
.map(function(c){return c.charCodeAt(0);}) //to array of numbers (each is character's ASCII value)
@luckyshot
luckyshot / geoip.php
Last active Nov 13, 2020
PHP - Geolocalization by IP address
View geoip.php
<?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
@chales
chales / db-connect-test.php
Last active Oct 11, 2021
Script for a quick PHP MySQL DB connection test.
View db-connect-test.php
<?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'");
@denji
denji / nginx-tuning.md
Last active Oct 20, 2021
NGINX tuning for best performance
View nginx-tuning.md

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.

@m4tthumphrey
m4tthumphrey / CronSchedule.php
Last active Aug 20, 2021
CronSchedule.php - Allows one to parse a cron expression into human readable text.
View CronSchedule.php
<?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.
@servergrove
servergrove / backup_mysql.sh
Created Jan 24, 2012
Script to backup MySQL
View backup_mysql.sh
# 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`