Skip to content

Instantly share code, notes, and snippets.

@Rodrigo54
Rodrigo54 / php-html-css-js-minifier.php
Last active April 4, 2026 00:29 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active March 20, 2025 17:17
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
@brentonstrine
brentonstrine / css-compress.php
Last active January 23, 2026 20:30 — forked from manastungare/css-compress.php
Fix space removal so that it doesn't break space-separated values where the developer used more than one space to separate values.
<?php
/**
* On-the-fly CSS Compression
* Copyright (c) 2009 and onwards, Manas Tungare.
* Creative Commons Attribution, Share-Alike.
*
* In order to minimize the number and size of HTTP requests for CSS content,
* this script combines multiple CSS files into a single file and compresses
* it on-the-fly.
*
@egulhan
egulhan / ResizeImage.php
Created July 24, 2014 13:56
Resize Image Class With PHP
<?php
// @source: http://www.paulund.co.uk/resize-image-class-php
/**
* Resize image class will allow you to resize an image
*
* Can resize to exact size
* Max width size while keep aspect ratio
* Max height size while keep aspect ratio
* Automatic while keep aspect ratio
@Fysac
Fysac / counter.php
Last active January 20, 2023 17:28
Database-less, sessionless way to count online users in PHP.
<?php
$timeout = 300; // 5 minutes
$time = time();
$ip = $_SERVER["REMOTE_ADDR"];
$file = "users.txt";
$arr = file($file);
$users = 0;
for ($i = 0; $i < count($arr); $i++){
if ($time - intval(substr($arr[$i], strpos($arr[$i], " ") + 4)) > $timeout){
@derapU
derapU / upload-download-progress-events-for-jquery-ajax.js
Last active August 29, 2015 13:57
add progress events for upload and download to jquery.ajax (xhr2)
jQuery( function ( $ ) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup( {
progress: function () {},
uploadprogress: function () {},
xhr: function () {
var req = originalXhr(),
self = this;
if ( req ) {
@devluis
devluis / live-word-counter-jquery
Created December 6, 2013 05:35
Live Word and Character Counter using jQuery
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Live Word and Character Counter using jQuery</title>
<style>
textarea{
@luckyshot
luckyshot / response.php
Last active November 1, 2024 08:20
Web scraping done right (with cUrl and user agent)
<?php return array (
'url' => 'https://xaviesteve.com/',
'content' => '<!doctype html><html>...</html>',
'cookies' => '__cfduid=d3fa669e1069e72c2e47d127ab9b8e11f1465390629',
'http_code' => 200,
'content_type' => 'text/html; charset=UTF-8',
'header_size' => 578,
'request_size' => 229,
'filetime' => -1,
'ssl_verify_result' => 0,
@chenha0
chenha0 / speedtest.html
Created March 25, 2013 15:58
js download and upload speed test
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var str = '1';
for (var dup = 0; dup < 20; dup++) {
str += str;