Add CSS Class to body when Sidebar is Present
Here's the problem I was having while working on a custom theme for a client. Certain pages, posts, tag pages, archive pages, and custom pages either had the sidebar, or did not have the sidebar. The main content div #ContentW
had a 72% width when the sidebar was present, otherwise it was 96%. The problem was that I dislike having to do things manually when they can be automated through code. What I was having to do was manually add/remove page-specific classes to the css file to reflect whether the sidebar was present on that page or not.
3 Ways to Serve PDF Files using Htaccess Cookies, Headers, Rewrites
FYI, using the Mod_Rewrite Variables Cheatsheet makes this example, and all advanced .htaccess code easier to understand. This demo lets you set a cookie with 1 of 3 values, then you just request the pdf file with a normal link click and get 1 of 3 different responses. This is accomplished with a nice bit of .htaccess code.
Set PDF Viewing Mode - Make a selection, then click the view pdf button.
Inline Download Save As View PDF using selected mode »
Javascript Snippet to Add HTML, CSS, and FEED Validation Links
Here's an example of validation links from the AskApache footer.
RSS | XHTML 1.1 | CSS 2.1
document.getElementById("validat").innerHTML += ' | <a href="http://feedvalidator.org/check.cgi?url=https://www.askapache.com/feed/">RSS</a> | <a href="http://validator.w3.org/check/referer?ss=1;outline=1;sp=1;debug">XHTML 1.1</a> | <a href="http://jigsaw.w3.org/css-validator/check/referer?warning=0">CSS 2.1</a>';
Enhanced printenv Script for Server Debugging
A souped-up version of the Apache printenv script for hard-core server environment debuggery.
#!/bin/sh echo -e "Content-type: text/plainnn" ... __T "CURRENT PROCESS CMDLINE" { for p in `echo /proc/[0-9]*/cmdline`; do pid=${p:6:$((${#p}-13))} [[ $pid == $PPID || $pid == $$ ]] && continue; __M "[ /proc/$pid ]"; sed 's/x00/ /g;G' $p 2>/dev/null done } fi
Windows Batch Script saves Screenshots every 10min
Terminal Escape Code Zen
An image and technicacl achievement so profound, it will touch yoour heart.. So 3D... it'll hurt you eyes! LOL.. lol.. Man I am cracking up here. haha Ha definately the best intro ever, those really do look 3D for terminal though huh.. Sweet. Here is the little function I wrote to output that grey marble.
HTTP Status Codes and Htaccess ErrorDocuments
There are a total of 57 HTTP Status Codes recognized by the Apache Web Server. Wouldn't you like to see what all those headers and their output, ErrorDocuments look like?
PHP to handle HTTP Status Codes for ErrorDocument
Fast, HTTP Protocol, protection. If you are reading this article, you already know enough about the benefits of making sure your site can handle HTTP Protocol Errors. This is a nice single php file with no dependencies or requirements, will work on anything. Optimized for minimizing bandwidth and resource-hogging connections from bots and spambots.
<?php ob_start(); @set_time_limit(5); @ini_set('memory_limit', '64M'); @ini_set('display_errors', 'Off'); error_reporting(0);
Adding YouTube Videos To Website, 4 Methods
This is the advanced example. It uses the jw flv player to create a flash proxy. This basically lets me control the youtube video as if it were a local .f4v file. With this method I can specify any options, autostart, volume, playlists, etc.. But it's rather complex so lets start with 3 other methods to embed YouTube video.