Ramblings

May 31, 2010

Django OSX MySQL MAMP

Filed under: django, macports, mamp, mysql, mysqldb, osx — michaelangela @ 7:29 am

For my overly customized MAMP install, it wasn’t pretty. I forget why it’s actually set up this way now but the different parts didn’t like each other and it took quite a while to get it working. Not fun. But fortunately there were those who had gone before me and it wasn’t hard in the end. It just took a long time.

http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/

http://www.marteinn.se/blog/?p=467

Correction. It just took a really REALLY long time. The reason? You need to have libs and headers and such in places that all make sense for everything to compile. (This is the SHORT version.) So MacPorts to the rescue. Install py25-mysql, copy some files around, use a slightly different “HOST” setting for the database connection and you’re good to go. But installing py25-mysql installs ALL the dependencies needed in order to get that running. Which is good when that’s what you need. Which is what took a long time. But at least it was a one command thing and not hopping all over the ‘net to find and install things as I was very close to doing.

And that bit about the unique “HOST” setting for mine turns out to be

DATABASE_HOST = ‘/Applications/MAMP_1.7.2/tmp/mysql/mysql.sock’

May 27, 2010

Ruby, OS X, MAMP, MySQL, do_mysql and getting it installed

Filed under: install, mysql, osx, ruby, tip — michaelangela @ 7:33 am

This took a lot of time. In hopes that this will help someone else, I add this link.

How to install the MySQL/Ruby gem on Mac OS X Leopard

Here’s the situation. I have MAMP. For legacy reasons my current MAMP 1.7.2 is in a custom directory. I use ruby. In particular I wanted to use DataMapper in a project with ruby. I wanted to use it with MySQL. That requires do_mysql. It just would not install with all kinds of errors. Well one in particular. It complained of possibly missing headers or libraries. After a long search the above link surfaced from the depths of Google. It almost worked for me. Everything but the last command actually. So for me, the command I ended up using is something like:

sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-dir=/Applications/MAMP_1.7.2/Library –with-mysql-include=/Applications/MAMP_1.7.2/Library/include/mysql –with-mysql-config=/Applications/MAMP_1.7.2/Library/bin/mysql_config

This is OS X 10.5.8 Leopard

December 14, 2009

PathTools and iTerm instead of Terminal

Filed under: applescript, automation, eclipse, iterm, osx, pathtools, Uncategorized — michaelangela @ 9:44 am

So as noted, I tried using PathTools with FleBuilder under Eclipse 3.5 except FlexBuilder just has too many issues under 3.5. I gave up on PathTools with FlexBuilder but it’s been just awesome with the recent JaveEE 3.5 build. I only had one not-even-gripe as there really isn’t anything to complain about. It opens Terminal for the new paths instead of iTerm. Fortunately a little scripting later and it’s all good based on some code from the iTerm site and also this snippet.

You can see in the PathTool preferences what is called in order to do some of the interaction. Launching a terminal in the selected path is simple enough and is located here: /Applications/eclipse/configuration/org.eclipse.osgi/bundles/685/1/.cp/scripts/cdterminal.scpt

Changing that to the following makes it launch iTerm instead, with a little simple error correction. I hadn’t done Applescript stuff before so was just trying it out. I love these little bits of integration/customizations that are possible.

on run argv
set cdTo to item 1 of argv
tell application “iTerm”
activate
— talk to the first terminal
tell the first terminal
— launch a default shell in a new tab in the same terminal
try
launch session “Default Session”
on error
display dialog “There was an error creating a new tab in iTerm.” buttons {“OK”}
end try
tell the last session
try
— cd to the requested cdTo path
write text “cd ” & cdTo
on error
display dialog “There was an error cding to the requested path.” buttons {“OK”}
end try
end tell
end tell
end tell
return
end run

December 8, 2009

sudo visudo and environment variables like JAVA_HOME

Filed under: bash, java, osx, tip — michaelangela @ 3:26 am

I was trying all sorts of incantations to get JAVA_HOME set. None worked. OS X. Bash. .bashrc, .profile, etc., etc. Turns out the following is the problem, and the solution.

sudo, JAVA_HOME and Mac OS X [Article] « elc technologies

The problem is that JAVA_HOME doesn’t get passed to sudo, so sudo cannot access it. I remembered two solutions to fix this problem, one by telling the env to keep the variable and the other by switching to root user and exporting the variable there.

So, the first solution is to make the JAVA_HOME variable available to sudo, first export it and then run sudo visudo and add the following line to it:

