All Code

Code Snippet NameSort by Category CategorySort by Category Submitted BySort by Person   Date

Apache Server Info

Other 05/18/12
Use this snippet in your http config file to display a server information page, in apache

Then go to the appropriate hyperlink to view. It wouldn't hurt to add some security to this.

http://xxx.xxx.xxx.xxx/server-status?refresh=5 View Code

Tags

Twitter Bootstrap Walker Classes

Wordpress 04/28/12
I finally broke down and decided to start using twitter bootstrap. I immediately noticed that twitter bootstrap drop-down menus did not work the way I wanted them to. Bootstrap has abandoned hover drop downs in lieu of the click to drop-down system. I created these two WordPress walker classes in ... View Code

Tags

Page Nav Filter

Wordpress 04/20/12
Use this WordPress filter to remove the container and UL produced by the wp_page_menu function. View Code

Tags ,

Reference calling class

PHP 03/02/12
Alright, this is how to reference a calling class in php. It is hard to make the distinction between a parent class, and a calling class.

CallingClass instantiates the class InstanceClass. So from within InstanceClass if you need to access methods or properties of the caller you typically need ... View Code

Tags

Observer pattern

PHP 03/02/12
This is a quick example of the observer design pattern. The pattern allows you to notify the observer of any changes in the subject. This can reduce dependencies and enables you to notify many classes of a single change, at once. View Code

Tags

Root relative file location

PHP 02/28/12
This php snippet will allow you to detect the root relative url of an included php file. This is great for auto detecting file locations, from the file. Basically getting you the url of your current file. PHP self and script file location are for the parent file that includes others. View Code

Tags ,

Session to object

PHP 02/27/12
This class will quickly map a php session variable to a local object. The technique allows you to quickly modify values using arrow syntax. Your local session object, in this case 'my_session' will save session variables as you change them in the object. The actual session is namespaced with the ... View Code

Tags ,

Property overload

PHP 02/24/12
This simplified example of overloading will help you get started in creating dynamic properties in your classes, using PHP magic methods.
View Code

Tags

Stop event propogation

Javascript 02/23/12
Use this javascript technique to prevent events from bubbling from an element to its parent onclick.

The parent div has a function that runs onclick. Normally if you click on a child hyperlink, then the event of the parent will fire. In this case if you want to prevent runFunction() from ... View Code

Tags

Better Truncator

Actionscript 02/20/12
I was having trouble with my limit string snippet http://code.hyperspatial.com/143/shorten-string-in-php/

It
was not working well with long strings with no spaces, like urls. This php snippet will truncate a long url. So if you want to shorten a url for display use this. View Code

Tags

Better mysqli table creation

PHP 02/20/12
This is the latest of the php table creation scripts. This is a suggested technique on php.net for the oop mysqli classes.

Replace the DB constants with your own values. View Code

Tags ,

Action type callbacks

PHP 02/20/12
I don't even want to start rebuilding the Wordpress hook system, but I needed something similar for a straight PHP site.

This html insert system allows you to fire callback functions in a similar manner to do_action(). The system is not set up to pass arguments at this point.

Just make sure ... View Code

Input action on enter

Javascript 02/17/12
This javascript snippet allows you to run javascript or just submit the form on the enter keypress. View Code

Tags

Improved Shortcode

Wordpress 02/15/12
This in an improved version of http://code.hyperspatial.com/1105/function-as-shortcode/ which allows you to use one function for shortcode callbacks. So instead of writing two functions, one for shortcode (must return printed output) and one to call directly, try this output buffer ... View Code

Tags

SSL check

PHP 02/14/12
This is a quick php snippet to check it the page you are on is secured with an ssl. It basically checks the php server superglobal for https View Code

Tags

BP profile data

Buddypress 02/13/12
These are two functions you can use to get Buddypress xprofile data and change said data. View Code

Tags