Skip to content

Instantly share code, notes, and snippets.

@ironsjp
ironsjp / cls.js
Created July 18, 2011 14:42
cache script and css to localStorage (same domain only)
/**
* cache script and css to localStorage (same domain only)
*
* $CLS.style("a.css");
*
* $CLS.script("jquery-1.5.2.min.js").wait()
* .script("a.js")
* .script("b.js")
* .script("c.js")
* .wait(function() {
@dtalley
dtalley / build-site.php
Last active January 17, 2023 07:38
Small PHP script to build a web application from a set of source files, combine it into as few files as possible (as defined by you), and minify/compress everything using a few useful tools. This particular script requires that you have PHP, Ruby, and Java installed, as well as the SASS gem, and you also need the YUICompressor and HTMLCompressor…
<?php
//You can pass -nm into the php script and no minification will occure (for debug purposes)
$minify = true;
foreach($argv as $arg)
{
if( $arg == "-nm" )
{
$minify = false;
}
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
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+');
@geraldvillorente
geraldvillorente / sitemap-crawler.php
Last active September 11, 2023 10:51
Sitemap crawler to test 301 and 404.
/**
* Crawl the sitemap.xml for 301 redirections and 404 errors.
* Source: http://edmondscommerce.github.io/php/crawl-an-xml-sitemap-quality-check-301-and-404.html
*
* To use this script you need to allocate a huge amount of time to maximum_execution_time to
* avoid Fatal error: Maximum execution time...I suggest to run this script on terminal.
* Ex: $ php test-xml.php > ~/Desktop/sitemap-curl-result.txt
*
* For 3000 links the average time the script consumed is around 45 minutes to 1 hour.
*/
@Rodrigo54
Rodrigo54 / php-html-css-js-minifier.php
Last active May 22, 2024 04:25 — 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) {
@martincarlin87
martincarlin87 / gulpfile.js
Last active April 15, 2024 07:08
Example gulpfile for PHP, SASS, Watching, Minifying, Optimising, Live Reload and Deploying
var gulp = require('gulp');
var gutil = require('gulp-util');
var argv = require('minimist')(process.argv);
var prompt = require('gulp-prompt');
var rsync = require('gulp-rsync');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var useref = require('gulp-useref');
@v3l0c1r4pt0r
v3l0c1r4pt0r / update-hekko.sh
Last active October 6, 2021 19:48
Script to regenerate Let's Encrypt certificate and update hekko.pl via DirectAdmin and certbot
#!/bin/sh
# Update hekko.pl SSL certificate page automatically with Let's Encrypt cert
# Provide $login and $pass to your environment to disable manual login page
# Outputs will be generated in CWD !
domain='example.com'
chain='chain.crt'
ca='isrgrootx1.pem'
useragent='Mozilla/5.0 (X11; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0'
cookiefile='.cookies'
@williankeller
williankeller / amp-converter.php
Last active February 18, 2024 12:46
Convert HTML to AMP
<?php
class AMP {
private $html;
/**
* HtmlToAmp constructor.
*/
public function __construct($htmlContent) {
@seoagentur-hamburg
seoagentur-hamburg / .htaccess
Last active May 29, 2024 17:59
UPDATE 2024/03: Perfect .htaccess file for highspeed and security. You can use it for every WordPress-Website without problems. Highspeed and Security - testet on hundreds of Websites. If you are using a WordPress Multisite, change the last part of this file.
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2.0.9 - 03/2024
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://seoagentur-hamburg.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
@fians
fians / optimize.php
Created January 3, 2018 10:24
Optimize Image in PHP using Imagick according Google Pagespeed Recommendation
/**
* Optimize image image
*
* https://developers.google.com/speed/docs/insights/OptimizeImages
* -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB
*
* @access public
* @param string $filePath Path of the file
* @return string Raw image result from the process
*/