Skip to content

Instantly share code, notes, and snippets.

@nielsenrc
nielsenrc / PHP | Show Content Only to My IP.php
Last active January 4, 2016 11:58
PHP | Show Content Only to My IP
<?php
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip == "[ip]"):
//do things
endif;
?>
@nielsenrc
nielsenrc / JS: Google + Asynchronous Snippet.js
Last active April 26, 2016 19:28
JS | Google + Asynchronous Snippet
<script type="text/javascript"
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js?onload=onLoadCallback';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
@nielsenrc
nielsenrc / htaccess | Implement Browser Caching
Last active January 4, 2016 12:39
htaccess: Implement Browser Caching
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/javascript "access 1 month"
@nielsenrc
nielsenrc / robots-deny-all.txt
Last active January 4, 2016 12:39
Robots.txt: Deny All Robots.txt
User-agent: *
Disallow: /
@nielsenrc
nielsenrc / wp-automatic-feed-links.php
Created September 9, 2015 19:26
Fix feed links in Wordpress
@nielsenrc
nielsenrc / force-ssl.txt
Created September 9, 2015 19:29
Enforce SSL in Apache htaccess File
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]
@nielsenrc
nielsenrc / robots-deny-all.html
Created September 9, 2015 19:29
Robots Deny All Meta Tag
<meta name="robots" content="noindex, nofollow">
@nielsenrc
nielsenrc / wp-add-ftp-info.php
Created September 9, 2015 19:32
Add FTP Info to Wordpress wp-config.php
define('FTP_USER', 'username'); // Your FTP username
define('FTP_PASS', 'password'); // Your FTP password
define('FTP_HOST', 'ftp.example.org:21'); // Your FTP URL:Your FTP port
@nielsenrc
nielsenrc / widest-element-on-page.js
Created September 9, 2015 19:37
JS | Find Widest Element on Page with Javascript
var widest = null;
// remember the width of the "widest" element - probably faster than calling .width()
var widestWidth = 0;
$("div").each(function() {
if (widest == null)
{
widest = $(this);
widestWidth = $(this).width();
}
else
@nielsenrc
nielsenrc / vim-delete-all-files-containing-string.txt
Created September 9, 2015 19:39
VIM | Delete All Lines Containing String
:g/profile/d