Posterous theme by Cory Watilo

Filed under: osx

myPyTunes v0.2

I've updated and posted the myPyTunes script on Assembla using its Wiki/Trac/SVN project capabilities. I could put it on Google Code, but I figure I try Assembla out since somebody else recommended this to me before. Assembla maybe a bit of fluff, but I'll give it a whirl for now. myPyTunes has been recoded and I'm planning to classify (OOP) it for the next update. Another step will be to make it a fully integrated web application with server so it's completely portable. In due time I guess, but until then, here is the link to the Main Website and SVN http://www.assembla.com/wiki/show/mypytunes 

myPyTunes: iTunes from the Terminal in Python

Inspired by the Controlling iTunes from the Terminal article explaining a bash shell command line script to (as the title says) control iTunes from the terminal. I liked this, but I felt I needed a bit more flexibility (meaning I want it coded in something i know better), and I really like Python (especially when i decide to class-ify this script), so I decided to port it over to Python.

I found this useful to have installed on the Mac Mini sitting on a desk while i was across the room on my Powerbook. Very handy since I didn't want to have to get up every time I wanted to change the song, or pause it when the phone rang, etc. So far its a pretty clean traslation over with a few modified functions, and a few functions I've thrown in from other posts I had seen, or functions I feel would be cool to be added.

I've only tested this on OSX 10.4.11 - iTunes 7.6, so even though I believe it should work on other versions of iTunes/OSX, don't take my word for it, but please let me know if you do run into any problems with it. Right now i'll upload the file along with this blog, but i'll be sure to use a versioning tool as i make updates.

Download myPyTunes here - Right click the link and choose "Save As.."

Here is the basic help menu when you type in "itunes -h":

----------------------------------------------------------
iTunes Command Line Interface 
----------------------------------------------------------
Usage: /usr/bin/itunes <option>
Options:
status = Shows iTunes' status,
current artist, and track.
play = Start playing iTunes.
stop = Stop iTunes
pause = Pause iTunes.
playpause = Play/Pause iTunes.
next = Go to the next track.
prev = Go to the previous track.
mute = Mute iTunes' volume.
unmute = Unmute iTunes' volume.
vol up = Increase iTunes' volume by 10%
vol down = Increase iTunes' volume by 10%
vol # = Set iTunes' volume to # [0-100]
quit = Quit iTunes launch = Launch iTunes
playlist @ = Play iTunes' playlist named @"
list = list playlists.
shuf = turn on shuffle playlist
noshuf = turn off shuffle playlist
ostream = open stream
help = what's showing now
----------------------------------------------------------

Speed up Mail.app

for you mac users that use Mail.app, i found this (through digg) that will help speed up the application. Here is a brief instruction on what to do (copied from that site):
1. Quit Mail. 2. Open Terminal. 3. Type the following: cd ~/Library/Mail sqlite3 Envelope\ Index An sqlite> prompt will appear. At that prompt, type vacuum subjects;. After a short delay, the prompt will return. Type Control-D to exit. 4. Restart Mail and enjoy the extra speed.
UPDATE: apparently this works too… sqlite3 ~/Library/Mail/Envelope Index vacuum index;

Tab Through Forms on the Mac

One of the biggest issues I had since owning a mac was the inability to tab through items in a form on a webpage.

Text boxes would tab through no problem, but what about the Pulldowns, checkboxes, and submit buttons?

What about the OK and Cancel buttons you get on a Mac Popup???

I resorted to using the mouse for this until i was explaining one thing to another friend in the System Preferences, and tucked away in a spot i would never think to look at held the option to change and make this possible…

System Preferences >> Keyboard & Mouse >> Keyboard Shortcuts

i originally thought this was just a fault of the os x system and never bothered to look for a remedy. now that i’ve found it, i’ve been a form tabbing maniac again (lame, i know, but it’s true).

color terminal bash on the Mac (iTerm included)

first open up .bash_profile from your favorite editor. fastest way to do it from the terminal command line is:

$ vi ~/.bash_profile

copy and paste the code below if you like. it includes an explanation of each line
.bash_profile

#enables color in the terminal bash shell export
CLICOLOR=1
#sets up the color scheme for list export
LSCOLORS=gxfxcxdxbxegedabagacad
#sets up the prompt color (currently a green similar to linux terminal)
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '
#enables color for iTerm
export TERM=xterm-color
#sets up proper alias commands when called
alias ls='ls -G'
alias ll='ls -hl'

C/P’d from MacOsXHints.com:

The colors can be set with the LSCOLORS variable. The color designators are as follows:

a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background

Note that the above are standard ANSI colors. The actual display may differ depending on the color capabilities of the terminal in use. The order of the attributes in the LSCOLORS variable is as follows:

1. directory
2. symbolic link
3. socket
4. pipe
5. executable
6. block special
7. character special
8. executable with setuid bit set
9. executable with setgid bit set
10. directory writable to others, with sticky bit
11. directory writable to others, without sticky bit

They are set in pairs, foreground (f) then background (b), i.e. fbfbfbfbfbfbfbfbfbfbfb for all 11 settings. The default is exfxcxdxbxegedabagacad, i.e. blue foreground and default background for regular directories, black foreground and red background for setuid executables, etc.

PHP/MySQL on the Mac

First Enable Apache:

  • System Preferences > Sharing
  • Check ‘Personal Web Sharing’

Then edit httpd.conf

  • sudo vi /etc/httpd/httpd.conf
  • locate these lines and remove the hashes in front:

#LoadModule php4_module
#AddModule mod_php4.c
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

Download and install MySQL for the Mac (10.3, 10.4, etc)

$ sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
$ mysql -u root mysql

  • Then set a password (changing “NewPw”, of course):

> update user set Password=password('NewPw‘) where User=’root’;
> flush privileges;

How to fix Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’
Apparently, OS X Tiger doesn’t allow for PHP MySQL connection out of the box. You get this: Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’
/etc/php.ini(.default) looks for mysql.sock in the wrong place… two options are to make a symbolic link from the right place to the socket…

$ sudo mkdir /var/mysql
$ sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

Or you can update your php.ini (.default) by finding “mysql.default_socket” and setting it to equal /private/tmp/mysql.sock and then restart apache with “apachectl graceful