Skip to content

Instantly share code, notes, and snippets.

View levnhub's full-sized avatar
🎯
Focusing

Lev N levnhub

🎯
Focusing
View GitHub Profile
@oliveratgithub
oliveratgithub / readme.md
Created January 4, 2019 08:44
Configure the PHP CLI in macOS to use MAMP PHP binaries

Pre-requisites

Find MAMP's installed PHP version(s) you want to use the PHP CLI for:

$ ls -l /Applications/MAMP/bin/php/

Configure PHP CLI in macOS to use MAMP's PHP

  1. First, open your local user's .bash_profile in edit mode, in order to add aliases for accessing the PHP CLI locally
$ pico ~/.bash_profile
@ollietreend
ollietreend / acf-php-to-json.php
Last active August 28, 2025 05:42
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@amboutwe
amboutwe / yoast_seo_breadcrumb_add_woo_shop.php
Last active September 17, 2025 12:07
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@merli129
merli129 / jQuery Page Preload
Last active August 17, 2017 23:16
jQuery Preload
#loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 9999;
@alexsasharegan
alexsasharegan / .htaccess
Created September 7, 2016 00:36
Apache Config for React Router
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
@nicohaemhouts
nicohaemhouts / Limit-the-number-of-lines-in-a-textarea.markdown
Last active January 8, 2025 12:03
Limit the number of lines in a textarea

Limit the number of lines in a textarea

This limits the number of lines of any textarea that has the attribute 'data-limit-rows' set to 'true'. The limit is the 'rows'-attribute of the textarea.

To know how many lines have been entered you have to look at the number of newline characters (\n) in the text. You could do this by splitting text on the newline character, and looking at the length of the resulting array: i.e. myText.split(/\n/g).length; This would work fine in every browser, except for one special case in Internet Explorer 8, whereby the user hits the enter key several times in a row, thus producing empty lines. In this case Internet Explorer 8 excludes all empty values from the resulting array, ie those places where the delimiters appear next to each other. The result is that the usr can enter more lines of text than permitted. This is probably also true for Internet Explorer versions lower than 8, but I didn't check.

To know which key was pressed it's b

@raaar
raaar / php
Created July 28, 2012 13:50
WORDPRESS: Loop Custom Taxonomy in custom Post type
<?php // loop for taxonomy in custom post-type
$argsMine = array(
'numberposts' => -1,
'orderby' => 'desc',
'post_type' => 'info',
'section' => 'minesweeper',
'post_status' => 'publish'
);
$postslist = get_posts($argsMine);
foreach ($postslist as $post) :