Skip to content

Instantly share code, notes, and snippets.

View atelierbram's full-sized avatar

Bram de Haan atelierbram

View GitHub Profile
@atelierbram
atelierbram / include.md
Last active January 28, 2024 18:16
WordPress maintenance - minimal setup

If maintenance.php is in a folder called inc within the WordPress theme folder, then include this code at the top of the header.php file of the theme:

  require_once get_stylesheet_directory() . '/inc/maintenance.php';

Everyone not logged in visiting the website will get the message.

@atelierbram
atelierbram / make-git-store-the-username-and-password.md
Created November 28, 2023 16:26
Make Git store the username and password
  git config --global credential.helper store
@atelierbram
atelierbram / minify-html-output.php
Last active November 18, 2023 13:18
PHP Function to Minify HTML Output
<?php
// start the output buffer
ob_start('compress_page');
?>
<!-- all html content here -->
<?php
// end the buffer, echo the page content
ob_end_flush();
// function that gets rid of tabs, line breaks, and extra spaces
@atelierbram
atelierbram / accordion-step-javascript.markdown
Created September 27, 2023 09:39
accordion: step javascript
@atelierbram
atelierbram / how-to-setup-homebrew-apache-php-mariadb-on-macos.md
Last active February 2, 2024 12:48
How to setup Homebrew, Apache, PHP and MariaDB on macOS

How to setup Homebrew, Apache, PHP and MariaDB on macOS

This guide is intended to assist you in maintaining an up-to-date development environment for macOS using the latest versions of Homebrew, Apache, PHP, and MariaDB.

Make a backup of your computer, but also think about exporting databases of your projects in .sql files from PhpMyAdmin.

XCode Command Line Tools

If you don't already have XCode installed, it's best to first install the command line tools as these will be used by homebrew:

@atelierbram
atelierbram / test.sh
Created September 10, 2023 19:25
Checking syntax highlighting Base2Tone for bash files in VS-Code
#!/usr/bin/env bash
do_something() {
grep --help | grep '\-i'
grep --help | grep -e -i
grep --help | grep -- -i
}
@atelierbram
atelierbram / start-over-in-github.md
Created January 29, 2023 16:00
Start over in Github

Start over in GitHub

  • Create a new branch to point to your old code
  • Delete all the code and commit on master
  • Start your rewrite on master
# checkout the master branch
git checkout master
@atelierbram
atelierbram / jigsaw-static-site-set-active-class-in-navigation-menu.md
Last active January 28, 2023 15:21
Jigsaw Static Site - Set active class in navigation menu

Jigsaw Static Site - Set active class in navigation menu

Set a custom front matter variable "slug" in top of your post.blade.md file which is the same as the filename, here: this-post-example.blade.md

---
extends: _layouts.post
section: content
title: This Post Example
slug: this-post-example
@atelierbram
atelierbram / lazy-loading-video.md
Last active January 17, 2023 12:27
Lazy loading video

Lazy loading video

<video class="lazy" autoplay muted loop playsinline width="610" height="254" poster="one-does-not-simply.jpg">
  <source data-src="one-does-not-simply.webm" type="video/webm">
  <source data-src="one-does-not-simply.mp4" type="video/mp4">
</video>

You'll notice the addition of the poster attribute, which lets you specify a placeholder to occupy the <video> element's space until the video is lazy-loaded. As with the <img> lazy-loading examples, stash the video URL in the data-src attribute on each <source> element. From there, use JavaScript code similar to the Intersection Observer-based image lazy loading examples:

@atelierbram
atelierbram / responsive-images-in-wordpress-with-advanced-custom-fields-pro.md
Last active January 14, 2023 12:25
Responsive images in WordPress using srcset with Advanced Custom Fields Pro plugin

Responsive images in WordPress using srcset with Advanced Custom Fields Pro plugin

in functions.php:

add_filter( 'acf_the_content', 'wp_make_content_images_responsive' );

in template.php:

$image = get_field('my_image');