Skip to content

Instantly share code, notes, and snippets.

View petervansark's full-sized avatar

Peter van Sark petervansark

View GitHub Profile

Estimation

This document is an attempt to pin down all the things you don't think about when quoting for a project, and hopefully provide a starting point for some kind of framework to make quoting, working and delivering small-medium jobs more predictable and less stressful.

Contents

@petervansark
petervansark / fpm_get_status_with_auth.php
Created June 2, 2025 13:56 — forked from Cojad/fpm_get_status_with_auth.php
PHP-FPM real-time status page (Single file without the need for web server configuration) with simple auth
<?php
// Use HTTP Basic Authentication for verification
$username = 'admin';
$password = 'Passw0rd!'; // Please use your own password!!
// Check if the client has provided correct credentials
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $username || $_SERVER['PHP_AUTH_PW'] !== $password) {
// Send authentication request headers
header('WWW-Authenticate: Basic realm="Restricted Area"');
header('HTTP/1.0 401 Unauthorized');
@petervansark
petervansark / receive_post.php
Created April 2, 2025 08:35 — forked from edstenson/receive_post.php
PHP example to receive an HTTP POST request from Push
<?php
file_put_contents('/tmp/ds.' . microtime(true) . '.json', file_get_contents('php://input'));
echo json_encode(array('success' => true));
@petervansark
petervansark / maintenance.php
Last active April 12, 2025 19:25 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<?php http_response_code(500); ?>
<?php
$time_to_wait = 7200; // in seconds
$site_title = 'PHKHotdeals';
$contact_link = 'https://t.me/leinad8th'; // Exemple: 'xx@xx.xx', 'https://xx.xx.xx', 'https://discord.com/invite/xxx'
$logo_path = './logo-light.png'; // Spécifiez le chemin du logo
$logo_link = 'mailto:hello@phktopdeals.com'; // Spécifiez le lien du logo
$facebook_link = 'https://www.facebook.com/phktopdeals'; // Spécifiez le lien Facebook
$linkedin_link = 'https://www.linkedin.com/in/phktopdeals/'; // Spécifiez le lien LinkedIn
Shopify objects that contain attributes that can be dynamically put on the page. For example, the product object contains an attribute called title that can be used to output the title of a product.
The handle is used to access the attributes of a Liquid object. By default, it is the object’s title in lowercase with any spaces and special characters replaced by hyphens (-). Every object in Liquid (product, collection, blog, menu) has a handle.
Collections & Products
Collection ►
all_types ►
Returns a list of all the product types for a collection
@petervansark
petervansark / is_ios_safari.js
Created September 17, 2021 14:18 — forked from carloscabo/is_ios_safari.js
JS Detect Safari on iOS devices
(function(){
var
is_ios = /iP(ad|od|hone)/i.test(window.navigator.userAgent),
is_safari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
if ( is_ios && is_safari ) {
var
$html = document.documentElement,
classes = $html.className.concat(' is-ios-safari');
$html.className = classes;
}
<?php
add_filter('the_content', function($content) {
return str_replace(array("<iframe", "</iframe>"), array('<div class="iframe-container"><iframe', "</iframe></div>"), $content);
});
add_filter('embed_oembed_html', function ($html, $url, $attr, $post_id) {
if(strpos($html, 'youtube.com') !== false || strpos($html, 'youtu.be') !== false){
return '<div class="embed-responsive embed-responsive-16by9">' . $html . '</div>';
} else {
@petervansark
petervansark / tmux.md
Created November 29, 2019 10:26 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@petervansark
petervansark / dnsmasq OS X.md
Created August 20, 2019 07:42 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

NOTE this has been done properly by a guy here: https://www.stevenrombauts.be/2018/01/use-dnsmasq-instead-of-etc-hosts/

You should go and do that now, ignore all of this.

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements