Silently Hit or Ping a URL from Windows Command Line

Published on 02/27/2012

Recently, I developed a need to make regular API calls from a WAMP Server on Windows to a Linux web-server. I wanted to ping the URL silently (without launching a browser window).

Fortunately, I found an wonderful, small utility called HTTP-Ping. Within minutes, I was able to setup a quick Batch Script, and a Scheduled Task in Windows to ping the URL whenever I need.

Here are the steps for you to duplicate this process:

  • Download HTTP Ping from: http://www.coretechnologies.com/products/http-ping/
  • Create a file with a .bat extension in the same directory as the http-ping.exe directory
  • Add a line like the following to the .bat file: http-ping -s -n 1 http://example.com/test.php
  • Setup a Scheduled Task in Windows (see references below)

References:

Read the full post . . .

Super-simple way to make the main-content and sidebar even

Published on 02/02/2012

This technique (the CSS solution) is especially great for adding a vertical divider between the sidebar and main-content area on a webpage.

http://stackoverflow.com/a/2168585/973918

Read the full post . . .

Handling fatal errors in PHP with a shutdown function

Published on 11/07/2011

Fatal errors are easy to handle in PHP by simply creating a function to run when the script shuts down.

The example below sets the PHP memory limit to 1mb, then causes a memory limit error which is handled by the custom shutdown function, fatal_errors()

<?php 
	//Turn off normal error handling
	error_reporting( 0 );
 
	//Set the function to run on Fatal Shut Down (not parser errors)
	register_shutdown_function( 'fatal_errors' );
 
	//Set the memory limit to 1mb for this demo
	ini_set('memory_limit','1M');
 
	//Cause a memory error
	$i = 0;
	while(1) {
		$im[$i] = imagecreatetruecolor(200, 547);
		$i++;
	}
 
	//Function: Fatal Errors - This function is called when a fatal error occures
	function fatal_errors() {
	  $error = error_get_last();
		echo '<p>An error occured man!  Here are the details:<br /><br />' . 
			'<strong>Message: </strong>' . $error['message'] . '<br />' . 
			'<strong>File: </strong>' . $error['file'] . '<br />' . 
			'<strong>Line: </strong>' . $error['line'] . '</p>';
	} //End of Function
?>

Read the full post . . .

Checking for an admin or editor in MojoMotor – tip for developers

Published on 08/17/2011

Checking to see if a user is logged in as an admin or editor in MojoMotor is extremely easy for addon developers, however it is not documented.  In your addon code, simply load the auth library and run the methods is_admin() and/or is_editor().  

Read the full post . . .

VPS Hosting Upgrade. Bye ServInt, Hello LiquidWeb

Published on 06/08/2011

Well it’s time to start looking at upgrading my hosting package. I’ve simply out-grown my current setup, and need more resources. For a little over three years now, I have been with the same host, ServInt.NET. I haven’t had any major issues or outages, and my overall experience has been pretty darn good actually. The technicians are not as friendly as I would like, but they are knowledgeable and professional – which is by far more important to me than kindness to me.

Read the full post . . .

Replace Microsoft Word Fancy Quotes Using PHP

Published on 06/01/2011

Recently I’ve been working on a few utility scripts to help with common tasks – one of which for me is converting MS Word Smart (or Fancy) Quotes to standard quotes. IMHO, the best (easiest and most reliable) way to replace MS Word characters is to convert them the HTML Entities first, and then convert the HTML Entities to the proper characters using the PHP function 

Read the full post . . .

About CodeSafari

CodeSafari is maintained by Charles Garrison. Charles is a professional web developer who lives in New Mexico. He loves God, life, his kids, his wife, and his two Akitas.

Categories