Skip to content

Instantly share code, notes, and snippets.

View johanoloflindberg's full-sized avatar
💭
Ready to work 😃

WEBBAB johanoloflindberg

💭
Ready to work 😃
View GitHub Profile

RegEx Snippets


Extract URLs

Find all links

Works pretty well in capturing the full URL when using this in a search (like in Sublime Text 2). (https?|ftps?)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/?

@johanoloflindberg
johanoloflindberg / database encoding fix.sql
Created July 4, 2017 03:54 — forked from ericrasch/database encoding fix.sql
Fix WordPress database encoding issues with these MySQL queries... source #1: http://tanyanam.com/technology/fixing-encoding-issues-on-wordpress-comments-display-as-question-marks source #2: http://stackoverflow.com/a/3568144/284091 The 3 groups of repeated queries include the post content, post title, and the post slug.
ALTER DATABASE 'my_wp_database' CHARACTER SET utf8;
ALTER TABLE 'wp_comments' CHARACTER SET utf8;
alter table 'wp_comments' change comment_content comment_content LONGTEXT CHARACTER SET utf8;
alter table 'wp_comments' change comment_author comment_author LONGTEXT CHARACTER SET utf8;
update `wp_posts` set `post_content` = replace(`post_content` ,'á','á');
update `wp_posts` set `post_content` = replace(`post_content` ,'é','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'í©','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'ó','ó');
@johanoloflindberg
johanoloflindberg / TypeKit embed code.php
Created July 4, 2017 03:54 — forked from ericrasch/TypeKit embed code.php
Different methods for loading TypeKit's embed code.
<?php
/**
* TypeKit's default embed code.
* Source: http://help.typekit.com/customer/portal/articles/649336-embed-code
* Avg. Load Time: 191ms; 198ms; 265ms
*/
?>
<script type="text/javascript" src="//use.typekit.net/xxxxxxx.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
@johanoloflindberg
johanoloflindberg / WP Ping Services
Created July 4, 2017 03:54 — forked from ericrasch/WP Ping Services
A list of ping services to use in the WordPress admin.
http://bing.com/webmaster/ping.aspx
http://blo.gs/ping.php
http://blog.goo.ne.jp/XMLRPC
http://blog.with2.net/ping.php
http://blogpingr.de/ping/rpc2
http://blogsearch.google.com/ping/RPC2
http://ping.bitacoras.com/
http://ping.fc2.com/
https://feedburner.google.com/fb/a/ping
http://ping.wordblog.de/
@johanoloflindberg
johanoloflindberg / WP Disable Comments.md
Created July 4, 2017 03:54 — forked from ericrasch/WP Disable Comments.md
If you need to completely shut off all comments/trackbacks/pingbacks in the WordPress Admin

To shut off all comments/trackbacks/pingbacks in the WordPress Admin, the steps for cleanup are:

@johanoloflindberg
johanoloflindberg / Set Custom WP Feeds.php
Created July 4, 2017 03:53 — forked from ericrasch/Set Custom WP Feeds.php
Add this code to your Theme's functions.php file.
<?php
/* =BEGIN: Remove WP generated junk from head
Source: http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/
---------------------------------------------------------------------------------------------------- */
function removeHeadLinks() {
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'feed_links_extra', 3 );

Proper HTML Formatting

Just wanted a simple resource for referencing the proper way to correctly format HTML code.

A Pen by Eric Rasch on CodePen.

License.

<section id="scrollNav-1" class="scroll-nav__section">
<h2>
Title with no class
</h2>
<div>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.</p>
</div>
<hr>
</section>
@johanoloflindberg
johanoloflindberg / HTML5 Keyboard Input Types.js
Created July 4, 2017 03:53 — forked from ericrasch/HTML5 Keyboard Input Types.js
HTML5 Input Types for Touch Keyboards
$('<input type="email" id="lead_email_alt" name="lead[email]" required="required" placeholder="E-mail Address" class=" form field text _lead_email ">').insertAfter('input#lead_email');
$('input#lead_email').remove();
$('<input type="tel" id="lead_phone_alt" name="lead[phone]" required="required" placeholder="Phone Number" class=" form field text phone _lead_phone ">').insertAfter('input#lead_phone');
$('input#lead_phone').remove();
$('<input type="text" autocorrect="off" id="lead_address_alt" name="lead[address]" required="required" placeholder="Street Address" class=" form field text _lead_address ">').insertAfter('input#lead_address');
$('input#lead_address').remove();
$('<input type="number" pattern="\d*" id="lead_zipCode_alt" name="lead[zipCode]" required="required" placeholder="Zip Code" class=" form field text _lead_zipCode ">').insertAfter('input#lead_zipCode');
@johanoloflindberg
johanoloflindberg / Detect WordPress template file.php
Created July 4, 2017 03:53 — forked from ericrasch/Detect WordPress template file.php
Detect + display WordPress template file being used
<?php
/**
* Detect + display WordPress template file being used
* REF: http://www.wpmayor.com/output-name-of-wordpress-template-file-being-used/#comment-8221
*/
add_action('wp_head', 'show_template');
function show_template() {
global $template;
global $current_user;