Skip to content

Instantly share code, notes, and snippets.

View AjmalPraveeN's full-sized avatar
👁️

Ajmal Praveen AjmalPraveeN

👁️
View GitHub Profile
@chrisbloom7
chrisbloom7 / mod_xsendfile_example.php
Created March 4, 2011 04:27
Example of using mod_xsendfile to send a file as a download.
<?php
/**
* In your Apache conf file, set the following to enable XSendfile:
*
<Directory "/">
# This should be handled by the XSendFile module, but a bug in 0.11.1 prevented it from being set properly.
EnableSendfile on
XSendFile on
@psykzz
psykzz / downloader.class.php
Created September 9, 2012 21:51
Simple rate limited downloader.
<?php
/* *
* @filename downloader.class.php
* @author PsyKzz
* @version 1.0.0
* @description Simple class to rate limit your downloads, while also providing a custom tickrate to combat timeout issues.
* @url http://www.psykzz.co.uk
*
* @license 'WTFPL ' - "Do What The Fuck You Want To Public License".
* This program is free software. It comes without any warranty, to
@fzerorubigd
fzerorubigd / dl.php
Created October 16, 2012 12:50
A simple download script with resume and multi-part support
<?php
date_default_timezone_set('GMT');
//1- file we want to serve :
$data_file = "/home/f0rud/Aalto Talk with Linus Torvalds [Full-length].mp4";
$data_size = filesize($data_file); //Size is not zero base
$mime = 'application/otect-stream'; //Mime type of file. to begin download its better to use this.
$filename = basename($data_file); //Name of file, no path included
@ck-on
ck-on / ocp.php
Last active May 18, 2024 22:35
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
@denji
denji / nginx-tuning.md
Last active July 20, 2024 17:33
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.

@liunian
liunian / gist:9338301
Last active July 11, 2024 09:59
Human Readable File Size with PHP
<?php
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
echo human_filesize(filesize('example.zip'));
@kaidesu
kaidesu / gist:9819416
Created March 27, 2014 21:29
PHP/MySQL User's Online Script
CREATE TABLE `user_online` (
`session` char(100) NOT NULL default '',
`time` int(11) NOT NULL default '0'
) TYPE=MyISAM;
@zmwangx
zmwangx / thumbnails.sh
Last active March 3, 2024 15:51
Script to generate thumbnails of a video and combine into one tile image. Uses FFmpeg and ImageMagick.
#!/bin/zsh
# Script to generate thumbnails of a video and combine into one tile image.
#
# CAUTION:
# FFprobe might fail to extract duration info from a MKV container. Use
# ffmpeg -i video.mkv -c:v copy -c:a copy video.mp4
# to swap to an MP4 container.
#
# Dependencies:
# 1. ffmpeg
@fevangelou
fevangelou / my.cnf
Last active July 14, 2024 17:45
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@dkittell
dkittell / PHP-DynamicBreadcrumbs.php
Last active July 21, 2022 18:59
PHP - Dynamic Breadcrumbs
<?php
// Credit goes to Dominic Barnes - http://stackoverflow.com/users/188702/dominic-barnes
// http://stackoverflow.com/questions/2594211/php-simple-dynamic-breadcrumb
// This function will take $_SERVER['REQUEST_URI'] and build a breadcrumb based on the user's current path
function breadcrumbs($separator = ' &raquo; ', $home = 'Home')
{
// This gets the REQUEST_URI (/path/to/file.php), splits the string (using '/') into an array, and then filters out any empty values
$path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)));