I wanted a way to quickly start and stop Apache without having to go into System Prefs every time. This small AppleScript can be placed in the Dock, allowing one-click launching and terminating of Apache. One caveat: In order for this to work, you have to edit /etc -> sudoers to give yourself the ability to launch Apache without having to enter your password -- see man sudoers for help with that process. That's a potential security risk, but as I see it, it's no riskier than allowing System Prefs to launch it via a button.
do shell script "sudo /usr/sbin/apachectl stop"
if result = "/usr/sbin/apachectl stop: httpd (no pid file) ¬
not running" then
do shell script "sudo /usr/sbin/apachectl start"
display dialog "Apache Started" with icon 2 buttons ¬
{"OK"} giving up after 1
else
display dialog "Apache Stopped" with icon 2 buttons ¬
{"OK"} giving up after 1
end if
Enter the script in Script Editor, save it as an application, and drag it into your dock.
This is a hint for all those poor people out there who still have dial up at home, like me. This isn't much of anything just a little something for those lazy people. Using a key editor, I suggest iKey), create a script like this:
tell application "internet connect"
(connect)/(disconnect)
end tell
Using iKey, set the key to launch this script to whatever you want -- I used the Command-F13. When pushed, it automatically connects to the internet for you. The only problem I have found is that it opens the application Internet Connect. If you're like me, and don't like a bunch of applications open in the dock that are pretty useless, it's kind of irritating. Maybe someone could find the command for the little phone thingy in the status bar. That way it wouldn't open anyhting.
[robg adds: I don't have a dial-up account to test this with, but I would think adding "quit" just above the "end tell" would connect to the net and then quit the Internet Connect app -- that's just a guess, though...]
Ever want to ban a specific robot technology from browsing your hosted website? For example, perhaps there's a bot that ignores the robot exclusion rules. Here's how you can do just that -- ban a specific robot or browser from your site. Note that this hint could be helpful for lots of other tasks, like specific behavior according to specific http headers. See Apache's documentation on Module mod_setenvif and Environment Variables in Apache for more info.
It only takes two lines in your httpd.conf file to ban any specific browser or robot. The first is in the <IfModule mod_setenvif.c> section. Somewhere in that section, add:
BrowserMatch "some_text" badbot
Replace some_text with a word that appears in the User-Agent HTTP request header field. For instance, if you wanted to (not that you would!) block the Mozilla browser from your site, use "Mozilla" to replace "some_text".
Then inside your <Directory "/Library/WebServer/Documents"> section, add the following line before the Allow from all line (I removed the comments, showing only the active commands):
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
# The next line is the new addition
deny from env=badbot
Allow from all
</Directory>
What we did is quite straightforward. If the User-Agent field contains "some_text" anywhere inside it, the environment variable 'badbot' is declared; it is non-existent otherwise. Then, when checking for accessibility, if 'badbot' exists, the client is denied.
While about to go to the countryside, I was desperately searching for a solution to connect to the Internet via my new Siemens S55 GPRS phone. I've searched macosxhints but could only find one for Nokia and another for Sony Erricson. After some searching on the internet, I've compiled the steps needed to make it work via my G4 Powerbook iRDA port (bluetooth should work too). You can find the instructions at BusyBee OSX in this article. FYI, I'm connected to Australia's Telstra ISP. It should work with other Australian providers and even in other countries.
For those of you with other mobile GPRS phones, you may wish to follow the link in the article to access a bunch of other mobile phone modem scripts.
I'm sure many of you already do what I do when reading various forums: click the "View New Posts" link, then open tabs for each of the articles you're interested in reading. Trouble is, many forums don't have a "Mark All Forums As Read" link on the results page of the new posts search, so you have to go back to the main page to clear all the posts.
To save a few clicks, I've added the "View New Posts" link as a bookmark in the Bookmarks Bar, so that I can just go directly to the list of new posts. I make tabs of all the threads I'm interested in, then I click on another bookmark I made of the "Mark All Forums As Read" link to clear the list.
I was messing around with .Mac Slides Publisher (one of the lesser known features of .Mac), and I found some interesting hidden treasures. I had previously messed with Slides Publisher when it first came out, but I was disappointed at the lack of options for image compression (combined with the default setting of 'too much', in my opinion). I have recently found a way to replace the images uploaded via Slides Publisher with your own (arbitrarily compressed) images.
Use Slides Publisher to create a basic slide show of an image or two. This will create the directories and files needed to provide slideshows via .Mac. Now connect to your iDisk and look in the Pictures folder - you'll see a new folder called "Slide Shows," inside of which is a "Public" folder, inside of which are the images you uploaded with Slides Publisher. You'll also see an xml file called config.plist. The config.plist file looks a little something like this:
You can upload your own images into the Pictures -> Slide Shows -> Public directory, and then either rename them to match the names in the Images array (that is, Image-001.jpg, etc), or else alter the array contents to match the names of your images. Also, update the SizeOfSlideshowInBytes to match the sum of the file sizes of your images (the numbers in parenthesis of each image file's Get Info window, or the 5th field of ls -l Terminal output). I'm not sure where or how this value is used, but it's there for a reason, I do declare!
There's more! You can even change the base URL to be anything you want it to be. In my testing, it works without a hitch, and I'm pulling images from my server via the .Mac Screen Effects screensaver. Combine this with some scripting elsewhere to update the images, and you've got yourself a pretty handy way to roll out updatable images to the masses (I seem to remember that .Mac Screen Effects will refresh with the .Mac servers every so often, but I'm not sure).
Also, you'll note that in the example, the BaseURL points to a .Pictures folder (with a period in front of the name, as if it were hidden), which as far as I can tell does not exist. In any case, it works as if there were no period. As far as which image file formats are supported, and any upper-limit on size ... I'll leave that as an exercise for the reader (just remember to keep things modest if you want to share with your non-broadband-enabled bretheren!
When you have a (A)DSL connection like I do, you have to specify your internal IP number in the Network control panel, as well as the router address. For example, 10.0.0.150 and 10.0.0.138. Your real IP address will be different. When you have built a website on your computer (or anything else), you may want to check if what you did was any good. This can be a problem, since your 'outside' IP address is, of course, not 10.0.0.150, but some other number. This can be a fustrating mess. After checking complicated solutions like the Apache conf file and routed, I just found an amazing simple solution!
Go to Preferences -> Network and selelect Network Port Configurations from the popup.
Duplicate your ethernet card's port
Change the IP address to your outside IP number, e.g. 80.60.xx.xx (no complete sample ;-))
Set the netmask: 255.255.0.0
Set the router: 127.0.0.1
Hit Apply Now
The control panel will complain that the router's address is not in your address range. Ignore this. Now you can access your local machine by its external IP. I'm quite amazed at the simlicity of this!
For the past few months I have had to contend with unbearably slow outgoing email. It seemed to take an age to connect to the SMTP server and send even a single line of text. I tried the MTU fix, I tried different mail clients - all the same thing.
I finally found today that if I turn off the OS X software firewall, it solves the problem. I'm behind two hardware corporate firewalls anyway, so it's clearly redundant. Go to System Preferences -> Sharing -> Firewall and press Stop.This fixed the problem for me and hope it helps others.
This hint is possibly well known, but I just came across it in a newsletter from OWC:
By adding the suffix site:www.XYZ.com to your search terms, Google knows to limit its search to that particular site. Replace www.XYZ.com with the site to which you are attempting to limit the search.
[robg adds: No, this isn't an OS X hint. Given the popularity of Google, however, I thought I'd run it. For a full page of tidbits on getting the most out of Google, read their expert search tips.]
Code Red and Nimda requests are annoying at best, and can complicate log processing. One option of dealing with these requests is to have Apache log the requests to a separate log file, which can be processed as needed. Additional uses for separate log files are explored.
The httpd.conf file will need to be manually edited to add the following features. For more information on the configuration outlined below, consult the Apache manual.
[robg adds: A previous hint includes a shell script to block Nimda and Code Red requests at the firewall level; this hint explains how to use Apache's custom logging features to log these activities in a separate log file without actually blocking the requests.]