Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / movie-calendar.md
Last active August 9, 2023 02:37
365 Days of Movies - A work in progress. Each day corresponds with a date mentioned or relevant in the movie.

365 Days of Movies

January 1 - Rocky

January 6 - Sherlock Holmes

January 11 - Goodfellas

January 20 - The Fugitive

@8ctopotamus
8ctopotamus / count-repeater-fields-in-acf-flexible-content-example.php
Last active February 23, 2024 20:58
Count number of repeater fields in ACF flexible content.
// Source: https://katienelson.co.uk/developer-acf-counting-repeater-rows-inside-flexible-content/
// The following code doesn’t work with a repeater field if it is part of a flexible content block.
<?php
if(have_rows('card')):
$cards = get_sub_field('card');
$number_of_cards = count($cards);
endif;
?>
@projectivemotion
projectivemotion / php-unresolved-symlinked-path.php
Last active May 25, 2018 18:45
Get unresolved path of symlinked php file. Does the opposite of realpath().
<?php
/**
* Returns the Symlink (Non-Realpath) of the current script.
* I am not so sure how well this function works from inside include's.
* Use case:
*
* [amado@gravedigger phpcode]$ php -f subdir/mysymlink/subdir/mysymlink/subdir/mysymlink/app.php
* PWD: /tmp/phpcode
* SCRIPT_FILENAME: subdir/mysymlink/subdir/mysymlink/subdir/mysymlink/app.php
* ___FILE__ : /tmp/phpcode/app.php
@solepixel
solepixel / .htaccess
Last active February 13, 2024 15:00
This htaccess snippet (lines 4-12) will pull any missing images from another URL. Helpful when developing locally or on a staging site where media is present on production but is too much to migrate to staging or locally.
<IfModule mod_rewrite.c>
RewriteEngine On
# BEGIN Use uploads directory from Live Site
RewriteBase /wp-content/uploads/
RewriteCond %{HTTP_HOST} !^www\.livedomain\.com
RewriteCond %{HTTP_HOST} !^livedomain\.com
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@verticalgrain
verticalgrain / gf-email-validate.php
Created May 28, 2015 18:19
Email validation in Gravity Forms - validate an email address entered in a regular text input
<?
/**
* Hooks for validating an email address in Gravity Forms
* When using a plain text input to collect an email, this will validate that the email address entered is a proper email address
* Useful for situations in which the existing gravity forms email field can't be used
*
* Change line 28 and line 37 to adapt this to your form
*
* @package d7
@solepixel
solepixel / im-bruce-willis.lyrics.txt
Last active May 14, 2018 14:14
I'm Bruce Willis by Wreck&Salvage (https://vimeo.com/13033974)
Yeah
Yo, why you tryin' to hurt me girl
Don'tcha know I'm Bruce Willis.
Yeah
Yo, why you tryin' to hurt me girl
Don'tcha know I'm Bruce, Bruce
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//