Bash scripting
This is definitely something worth looking into. For now, here's a Mac example to set a different /etc/hosts depending on your IP (good for local network/adsl workarounds).
#!/bin/bash
EN1IP=`ifconfig en1 | grep 'inet ' | cut -d' ' -f 2`
H_EN1IP=10.1.1.
W_EN1IP=192.168.0.
if echo "$EN1IP" | grep -q "$H_EN1IP"
then
cp /etc/hosts.home /etc/hosts
echo `date` "Location: home - $EN1IP" >> /var/log/hosts.log
else
cp /etc/hosts.work /etc/hosts
echo `date` "Location: work - $EN1IP" >> /var/log/hosts.log
fi
exit 0
Then you could set up a LaunchAgent in /Library/LaunchAgents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.hostswapper</string>
<key>ProgramArguments</key>
<array>
<string>/opt/loc</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Automatic host swapping!
Update: actually, this wouldn't work since the LaunchDaemon is called before a wireless IP is acquired. Back to the drawing board. Pinging a known IP (ie. the router) with a set interval might work better.
Favicons
The following will work under any modern browser (IE included):
<link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" /> <link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
linkmust be insidehead/favicon.icois a legacy name and path that older browsers will sniff regardless of the above codetypemay beimage/giforimage/png(but it doesn't work in IE)
- A useful page on the Wikipedia (..SRSLY?)
- Free ICO import/export plugin for Photoshop (works in CS3 Win)
Mount a network share with CIFS
For a one-off:
mount -t cifs //host_or_ip/share /mountpoint
And you'll probably need at least some of:
-o username=smbusername, password=smbpassword, iocharset=utf8, file_mode=0777, dir_mode=0777
If you want it automatic, add a line to /etc/fstab:
//netbiosname/share /mountpoint cifs username=smbusername,password=smbpassword, iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
(you could store the user/pass in a file and point credentials at it for better security)
Now try it out with sudo mount -a.
Change MySQL password
Change a user password at console with
SET PASSWORD FOR 'user'@'%' = PASSWORD('newpass');
Which is equivalent to
UPDATE mysql.user SET Password=PASSWORD('newpass')
WHERE User='user' AND Host='%';
FLUSH PRIVILEGES;
