Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Cernis nickcernis

  • Innsbruck, Austria
View GitHub Profile
@nickcernis
nickcernis / old-version-homebrew.md
Last active Nov 13, 2020
Install an old version with homebrew for macOS
View old-version-homebrew.md
  1. Find the formula for the version you want to install:

    • Visit https://github.com/Homebrew/homebrew-core/tree/master/Formula
    • Click the file with your formula (e.g. “composer.rb”)
    • Click “History” (top right)
    • Click the commit hash for the version you want to download
    • Click the three dots (top right of diff) and choose “view file”
    • Click “Raw” and copy the raw URL from the browser address bar.

    For example, composer 1.10.15 lives here: https://github.com/Homebrew/homebrew-core/blob/9e6e6a1ca8551901bff69d329c7fbb9007064134/Formula/composer.rb

@nickcernis
nickcernis / docker-cleanup.md
Last active Sep 16, 2020
Docker commands to remove all containers and images
View docker-cleanup.md

docker kill $(docker ps -q) to kill all running containers
docker rm $(docker ps -a -q) to delete all stopped containers.
docker rmi $(docker images -q) to delete all images.

@nickcernis
nickcernis / mariadb-brew-macos.md
Created Jul 13, 2020
Install MariaDB with brew on macOS and fix the “access denied” issue
View mariadb-brew-macos.md

Attempting mysql -u root fails with Access denied for user 'root'@'localhost immediately after doing brew install mariadb and starting mariadb with brew services start mariadb.

To fix it (with MariaDB still running):

  1. sudo mysql then enter your Mac user password
  2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'newrootpassword'; replacing newrootpassword with the password you wish to use for the MariaDB root user.
  3. Ctrl-C to exit mysql.

You should then be able to connect to MariaDB with mysql -u root -p, then entering the root password when prompted.

View keybase.md

Keybase proof

I hereby claim:

  • I am nickcernis on github.
  • I am nickcernis (https://keybase.io/nickcernis) on keybase.
  • I have a public key ASBvU4zu6cS48NykeyxX4A6zupanqwouo_gAEMuMysQSBgo

To claim this, I am signing this object:

@nickcernis
nickcernis / functions.php
Last active May 12, 2020
Wrap Genesis titles with a link on singular posts and pages
View functions.php
<?php
add_filter( 'genesis_post_title_output', 'custom_wrap_singular_titles_with_links', 10, 3 );
/**
* Wrap the post title with a link on singular entries.
*
* @param string $output The original title output (title content and tags).
* @param string $wrap The title tag.
* @param string $title The content of the title tag.
* @return string The new title output.
*/
View wp-cli-snippets.md

Delete all menus

wp menu list --format=ids | xargs wp menu delete
@nickcernis
nickcernis / functions.php
Created Feb 18, 2020
Show the day in the heading on Genesis archives, even if an archive has no posts
View functions.php
<?php
remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_headline', 10, 3 );
add_action( 'genesis_archive_title_descriptions', 'custom_do_archive_headings_headline', 10, 3 );
/**
* Adapts archive title to display a date even for days in custom post types that have no posts.
*
* @param string $heading Optional. Archive heading, default is empty string.
* @param string $intro_text Optional. Archive intro text, default is empty string.
* @param string $context Optional. Archive context, default is empty string.
*/
@nickcernis
nickcernis / functions.php
Last active Jan 20, 2020
Set Genesis static homepage site title and entry title heading levels to h1 and h2
View functions.php
<?php
add_filter( 'genesis_entry_title_wrap', 'custom_homepage_title_to_h2' );
/**
* Set page title to h2 on a static homepage if Genesis SEO is not in use.
*
* @param string $wrap The original wrap.
* @return string The new wrap.
*/
function custom_homepage_title_to_h2( $wrap ) {
if ( is_front_page() && ! is_home() && ! genesis_seo_active() ) {
@nickcernis
nickcernis / onboarding.php
Created Aug 7, 2019
Importing different widgets during Genesis one-click theme setup
View onboarding.php
<?php
/**
* Genesis Sample.
*
* Onboarding config to load plugins and homepage content on theme activation.
*
* @package Genesis Sample
* @author StudioPress
* @license GPL-2.0-or-later
* @link https://www.studiopress.com/
@nickcernis
nickcernis / functions.php
Last active Oct 14, 2019
Prevent 'NotAllowedError' and 'user didn't interact with the document first' errors for Vimeo embedded in WordPress. No longer needed in WP 5.3 beta 3 or higher.
View functions.php
add_action( 'wp_enqueue_scripts', 'studiopress_load_newer_vimeo_mediaelement', 100 );
/**
* Replace the mediaelement-vimeo script with a newer version.
*
* This works around an issue in WordPress core that can prevent playback of
* Vimeo videos embedded via the `wp_video_shortcode()` function.
*
* This is caused by WordPress loading an older version of the Vimeo script
* (currently loads 4.2.6), which does not add the 'allow=autoplay'
* attribute to iframes that Chrome now requires to permit video playback as
You can’t perform that action at this time.