Skip to content

Instantly share code, notes, and snippets.

@nielsenrc
nielsenrc / bash-get-apache-version-number.txt
Created September 9, 2015 19:40
Bash | Get Apache Version Number
httpd -v
@nielsenrc
nielsenrc / php-get-contents-of-robots-txt-file.php
Created September 9, 2015 19:43
PHP | Get Contents of Robots.txt File for a Text File of Domains
<?php
//Purpose to Check Contents of the Robots.txt File for a Series of Domains in a Local Text File
//define text file location
$old_url_text_file = "list.txt";
//get contents of text file
$old_url_list = file_get_contents($old_url_text_file);
//process text file
$old_urls = explode("\n", $old_url_list);
$old_urls = array_filter(array_map('trim', $old_urls));
//loop through text files
@nielsenrc
nielsenrc / wp-add-lines-to-wordpress-robots.php
Created September 9, 2015 19:45
PHP | Add lines to dynamic Wordpress robots.txt
function virtual_robots_disallow( $output, $public ) {
$output .= "\n" . 'Disallow: /backup' . "\n";
return $output;
}
add_filter( 'robots_txt', 'virtual_robots_disallow', 10, 2 );
@nielsenrc
nielsenrc / 410-redirect.txt
Created September 9, 2015 19:46
htaccess | Apache 410 Redirect
errordocument 410 default
redirectmatch 410 /url/
@nielsenrc
nielsenrc / css-vertically-center-line-of-text.css
Created September 9, 2015 19:48
CSS | Vertically Center Line of Text in a Container
#box {
height: 90px;
line-height: 90px;
}
@nielsenrc
nielsenrc / mysql-dump-single-table.txt
Created September 9, 2015 19:49
MySQL | Dump a Single Table at Command Line
mysqldump db_name table_name > table_name.sql
@nielsenrc
nielsenrc / cli-search-for-files-containing-string.txt
Created September 9, 2015 19:50
CLI | Search for Files Containing String
grep -lr "text-you-are-searching-for" .
@nielsenrc
nielsenrc / wordopress-create-virtual-file-in-plugin.php
Created September 9, 2015 20:10
Wordpress | Create Virtual File in Wordpress Plugin
<?php
//assumes you have a locations.php file in your plugin folder
function advnap_kml() {
$url = str_replace( trailingslashit( site_url() ), '', plugins_url( '/locations.php', __FILE__ ) );
add_rewrite_rule( 'locations\\.kml$', $url, 'top' );
}
add_action( 'wp_loaded', 'advnap_kml' );
function advnap_plugin_activate() {
flush_rewrite_rules();
@nielsenrc
nielsenrc / wordpress-no-index-paginated-pages.php
Created September 9, 2015 20:21
Wordpress | Add no index to paginated pages
<?php if ( is_paged() ) { ?>
<meta name="robots" content="noindex,follow" />
<?php } ?>
@nielsenrc
nielsenrc / mysql-cms-made-simple-find-replace.sql
Last active September 9, 2015 20:22
MySQL | CMS Made Simple | Content Find and Replace
UPDATE cms_content_props SET content = REPLACE(content,'find','replace');