This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a bash script meant to be run on the command line. Requires imagemagick (apt-get install imagemagick) | |
## THIS WILL OVERWRITE YOUR FILES, uses sudo and may not require it. | |
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '800x600>' -density 72 $file; done | |
### another method using resolution (800*600) | |
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '480000@>' -density 72 $file; done | |
### example of *not* overwriting files | |
for file in /path/to/files/*/*.jpg; do sudo convert $file -resize '800x600>' -density 72 converted-$file; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Money Morning Ticket Export</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
$('.ticket-util').click( function(e) { | |
e.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replace_open_sans() { | |
// Kill the original style | |
wp_deregister_style('open-sans'); | |
// Replace it with your own (just as an example, I included only the 300 weight) | |
wp_register_style( 'open-sans', 'http://fonts.googleapis.com/css?family=Open+Sans:300' ); | |
wp_enqueue_style( 'open-sans'); | |
} | |
add_action( 'wp_enqueue_scripts', 'replace_open_sans' ); | |
// Thanks to @timkinnane | |
add_action( 'admin_enqueue_scripts', 'replace_open_sans' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Crawl a site's public urls to produce a csv list of urls and response codes | |
# This could be reduced into a single command, but I find it helpful to have a list of all urls. | |
# overview: crawl the site to add one url per line in a text file. | |
# NOTE: this must run and complete first. | |
# wget mirror's the site (including static files) | |
# grep files the line with the url on it. | |
# awk grabs the 3rd item (separated by spaces) and writes to urls.txt | |
wget --mirror -p https://domain.com/ 2>&1 | grep '^--' | awk '{ print $3 }' > urls.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file will demonstrate a method to export fields to code. | |
* You can use this to easily create fields using the UI, export to code | |
* and then use in a custom module. Upon installation of the module | |
* your fields and instances will already be set up. | |
*/ | |
// Create the fields you want using the Drupal UI. | |
// On the same site, go to example.com/devel/php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Found: https://steindom.com/articles/exporting-and-creating-field-definitions-drupal-7 | |
// My new favorite developer because of this, "Now that you understand how it works, let me show you some easy tricks to incorporate this into your development workflow." | |
// Fill in these with your desired field details. | |
$entity_type = ''; | |
$field_name = 'field_'; | |
$bundle_name = ''; | |
$info_config = field_info_field($field_name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('the_content','add_my_content'); | |
function add_my_content($content) { | |
$my_custom_text = '<hr><div class="patreonpara"><p><em>PARAGRAPH TEXT</em></p><a href="LINKURL" data-patreon-widget-type="become-patron-button" class="patreonbutton"><img src="FILEURL"></a></div>'; | |
$my_custom_text_other = 'something else'; | |
if(is_single() && !is_home()) { | |
if(in_category('videos')) { | |
$content .= $my_custom_text_other; | |
} else { | |
$content .= $my_custom_text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Siege attempts to recreate real traffic by using a CSV of urls to hit. | |
# This allows you to remove requests for assets, if you're running a CDN. | |
# | |
# c = concurrent users | |
# i = "like the internet would visit" | |
# b = benchmark (no delay needed) | |
# t = time | |
# f = file with urls 1 per line | |
siege -c100 -i -b -t120S -f urls.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run this from the command line. | |
// h/t: http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively#answer-91966 | |
// add read/execute to world, remove write | |
chmod -R u+rwX,g+rwX,o+rX-w path/ | |
// remove read/write/execute from world | |
chmod -R u+rwX,g+rwX,o-rwX path/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* This doesn't work and here's why not. | |
* | |
* The missing piece here has to do with rewrite rules. | |
* The registration process creates new rewrite rules during the process. | |
* This ensures the custom post type is set up appropriately. | |
* Modifying the url structure (which we're doing here) to hierarchical requires a change to the rewrite rules as well. | |
* | |
* The following is the first change you need to make. The rewrite change is not included here. | |
*/ |