For web servers using PHP as apache module:

AddType application/x-httpd-php .html .htm

For web servers running PHP as CGI:

AddHandler application/x-httpd-php .html .htm

In case you wish to do the ASP mimick:

For PHP as module:

AddType application/x-httpd-php .asp

OR

For PHP as CGI:

AddHandler application/x-httpd-php .asp

Open the Terminal and type:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

It may be necessary to log out and back in, or even to restart the computer (which is what the article states), for the change to take effect.

mysql_secure_installation

May, 8 -- Categories: Linux, Mac, MySQL

if you install mysql run this command please…

mysql_secure_installation

what does it do?

asks you set a password for root account
remove root accounts that are accessible from outside the local host.
remove anonymous-user accounts.
remove the test database, which by default can be accessed by anonymous users.

see… it’s important

here’s what happens

me@ubuntop:~$ mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n] n
… skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!

By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
– Dropping test database…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Yes to Mercurial

Dec, 29 -- Categories: Linux, Mac

Mercurial is a very nice alternative to svn. I have several projects in it now and I’m pretty happy with it. Here are some starter commands. These should be executed from the command line in the directory that you want to control.

$ hg init # creates .hg

$ hg add # add those ‘unknown’ files
$ hg commit # commit all changes into a new changeset, edit changelog entry
hg commit -m ‘updated bad links to style sheet and changed directory name’

$ hg parents # see the currently checked out revision (or changeset)

$ hg status # show all non-ignored files

$ hg help

# export your current repo via HTTP with browsable interface on port 8000
$ hg serve -n “My repo”

hg revert –all -r 268033ec7859
Backing out changes

Reverting the whole tree to a known-good revision
It’s easy, like using a sledgehammer is easy. But this is usually overkill.

$ hg pull -u
$ hg revert –all -r a0193d83c208 # use your known-good revision id here
$ hg commit # be kind, include the revision id in your commit message
$ hg push

There’s a more precise alternative:
Backing out a single changeset
Suppose changeset f8f4360bf155 broke something.
$ hg pull -u
$ hg backout f8f4360bf155 # use the revision id of the bad change here
This creates and commits a new changeset that reverts all the changes in that revision.

Capture top output

Nov, 21 -- Categories: Linux, Mac

Output 1 sample to a file
top -n 1 -b > top-output.txt

Output 1 sample to an email
top -n 1 -b | mail -s “Here’s my top” me@jamesborder.com

here is the mac version
top -l 1 | mail -s “Here’s my top mac” me@jamesborder.com

Command Line email

Nov, 10 -- Categories: Linux, Mac

Send email while your at the teminal….
echo "The body of your email here" | mail -s "The Subject of your email here" me@jamesborder.com

A couple of “useful examples”?

send the last 100 line of the error log to yourself (or to a client that needs to see them but doesn’t know how to get to them)
tail -100 /opt/local/apache2/logs/error_log | mail -s "From error_log" me@jamesborder.com

send the last 10 lines of your command line history to your self
history | tail -10 | mail -s "Howd I do that" me@jamesborder.com

Removing mysql from my mac

Sep, 9 -- Categories: Mac, MySQL

Yes I admit I have mangled MySql on my macbook very badly and it had to go…. here is what it took to do it

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*

Using the wall command

Aug, 3 -- Categories: Linux, Mac

sh-3.2# wall
Type your message here
wall supports up to 20 lines

type control d to close

That will result in everyone on the system seeing your message regardless of wether mesg is enabled or not

Broadcast Message from me@JBook.local
(/dev/ttys001) at 21:13 CST...

Type your message here
wall supports up to 20 lines

type control d to close

another quick line is to

echo "Your message here" | wall

Find command basics

Jul, 10 -- Categories: Linux, Mac

find by name
find /directory -name “filename.ext”
find /directory -name filename.*
find /directory -name *.php

ignore case
find /directory -iname “filename.ext”

invert results (list files that don’t end with .php)
find /home/test ! -name “*.php”

search only 1 directory deep
find /home/test -maxdepth 2 -name “*.php”

only 2 directories deep
find /home/test -maxdepth 3 -name “*.php”

Find all directories
# find . -type d

Find only the normal files
# find . -type f

Find all the hidden files
# find . -type f -name “.*”

Find all the hidden directories
# find -type d -name “.*”

Find files bigger than the given size
# find ~ -size +100M

Find files smaller than the given size
# find ~ -size -100M

Find files that matches the exact given size
# find ~ -size 100M

Accessed files

Find based on minutes (60 minutes)
find /home -amin -60

Long list the files which are accessed within the last 1 hour.
find /home -amin -60 -exec ls -l {} \;

Find based on day(s) (24 hours)
find /home -atime -1

Long list the files which are accessed within the last 1 day.
find /home -atime -1 -exec ls -l {} \;

Modified files

Find based on minutes (60 minutes)
find /home -mmin -60

Long list the files which are accessed within the last 1 hour.
find /home -mmin -60 -exec ls -l {} \;

Find based on day(s) (24 hours)
find /home -mtime -1

Long list the files which are accessed within the last 1 day.
find /home -mtime -1 -exec ls -l {} \;

hide errors (Permission denied)
find -name “*.txt” 2>>/dev/null

To display the full path in the Finder title in Leopard, open Terminal.app and run:
$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

then

$ osascript -e ‘tell app “Finder” to quit’

Then relaunch the Finder from the dock. To undo:

$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool NO

I want a /home directory on my mac

May, 14 -- Categories: Mac

Be warned…. this is probably dangerous, and will probably destroy your computer and kick your dog. You probably shouldn’t do this, but if you want to here is how:

Edit the /etc/auto_master file. You’ll need admin privileges to do this like so: sudo vi /etc/auto_master. All you need to do is comment out the line that starts /home by putting a pound sign (#) in front of it. When you are done, here’s how the file should look:

#
# Automounter master map
#
+auto_master         # Use directory service
/net             -hosts       -nobrowse,nosuid
#/home             auto_home     -nobrowse
/Network/Servers     -fstab
/-              -static

Once you do this, you need to restart your machine.

find /whatever/directory/here -type f -name “.DS_Store” -delete -print

for example:

find /Users/me/Documents/-Actionscript-Flash -type f -name “.DS_Store” -delete -print

or

find /home/vhosts/dev31 -type f -name “._*” -delete -print

Here are some subversion examples

find . -type d -name ‘.svn’ -print0 | xargs -0 rm -rdf

find ./ -name “.svn” | xargs rm -Rf

Yes I understand you can export to get rid of them. But there has been more than one occasion where I wanted to exactly this without purging thru subversion and I’m sure I’m not the only one that has ever wanted to… so here is how.