Category archives: programming

Unable to Edit or Rotate Images in WordPress

Have you ever experienced the following error in WordPress:

Could Not Load the Preview Image
Could not load the preview image. Please reload the page and try again.
Chances are you have WHM/cPanel and are running ModSecurity with the following rules enabled:

950120, 960015, 981243, 981044, 981049, 950901, 981245, 981243, 981257
If you have access to WHM yourself, you can disable the rules yourself.

  1. Log into WHM
  2. Navigate to Security Center
  3. Click on ModSecurity Tools
  4. Search for each of rules 950120, 960015, 981243, 981044, 981049, 950901, 981245, 981243, 981257
  5. Choose to Disable each rule
  6. Restart Apache after you disable each rule

Get Back the System Sleep Preferences in Mac OS X

I recently purchased a Mac Pro (late 2013) and discovered that the Energy Saver Pane is a little different; most notably, the Computer Sleep slider is missing. Here is how to get it back.

First, use the following terminal commands to determine the model and board ID of your computer:

sysctl hw.model | awk '{ print $2 }'
ioreg -l | awk -F\" '/board-id/ { print $4 }'

Second, navigate to the following folder:

cd /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources/

Third, determine the .plist file that corresponds to the model and board ID of your computer; e.g., Mac-F60DEB81FF30ACF6.plist.

Fourth, modify the file that corresponds to the model and board ID of your computer:

sudo vi /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources/Mac-UDID.plist

Fifth, change the following line:

UnifiedSleepSliderPref

to

UnifiedSleepSliderPref

Sixth, regenerate kext cache by “touching” the Extensions directory:

sudo touch /System/Library/Extensions

Finally, wait a minute just to make sure the system has enough time to finish regenerating the kext cache. Then, reboot your mac.

Alas, you will once again have the two-slider pane.

System Energy Dual Preferences

Make WordPress Print Pretty

Making your WordPress site print-friendly is probably not the first thing on your GTD list. However, the process is relatively straightforward. The simplest method is editing your existing header.php and style.css files.

First, look for the HTML declaration in your theme’s main file, usually header.php. Search for something like this:

<link rel="stylesheet" 
href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

Change the last attribute to:

media="screen, print"

Second, it’s time to edit your theme’s CSS file, usually style.css. Add the following code to the bottom of the stylesheet:

@media print and (color) {
* {
     -webkit-print-color-adjust: exact;
     print-color-adjust: exact;
  }
}

That’s it! If you have caching enabled, remember to empty your cache. Happy printing.

Hide SafeMonk Shortcut on Mac Desktop

SafeMonkI recently installed SafeMonk to encrypt my DropBox files. Unfortunately, SafeMonk adds an unnecessary shortcut to the desktop. Below is a nifty trick to hide that shortcut.

Open a terminal session, type “SetFile -a V”, and drag the SafeMonk shortcut onto the terminal window. You should observe an output along following lines:

# sudo SetFile -a V /Users/[username]/Dropbox/SafeMonk

Press enter and type in your password after the prompt. The above command “SetFile” sets the invisible extended attribute on the SafeMonk folder. You will next need to relaunch Finder for this setting to take effect. You can do this by entering “killall Finder” in your terminal session. Finally, you might want to put an alias (not a symlink) of the SafeMonk folder in your Dropbox folder.

five Mac OS X Snow Leopard Tweaks I Can’t Live Without

1.) Always view Mail.app attachments as icons.

defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes

Restart Mail.app, and voila!

2.) Use a spacer to split the Dock between Docked applications and non-Docked applications.

defaults write com.apple.dock persistent-apps -array-add
'{"tile-type"="spacer-tile";}' && killall Dock

3.) Add one or more stacks of recently used items.

defaults write com.apple.dock persistent-others -array-add 
'{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' 
&& killall Dock

4.) Enable new List view in Dock Stacks.

defaults write com.apple.dock use-new-list-stack -bool yes 
&& killall Dock

5.) Enables gradient effect on mouse over.

defaults write com.apple.dock mouse-over-hilite-stack -boolean yes 
&& killall Dock

How to create an mp3 Google search box for your website

Have you ever wanted to add a specialty Google search box for your website that only found mp3, xls, doc, or other files of specific extensions? Well using a little JavaScript and tweaking Google’s code, it’s very simple to add a specialty Google search box to your website.

Here’s an example of a search box that only finds mp3 files.
Try searching for Daft Punk

Google

Amazing, so how did I do this? Here’s the original JavaScript from Google to add a standard web search box to your website:

<!-- Search Google -->
<center>
<FORM method=GET action="http://www.google.com/search">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<TABLE style="background-color:#ffffff;"><tr><td>
<A HREF="http://www.google.com/">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif" ALT="Google" align="absmiddle" style="border:0;"></A>
<INPUT TYPE=text name=q size=25 maxlength=255 value="">
<INPUT type=submit name=btnG VALUE="Google Search">
</td></tr></TABLE>
</FORM>
</center>
<!-- Search Google -->

Here’s a little JavaScript you need to find only mp3 files. Notice, I am just using the “intitle” and “-” syntax to narrow the search results.

<!-- Search Script -->
function submitform() {
       var new_query="intitle:index.of \"mp3\" \"" +document.gs.query.value +"\"-htm -html -php -asp \"Last Modified\"";
       document.gs.query.value=new_query;
       }
<!-- End Search Script -->

In the above code, document.gs.query.value is just what the user originally typed.
Here’s the revised Google search code that implements the above JavaScript to make a specialty Google search happen:

<script type='text/javascript' src='search.js'></script>
<!-- Search Google --><center><form action="http://www.google.com/search" method="get" name="gs" onsubmit="return submitform();" ><input type="hidden" value="UTF-8" name="ie" /> <input type="hidden" value="UTF-8" name="oe" /><table style="background-color:#ffffff;">
<tr>
<td><a href="http://www.google.com/"> <img style="border:0;" alt="Google" src="http://www.google.com/logos/Logo_40wht.gif" /></a> <input type="text" maxlength="255" size="25" name="query" /> <input type="submit" value="mp3 Search" name="btnG" /></td>
</tr>
</table>
</form>
</center>
<!-- Search Google -->

If you wanted to make some money, you could modify Google’s Adsense Search Box to search for only mp3, mp4, mpeg, etc… However, that would violate the Google’s Adsense Terms of Service.