Defaults    env_keep +="JAVA_HOME"

[update]
In the end, it had to go in /etc/profile for it to take as noted below. Maven (mvn -v) just would not show the new version of java otherwise and builds done with maven would fail because they targeted the wrong version as well.

Compiling Java 1.6 projects using Maven on Mac OS X

You can declare this either as a one time export in your current shell above, in /etc/profile as I normally do or in any other startup file of your choice. Afterwards be sure to refresh your shell before you try again. This can be done either by closing your current terminal window and opening a new one or by sourcing whichever file you’ve put the above information into.

source /etc/profile

In order to make sure that it has taken effect one can output it in the shell as follows.

echo $JAVA_HOME

If it shows nothing then the shell has not picked up your change.

December 7, 2009

Reading chm on OS X

Filed under: cool, osx, tool — michaelangela @ 8:09 am

Nice. Will be trying this out shortly. This was mentioned in comments here.

iChm – Cocoa CHM Reader for Mac OS X and iPhone/iPod Touch – 石锅拌饭

iChm for Mac
Features

* Fully built with Cocoa. No ugly window and slow rendering.
* Tab browsing
* Search. Result sorted by relevance.
* Text encoding detecting/switching
* Find in the page
* Tag powered bookmark
* Index
* Back/Forward
* Text zoom
* Export to PDF
* Continuous reading with Page down/Page up

November 24, 2009

Quicksilver + pbpaste + pbcopy

Filed under: automation, cool, osx, tip, tool — michaelangela @ 3:07 pm

After seeing the following post, many possibilities came to mind.

Notes: Pretty print XML

But working with XMPP and SAPO Broker, I’m always copy&pasting XML from one place to the other and it would be nice to format the XML snippet sitting in the clipboard.

This pipe does the trick quite nicely:

pbpaste | xmllint –format – | pbcopy

I wrapped this into a script, called x-xml-format-clipboard and now its just one command away from gratification.

In the end I came up with a couple that I use a lot after searching the web. The possibilities are endless but these are neat for me. In Eclipse I can’t easily transform text unless I install AnyEdit which I have on other systems. But I haven’t yet on this one. So the transforms are simple:

upper to lower:

#!/bin/bash

pbpaste | tr '[:lower:]' '[:upper:]' | pbcopy

lower to upper:

#!/bin/bash<br /><br />pbpaste | tr '[:upper:]' '[:lower:]' | pbcopy<br />

remove blank lines:

#!/bin/bash<br /><br />pbpaste | grep -v '^

These are made into executable scripts on my path which I can then pull up with Quicksilver. So now to remove blank lines, I select the text in any editor, trigger Quicksilver, highlight the command, press enter, and paste it back. Nice. Of course this means that you can do just about anything with this kind of thing as discussed here. | pbcopy
These are made into executable scripts on my path which I can then pull up with Quicksilver. So now to remove blank lines, I select the text in any editor, trigger Quicksilver, highlight the command, press enter, and paste it back. Nice. Of course this means that you can do just about anything with this kind of thing as discussed here.

Commandline calculator for OSX

Filed under: osx, tool — michaelangela @ 2:39 pm

Every now and then I like to do a bunch of quick calcs with references back to previous calcs. I can use iPython which is really powerful tool since it’s an advanced interactive frontend to python. But this is just a neat little tip.

[awk] Command line calculator using awk « *NIX tricks

This is an update on our bash command line calculator posted a few days ago — except for the fact that this time we’ll use awk to do the calculation instead of bc. As I mentioned in that post, you may use python or ruby (irb) to do the same thing, but these tricks may be useful if you don’t ruby or python installed (bc and awk, in general, come by default in any Unix or GNU/Linux distro).

First, create (or rewrite if you used our last trick) function “?” as follows and put it in your ~/.bashrc file:
? () { awk “BEGIN{ print $* }” ;}

and make sure to reload your ~/.bashrc file (do the similar thing if you’re using any other shell). [NOTE: ZSH does not like “?” as a function, so you might consider replacing it with something reasonable, e.g., “compute”]

Now, if you want to calculate an expression, do it, for example, as
$ ? “2*3+4.0*(9.9+8.1)”

and don’t forget the quotes.

September 21, 2009

Printing from OS X 10.5 to a Canon Pixma MX330 shared on a Windows XP box

Filed under: cool, mac, osx, tip, tool, windows — michaelangela @ 6:34 pm

