Skip to content

Instantly share code, notes, and snippets.

View PawelGIX's full-sized avatar

Paweł Gruchociak PawelGIX

View GitHub Profile
@GAS85
GAS85 / http2_apache2_ubuntu20.04.md
Last active April 2, 2025 16:19
How to Enable HTTP/2 in Apache 2.4 on Ubuntu 20.04

Based on https://gist.github.com/GAS85/8dadbcb3c9a7ecbcb6705530c1252831

Requirements

  • A self-managed VPS or dedicated server with Ubuntu 20.04 running Apache 2.4.xx.
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.

Step 1: Install Apache2

Per default it will be apache2 version 2.4.41 what is enought for http2 support.

@jc-torresp
jc-torresp / access-pi-anywhere.md
Created September 21, 2019 05:12
Configuration to access Raspberry Pi from anywhere with UPnP port forwarding

Access Raspberry Pi from anywhere

Dynamic DNS

We need to use so called Dynamic DNS (DDNS) to create and dynamically update a mapping between a chosen domain name and an “external” IP address of our Raspberry Pi (i.e. router IP address).

  • Look for a DDNS provider.
  • Register a new user account.
  • Choose a desire domain name.
  • Configure it on router.
@endurtech
endurtech / wordpress-permissions-fixer.php
Last active September 12, 2023 23:22
Simple php script sets correct directory and file permissions on WordPress and others. Directories are 755, files are 644, .htaccess and wp-config.php is 444.
<?php
/*
** Plugin Name: WordPress Permissions Fixer
** Plugin URI: https://endurtech.com/how-to-fix-wordpress-file-and-folder-permissions/
** Description: Simple php script sets correct directory and file permissions on WordPress and others. Directories are 755, files are 644, wp-config.php is 444.
** Author: Manuel Rodrigues
** Author URI: https://endurtech.com
** Version: 1.1
** Tags: wordpress, php, script, directory, directories, file, files, wp-config.php, chmod, fix
** License: GPL-2.0+
@thedaviddias
thedaviddias / Preload CSS - Not blocking CSS.html
Last active January 17, 2025 15:27
Preload CSS and don't block the DOM with your CSS file request.
<link rel="preload" href="css/global.min.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="css/global.min.css"></noscript>
<script>
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(a){"use strict";var b=function(b,c,d){function j(a){if(e.body)return a();setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
/*! loadCSS rel=preload po
@javilobo8
javilobo8 / download-file.js
Last active May 13, 2025 05:55
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@tbranyen
tbranyen / make-cancellable.js
Last active December 11, 2018 10:02
Make Cancellable Promise
Promise.makeCancellable = promise => {
const deferred = {};
const promise = new Promise((resolve, reject) => {
deferred.reject = reject;
// Invoke the fetch argument with the matching args... only resolve if not
// aborted.
promise
.then(resp => !deferred.aborted && resolve(resp))
.catch(ex => !deferred.aborted && reject(ex));
@rchrd2
rchrd2 / test-php-basic-auth.php
Last active March 16, 2025 12:38 — forked from westonruter/test-php-basic-auth.php
PHP basic auth example
<?php
function require_auth() {
$AUTH_USER = 'admin';
$AUTH_PASS = 'admin';
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
@odan
odan / xampp_php7_xdebug.md
Last active April 9, 2025 13:07
Installing Xdebug for XAMPP
@chadrien
chadrien / AppController.php
Last active November 26, 2021 10:49
CakePHP force trailing slash
<?php
App::uses('TrailingSlashUtil', 'Lib');
App::uses('Controller', 'Controller');
class AppCpontroller extends Controller {
public function redirect ($url, $status = null, $exit = true) {
$url = TrailingSlashRouter::url($url);
@yangshun
yangshun / youtube-vimeo-url-parser.js
Last active June 14, 2023 22:27
YouTube Vimeo URL Parser
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551