Skip to content

Instantly share code, notes, and snippets.

@NeilJS
NeilJS / gist:32ac664f846bdea9aac25a428fe3727a
Created Sep 30, 2019
Chrome snippet: designMode="on" + kill all links
View gist:32ac664f846bdea9aac25a428fe3727a
// Disable anchor links
window.addEventListener("click", function (event) {
event.preventDefault();
});
// Disable click eventlisteners
window.addEventListener("click", function (event) {
event.stopPropagation();
}, true);
// design mode on
document.designMode = "on";
View genesis_public_key
049e0cd87735e5682ccd20f6017e7d72e540eda8fe0344d3a5d24c6f37ab692952d678dfa729069abcd475de9321354639f1ea6c6e57c21c2a9d493fb50fdf5832;callmejimmyj
@NeilJS
NeilJS / sslcrt-with-subjectAltName.txt
Last active May 4, 2017
Generate self-signed ssl cert (Virtualbox Ubuntu) - fix for Chrome 58 requirement for subjectAltName / Subject Alternative Name
View sslcrt-with-subjectAltName.txt
# Update refs to .example.com
sudo su
openssl req -x509 -nodes -sha256 -days 3650 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -new -out /etc/apache2/ssl/apache.crt -subj /C=GB/ST=London/L=London/O="Company Name"/OU=Team/CN=www.example.com -reqexts SAN -extensions SAN -config <(cat /usr/lib/ssl/openssl.cnf <(printf '[ SAN ]\nsubjectAltName=DNS:www.example.com,DNS:example.com,DNS:*.example.com'))
exit
sudo service apache2 restart
# On Windows, trust the certificate: save the new certificate from Chrome to desktop (via Devtools > Security > View > Details > Copy to file; use DER option)
# May need to delete any previously imported certificates via mmc (on Windows)
# Run mmc; add the Certificates snap-in; import from desktop to 'Trusted Roots Certification Authorities' and also 'Other People'
# May need to clear Chrome history + SSLs (Settings > Network > Change proxy settings... > Content > Clear SSL state)
@NeilJS
NeilJS / gist:6ff52bcd4c9a91435a35
Created Feb 12, 2015
Responsive text - dynamic body font size
View gist:6ff52bcd4c9a91435a35
<!DOCTYPE html>
<html lang="en" class="js">
<head>
<meta charset="UTF-8">
<title>Responsive text sizes</title>
<style>
h1 {font-size: 1.6em;}
p {font-size: 1em;}
@NeilJS
NeilJS / gist:6726336
Created Sep 27, 2013
Get array of categories/tags/custom taxonomy objects (as opposed to just outputting html or a list), for further manipulation. This is a slightly modified version of wp_list_categories() - but saved in functions.php!
View gist:6726336
function wp_get_categories( $args = '' ) {
$defaults = array(
'show_option_all' => '', 'show_option_none' => __('No categories'),
'orderby' => 'name', 'order' => 'ASC',
'style' => 'list',
'show_count' => 0, 'hide_empty' => 1,
'use_desc_for_title' => 1, 'child_of' => 0,
'feed' => '', 'feed_type' => '',
'feed_image' => '', 'exclude' => '',
'exclude_tree' => '', 'current_category' => 0,
@NeilJS
NeilJS / gist:5900183
Created Jul 1, 2013
Create a div shortcode - so you can wrap content in a div in the WordPress editor. Usage: [div id="ID" class="CLASS"]xxxx[/div]
View gist:5900183
# For Functions.php
// DIV SHORTCODE. Usage: [div id="ID" class="CLASS"]xxxx[/div]
function createDiv($atts, $content = null) {
extract(shortcode_atts(array(
'id' => "",
'class' => "",
), $atts));
return '<div id="'. $id . '" class="'. $class . '" />' . $content . '</div>';
}
add_shortcode('div', 'createDiv');
@NeilJS
NeilJS / gist:5487368
Created Apr 30, 2013
Fade in elements in consecutive order.
View gist:5487368
// Fade in divs consecutively (optional delay)
var delayBetweenEach = 300;
var fadeSpeed = 400;
$(".myDiv").delay(1000).each(function(index) {$(this).delay(delayBetweenEach*index).fadeIn(fadeSpeed);});
@NeilJS
NeilJS / gist:4269982
Created Dec 12, 2012
jQuery fix for click events in iOS
View gist:4269982
// Using Modernizr to detect mobile in this case. More specific for iOS may be better.
var event = (Modernizr.touch) ? "touchstart" : "click";
$("#element").bind(event, function(e) {
// do it
}
@NeilJS
NeilJS / Twitterify
Created Aug 10, 2012
Convert plain twitter urls, usernames, hashtags into clickable hyperlinks
View Twitterify
function twitterify($ret) {
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $ret);
$ret = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $ret);
return $ret;
}
#Thanks: http://www.snipe.net/2009/09/php-twitter-clickable-links/
@NeilJS
NeilJS / gist:2916810
Created Jun 12, 2012
Get tag id by name
View gist:2916810
<?php
function get_tag_id_by_name($tag_name) {
global $wpdb;
$tag_ID = $wpdb->get_var("SELECT * FROM ".$wpdb->terms." WHERE `name` = '".$tag_name."'");
return $tag_ID;
}
?>
You can’t perform that action at this time.