If you own a copy of the Mac version of Maple, and have used Maple in Linux, you may know about the command line version of Maple, and have noticed that it is missing in the Mac OS X version. But it is still there, it's just hidden.
To get it, add /Library/Frameworks/Maple.framework/Versions/Current/bin to your PATH (see this page if you don't know how to do this). Then, you can type maple at a command prompt to get the command line version of Maple with all it's ASCII beauty. There are advantages, too. It is much faster to load if you just need to do a quick computation and don't care too much about the appearance of the output.
If the GUI version doesn't work for some reason, such as a Java problem, the command line version will still work fine. There is also a diagnostic version of maple called mint, and an alternative GUI version called xmaple. But most importantly of all, you should at least give it a try to experience the wonders of ASCII 3D plots.
Note: This hint applies to Maple 12. I don't know if things are still this way for Maple 13 or Maple 14.
[crarko adds: I haven't tested this one. I omitted a very nice, but very large, ASCII 3D plot image.]
In Unix, you can easily add a user to a group by editing the /etc/group file. In the NetInfo days, there were equivalent methods in Mac OS X. Now that NetInfo has been replaced, how do you add a user as a member of a group? Here's how you can do it in Snow Leopard.
First, to find which groups you are currently in, you can use: % groups which promptly listed all the groups, except the one I needed. How do you add the user?
That's where the dseditgroup command comes in. It's a command-line tool which can perform certain editing operations on groups. It has an explanatory man page, and I used this command to add a username to a group. The parameter -u yourusername is your admin account, and the -p will prompt for the password.
% dseditgroup -o edit -u yourusername -p -a username -t user group.
[crarko adds: I tested this, and it works as described. You can consult the man page for dseditgroup for more information.]
Many people know about Fink and MacPorts, but few seem to know about Rudix.
MacPorts and Fink can compile complex *nix software for Macs, including all dependencies, but they also add a lot of bulk to your hard drive. So if you're just trying to download one simple tool like wget, sox, or imagemagick, they may be overkill for what you need.
The number of packages isn't nearly as large in Rudix as it is in the others, but if they have what you're looking for, you'll just be downloading one small .pkg file for each *nix program you want.
[crarko adds: I haven't tried Rudix; their home page notes that the project uses Python, and as such, there are many Python modules available.]
This hint is about installing Ubuntu Linux over the Internet on a PC compatible with network boot (PXE) without using a CD/DVD drive, a USB Flash drive, or having previously downloaded a full disc image.
You will need another computer on the same LAN. I will be using a Mac, hence why you're reading this hint here. Both computers obviously need Internet access.
I've written a few bash functions to interact with the normal Mac OS X trash can. This is actually slightly more complicated that it sounds at first, since the trash can is not just a folder somewhere. Each volume has its own trash, and your home folder has a trash can. Finder uses your home trash for any files on the boot volume, unless you have FileVault on.
Start by adding the following code (note you can check newer versions of the code on the mactrash SourceForge page) to your bash startup file (.bashrc or .profile).
#!/bin/bash -c 'echo This file is meant to be sourced.'
alias rm='del'
# make rm(1) safe.
# Remove or comment-out this line to return to normal rm(1) functionality.
function del ()
{
if declare -F trash >/dev/null
then
trash "$@"
else
command rm -i "$@"
fi
}
function trash ()
{
local F
local HOME_DEVICE="$(stat -f %Sd "$HOME")"
local TRASHCAN=~/.Trash
# Set this in advance _outside_ the loop below
for F in "$@"
do
if ! test -e "$F"
then
echo "No such file or directory: $F" 1>&2
return 4
fi
local DEVICE="$(stat -f %Sd "$F")"
if [ x"$DEVICE" == x"" ] || [ x"$DEVICE" == x"???" ]
then
echo "Can't locate trash for ${F}." 1>&2
return 3
fi
if [ x"$DEVICE" != x"$HOME_DEVICE" ]
then
TRASHCAN="$(trashOnDevice "$DEVICE")"
fi
if [ ! -d "${TRASHCAN}" ]
then
command rm -f "${TRASHCAN}"
if ! mkdir -m 700 "${TRASHCAN}"
then
echo "$TRASHCAN is inaccessible at this time." | sed 's;'"$HOME"';~;g' 1>&2
return 1
fi
fi
local FinT="$(basename "$F")"
if [ -e "${TRASHCAN}/${FinT}" ]
then
FinT="$(date) ${FinT}"
fi
if ! mv -vn "$F" "${TRASHCAN}/${FinT}"
then
echo "Unable to move $F to the trash." 1>&2
return 2
fi
done
local TRASHSIZE="$(du -hs "${TRASHCAN}" 2>/dev/null | cut -f 1)"
local TRASHCANloc="$(dirname "$TRASHCAN" | sed 's;^/Volumes/\(.*\)/.Trashes;\1;g' | sed 's;'"$HOME"';~;g' | sed 's;^/.Trashes;/;g')"
echo "${TRASHSIZE:- 0B} in trash on $TRASHCANloc."
}
function emptytrash ()
{
local TMPIFS="$IFS"
IFS='
'
local MOUNTS=( $(mount | sed -n 's:/dev/.* on \(.*\) (.*):\1:p') )
local TRASHCANs=( "${HOME}/.Trash" $(IFS="$TMPIFS";for i in `seq 0 $(( ${#MOUNTS[@]} - 1 ))`; do echo "${MOUNTS[$i]}/.Trashes/$(id -u)"; done) )
IFS="$TMPIFS"
unset TMPIFS
local TRASH_SIZE
TRASH_SIZE="$( (for i in "${TRASHCANs[@]}"; do ls "$i"/; done) 2>/dev/null | wc -w)"
if [ "$TRASH_SIZE" -gt 0 ]
then
echo -n "Emptying trash"
for i in "${TRASHCANs[@]}"
do
tput smcup
pushd "$i" 2>/dev/null && {
srm -frsvz . 2>/dev/null ; popd ;
}
tput rmcup
echo -n .
done
local DONE=
[ `ls "${HOME}/.Trash" | wc -w` == 0 ] && DONE="Done."
echo "$DONE"
else
echo "Trash is empty."
fi
}
function trashOnDevice ()
{
local DEVICE="$1"
local MOUNT="$(mount | sed -n 's:/dev/'"$DEVICE"' on \(.*\) (.*):\1:p')"
if [ x"$MOUNT" == x"" ] || [ x"$MOUNT" == x"???" ]
then
# If no mount point is found, then don't return the path to root!
return 1
elif [ x"$MOUNT" == x"/" ]
then
# Encourage the resulting path to _not_ start with two slashes
MOUNT=""
fi
echo "$MOUNT/.Trashes/$UID"
}
# Usage : seq n m [i]
# echo all integers between n and m using a skip or increment of i
function seq ()
{
[ "$1" ] || [ "$2" ] || return 1
local x=$1;
local y=$2;
local i=${3:-1};
local seperator="${4:- }"
while [ $x -le $y ]
do
echo -n $x"${seperator}";
x=$(( $x + $i ));
done
echo
}
Once you've added the above code to ~/.bashrc, you'll find that Terminal will now accept three new commands: del, trash, and emptytrash.
Running MAMP on standard ports (80 for Apache and 3306 for mySQL) makes MAMP ask for a password on each start up. I would like MAMP to start automatically when I log in, without requiring a password. There are a few ways to do this posted around the web, but they all involve hacking MAMP in one way or another. There is an alternative. Create the following AppleScript in AppleScript Editor:
do shell script "/Applications/MAMP/bin/startApache.sh &" password "YOURPASSWORD" user name "YOURUSERNAME" with administrator privileges
do shell script "/Applications/MAMP/bin/startmySQL.sh > /dev/null 2>&1"
Replace YOURPASSWORD and YOURUSERNAME with the proper values, then save it as a run-only application -- to keep anyone from being able to open the script and read your password. Then add that script to your login items. That's it, you're done!
[robg adds: This hint originally appeared in this blog entry; it was submitted here by the blog's owner. I've reproduced it as it was, with one clarifying note and some minor formatting changes to fit our site layout.]
It's a well know fact that running X11 applications on ae Mac crates a lot of ugliness. I discovered a way to solve this, at least partially.
A lot of Unix applications use the Gimp Tool Kit, or GTK for short. You can install GTK on Mac via MacPorts by running sudo port install gtk2 in Terminal. There are some themes in MacPorts as well to make your app look like an Air app instead of Win95; they work, but the look is still alien.
However, there is a GTK theme called mac4lin that emulates the Mac look on Linux, but I discovered this can be used on the Mac as well. Download and extract mac4lin and extract and copy one of the archives in the GTK folder to /opt/local/share/themes. Then run gtk-chtheme from MacPorts to change to your new aqua theme. As a final step, click the Font button to set the font to Lucida Grande 10pt, and you're done.
I found a couple of ways to update Twitter and read recent updates from the OS X command line. For instance, you can get all your tweets using the command line by using this command. (For some reason, retweets only show up as an "@" symbol, but your actual tweets will display correctly.)
When I need a container of files, or of a directory that is already compressed (i.e. jpg images), there is no need to 'compress' into a zip file, so the following OS X Service will replicate the Compress 'right-click' with tar:
Open Automator and select Service from the main screen.
Set the 'Service Receives Selected' pop-up menu to Files or Folders, and set the 'in' pop-up to Finder.
Drag Utilities » Run Shell Script into the workflow area.
Set the 'Pass input' pop-up to as arguments.
Delete all of the sample code, and replace with this:
Tarfile="$1.tar"
count=1
cd "${@%/*}"
if [ $# -eq 1 ]; then
while [ -e "$Tarfile" ]
do
let count++
Tarfile="$1 $count.tar"
done
else
Tarfile="Archive.tar"
while [ -e "$Tarfile" ]
do
let count++
Tarfile="Archive $count.tar"
done
fi
/usr/bin/tar -chf "$Tarfile" "${@##*/}"
Select File » Save and name your new Service (Package into Tar or whatever).
Quit Automator and try your Service in the Finder with a selection of files.