Internity

You’re not as old as the trees
Not as young as the leaves
You’re not as free as the breeze
Not as open as the seas
And your heart hasn’t found a home
Endlessly it seems to roam
But one day you will find inexhaustable ecstacy
And you will see…

That you’re beautiful and always have been
And everybody else can see
The love that you’ve been looking for
Is right there inside your door

Little Miss Divinity,
You’re the one that you’ve been looking for
Little Miss Divinity,
Won’t you lay your love on thee

And if you need a friend, I’ll be sailing right by your side
And if you need a lover, you must leave it all behind
And if you need direction, no one can be seen unkind
So listen closely my love, you have time
You’re doing fine

Future Sound of London: The Isness – Divinity

 

Agent Cooper Helps Leland Die

Leland, the time has come for you to seek the path. Your soul has set you face to face with a clear light. And you are now about to experience it in its reality. Wherein all things are like the void and cloudless sky. And the naked spotless intellect is like a transparent vacuum. Without circumference or center. Leland, in this moment know yourself. And abide in that state. Look to the light, Leland. Find the light. Into the light.

— Agent Cooper

Javascript Slugify

Javascript function to “slugify” a string:

function slugify ( str ) {
  str   = str.toLowerCase();
  str   = str.replace( /\s/gi, "-" );
  str   = str.replace( /\//gi, "-" );
  str   = str.replace( /[^-a-zA-Z0-9,&/\\s]+/ig, '' );
  
  // Trim dash from beginning, end.
  while( str.substr( 0, 1 ) == '-' )  str   = str.substr( 1 );
  while( str.substr( -1 ) == '-' )    str   = str.substr( 0, str.length -1 );
  
  return str;
}

Windows Recursively Delete Folders

Dreamweaver creates _notes folders in each directory when you upload a file. Recently switched to Aptana and wanted to remove all of these folders that are now useless clutter in my filesystem. Here’s how to do it on Windows CLI in one fell swoop:

> cd \path\to\my\project\folder
> for /d /r . %d in (_notes) do @if exist "%d" rd /s/q "%d"

Links

Stack Overflow
Index of Windows CLI

WordPress Menu Posts

Making a Menu containing a bunch of Posts is a good way to create a Page with custom ordering/selection. The new WordPress Menus make it really easy to drag and drop and they give you the option to add Posts in the Screen Options tab.

If you want to swap out Menus in your Theme’s Menu Location frequently, it could get PITA to update your Theme every time you make a new Menu. Here’s how to get those Posts to display on your site with only knowing your Theme’s Menu Location slug instead of hard coding the Menu’s slug into your Theme:

// ---	Get the menu locations. Returns array of ( slugs => ids )
//		The menu location slugs are set in the theme's functions.php file. 
//		@see http://codex.wordpress.org/Function_Reference/register_nav_menus
$menuloc 	= get_nav_menu_locations();
$menuid 	= $menuloc[ 'my-themes-menu-location-slug' ];

// ---	Get the currently assigned containing menu and associated posts.
$menuposts 	= wp_get_nav_menu_items( $menuid );

Filter Access by IP Address

This is a code snippet to keep unwanted visitors out while a site is under construction or being updated. The associative array helps to keep record of the identity of the user’s IP instead of just a collection of numbers with no semantic association. The $filter_ips value makes it easy to toggle the filtering on/off.

<?php
// ---	Filter vitsitor's IP address and bounce those not in the list.
$bounce_url 	= '/maintenance.php';
$filter_ips 	= true;
$allow_ips 	= array (
	'ORG: Firstname Lastname' 	=> '00.00.00.00'
);
if ( $filter_ips && !in_array ( $_SERVER[ 'REMOTE_ADDR' ], $allow_ips ) ) {
	header ( "location: $bounce_url" );
	exit ();
}
?>

It’s also helpful to output the user’s IP address on your bounce page so user’s trying to gain access can easily copy/paste their IP to send to you:

<?php echo $_SERVER[ 'REMOTE_ADDR' ]; ?>