Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Cernis nickcernis

  • Innsbruck, Austria
View GitHub Profile
@nickcernis
nickcernis / readme.md
Last active Nov 15, 2020
Exclude node_modules and .git from Backblaze backups on Mac
View readme.md

Exclude node_modules and .git from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add these rules inside the bzexclusions tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
@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 / functions.php
Last active Sep 6, 2020
Genesis Simple Share Shortcode
View functions.php
<?php
// Adds a [social-icons] shortcode to output Genesis Simple Share icons in posts
// https://wordpress.org/plugins/genesis-simple-share/
// Add the code below to your active theme's functions.php file,
// or use in a site-specific plugin.
// The shortcode takes no attributes; change your icon settings via Genesis → Simple Share.
add_shortcode( 'social-icons', 'gss_shortcode' );
@nickcernis
nickcernis / mailchimp-popup-for-wordpress.md
Last active Aug 11, 2020
MailChimp Popup Script that works with WordPress sites
View mailchimp-popup-for-wordpress.md

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

<script>
@nickcernis
nickcernis / functions.php
Last active Aug 6, 2020
Count widgets that are active for the current WPML language
View functions.php
<?php
/**
* Count widgets in a given sidebar, taking WPML language switching into account.
*
* Assumes widget languages are switched with the WPML String Translation or WPML Widgets plugins.
*
* @param string $id The sidebar ID.
*
* @return int The count of widgets in the sidebar.
@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
Created Dec 4, 2014
Add or edit the notes before the WordPress comments form
View functions.php
<?php // remove this line
// Add or edit the notes before the comments form
add_filter( 'comment_form_defaults', 'sp_add_comment_form_before' );
function sp_add_comment_form_before( $defaults ) {
$defaults['comment_notes_before'] = '<p class="comment-notes">Your email address will not be published. Required fields are marked <span class="required">*</span></p>';
return $defaults;
}
@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.
*/
You can’t perform that action at this time.