Since there are no drivers available to print to a shared Pixma MX330 that I am aware of, I have been unable to print to the printer. And because there are no drivers that allow the DNS-323 to host the Pixma MX330 as well, that was out, too.

The following did work though, except actually printing to the printer. In step 5, instead of doing IP > LPR over IP, I used Advanced > Windows type, and used the smb://username:password@ip_address/GhostcriptLPR and that has been working today so far.

This process will ask for your XP disk to install a couple of specific DLLs when you get to adding the new services.

How to Use a Printer Attached to a Windows XP Computer in Mac OS X

This document gives a detailed explanation of how to set up an HP DeskJet 722C printer that is attached to a Windows XP computer so that the printer can be used by a Mac OS X computer on a local area network (LAN). If your printer is slightly different, or you have a different version of Windows, or you’re using a different Unix than Mac OS X, you’ll have to adapt these instructions with your own creativity.

September 1, 2009

Other helpful shortcuts and tips for both os x and windows

Filed under: osx, tip, tool, windows — michaelangela @ 11:55 pm

Mostly notes for reference. Although Ctrl+F2 doesn’t seem to work without first going somewhere else like the dock with Ctrl+F3. Odd… maybe something I broke already. 🙂

Keyboard – XvsXP.com, Mac OS X vs. Windows XP

Most special characters can be typed with the help of the option key. Use option when typing a letter or symbol, and OS X will substitute a special character. For instance, option-shift-4 will type a cent sign instead of a dollar sign.

In addition, typing characters with accents is extremely easy. Type option-e, for example, and OS X will insert a forwards accent, highlighted in yellow. Then, type another letter — an “e,” “a,” etc. — and OS X will place that letter below the accent mark. This lets you easily type words like “résumé.” You can use other option key combinations to type other accents as well, letting you easily type letters like “ñ” (option-n + n) or “ü” (option-u + u).

Other helpful shortcuts and tips for both os x and windows

Filed under: osx, tip, tool, windows — michaelangela @ 10:53 pm

Mostly notes for reference. Although Ctrl+F2 doesn’t seem to work without first going somewhere else like the dock with Ctrl+F3. Odd… maybe something I broke already. 🙂

Keyboard – XvsXP.com, Mac OS X vs. Windows XP

Most special characters can be typed with the help of the option key. Use option when typing a letter or symbol, and OS X will substitute a special character. For instance, option-shift-4 will type a cent sign instead of a dollar sign.

In addition, typing characters with accents is extremely easy. Type option-e, for example, and OS X will insert a forwards accent, highlighted in yellow. Then, type another letter — an “e,” “a,” etc. — and OS X will place that letter below the accent mark. This lets you easily type words like “résumé.” You can use other option key combinations to type other accents as well, letting you easily type letters like “ñ” (option-n + n) or “ü” (option-u + u).

OS X list of os x shortcuts

Filed under: cool, osx, tip — michaelangela @ 10:45 pm

Many I knew, some I didn’t. But the author is right that it helps. The Tips & Tricks page has some nice notes as well.

Dan Rodney’s List of Mac OS X Keyboard Shortcuts & Keystrokes

I like to figure out the fastest way to do things. I hope these shortcuts will help you become the power user that lies within. These keystrokes should work on Mac OS 10.6 Snow Leopard and 10.5 Leopard (many also work on 10.4 Tiger). I add new shortcuts as I find them, so check back! I’m still exploring Snow Leopard and will be updating this page as I discover new goodies.

April 30, 2008

Show the date in the OS X Menu Bar

Filed under: cool, osx, tip — michaelangela @ 2:43 pm

A good tip and set of instructions on how to show the date in the menu bar so you don’t have to click, hover, etc.

How To: Display Date in OS X Menu Bar – PaulStamatiou.com

While getting things settled down on my MacBook it became apparent that I did not want to rely on the calendar widget to find out the numeric date. I simply wanted to view the date alongside the time in the menu bar. Unfortunately this is not an option in OS X. However, with a slight of hand, you too can easily display the date in the OS X menu bar without the need of additional applications.

April 24, 2008

Jump to path in OS X finder

Filed under: osx, tip — michaelangela @ 9:41 pm

Not sure where I saw this, but if you have an OS X Finder box open to, say, upload a pic to Facebook, if you hit Command-shift-G, it’ll give you a box you can paste a path in. You can also type the path in and it should give path completion so I’ve heard.

Nifty.

Blog at WordPress.com.