Setting up postgres on my mac

Trying to set up PostgresQL on my Mac. Why? I want to use a key-value pair as an entry in my database, for convenience. It’ll save me from using three or four weirdly interlocked tables. SQLite3 can’t do it.

Here’s the story:

  • I am using RubyMine. Using the pg gem, I started a new clean project and pressed some buttons on the RubyMine setup screen to configure the project with Postgres as the database.
  • Not working. Not surprising, but it was worth checking!
  • Entering psql on command line gives the following error:

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/pgsql_socket/.s.PGSQL.5432”?

  • I know I have Postgres installed. Socket issue? Do I even know these words?
  • Search through internets.
  • Apparently “reading directions” is still an important life skill. I installed Postgres using brew because the version packed with Apple is out of date already. When you type “brew install postgresql” a cascade of text appears. Often I have found that this material is unimportant to my life. Not this time! It includes crucial instructions, like how to start your new version of postgres. Typing “postgres -D /usr/local/var/postgres” at the terminal got a mysterious process started: now the server is running locally.
  • Then I went back to RubyMine and tried to set up my stuff. Couldn’t create the databases with “rake db:create”; while I was running postgres locally I still wasn’t creating connections on the right sockets with my Rails app. Aha: here’s where adding “host: localhost” to both development and test environments in config/database.yml came in handy. Once I had specified the host for both, the databases got created. RubyMine made happy faces and my terminal window informed me that “STATEMENT: CREATE DATABASE” action was happening.
  • Now I’m in business: created a migration to enable extension hstore, created a model using hstore, and proceeding toward a more flexible data model.

Ruby on Rails adventures

I’m learning a bit about Ruby on Rails. It’s fun. But this afternoon I looked around for a simple way to put a slider into a form. I found some jQuery sliders. I did lots of stuff: learned how to convert Javascript to Coffeescript the lazy automated way, learned something about putting labels on this jQuery slider, this, that, other. And I couldn’t get my page to save the output of the slider. And while looking up how to do that, I discovered range_field. The slider’s already built in to Ruby on Rails, and in a better way than this silly jQuery slider, and it worked right away.

How do we learn these things at the beginning? I looked up sliders in forms and there are apparently a lot of people building Javascript sliders for Ruby on Rails apps when half the time it’s there already!

Gephi on Mac 10.8.5

To run Gephi on Mac OS 10.8.5, I needed to make a few adjustments and wanted to record them for posterity.

I found this thread very useful.

  • I needed to install Java version 6. Oracle does not provide it; you need to get it from Apple. I found it here. Annoyingly, it was not in the standard software updates. Some sites (like Gephi’s?) tell you that Java 6 is automatically installed with Apple updates and that’s simply not true.
  • I already had Java version 7 and that won’t currently work with Gephi. I downloaded that to make Rapidminer run!
  • There’s nothing in either Gephi or RapidMiner that tells you what is missing when Java is missing or of the wrong version, by the way — they just fail to work.
  • Once Java 6 was installed, I had to change two lines of code. First, in /Applications/Gephi.app/Contents/MacOS/Gephi, I needed to type jdkhome=`/usr/libexec/java_home -v 1.6` on the lines above the if-then snippet that tells Gephi where to look for Java. So search for $jdkhome in this file and add the line hardcoding jdkhome before the if statement.
  • I also had to change the Gephi configuration file: I opened /Applications/Gephi.app/Contents/Resources/gephi/etc/gephi.conf and changed jdkhome there to jdkhome="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/".
  • Doing just one of these things was not enough.

Now I have graphs!