Archive for November, 2011

Quick and easy way to create read-only databases

Postgresql doesn’t have a one-step command to grant permissions on a batch of tables like you can in MySQL.  However, it is much simpler in 9+ than it was previously.  You still have to go schema by schema in a database, but at least you don’t have to go table by table, view by view.   Here are the steps to create a read-only user:

First, create the user:

CREATE USER readonlyusername WITH PASSWORD 'password';

Now for each schema in a database you want the read only user to have access to you need the next two statements:

GRANT USAGE ON SCHEMA schema TO readonlyusername;

GRANT SELECT ON ALL TABLES IN SCHEMA schema TO readonlyusername;

If you’ll be adding new tables or views and you want them to be accessable by your read only user you need the following:

ALTER DEFAULT PRIVILEGES IN SCHEMA schema GRANT SELECT ON TABLES TO readonlyuser;

If you know of a quicker and/or easier way please let me know!

Switched to Openbox

One thing I’ve always liked about Linux is the ability to run a simple, lightweight desktop.  You can’t get much more lightweight than the Openbox window manager.  By default it doesn’t even have a taskbar / pager, you just get a plain grey screen.  To get the most out of Openbox here are a few extra programs to install to get it a little more useable.

 

Menumaker:  Menumaker is a python script that will create the menu file for several window managers like Fluxbox, Blackbox, and xfce.  Just run mmaker, tell it which window manager you’re using and it will search your hard drive for installed programs and put them in the correct category.  It’s not perfect, it missed most of the LibreOffice suite for me, and it created duplicate entries for some programs.  It did make an entry for QGIS and catagorized it as a Science application, but GRASS was identified as Educational.  Since Openbox’s menu is driven by an XML file it was easy to correct those mistakes and do a little manual re-arranging. It’s just nice to have the script around to do the heavy lifting.  However, if you don’t feel like editing the XML file in a text editor you can use…

Obmenu:  Obmenu gives you a GUI to edit the menu.xml file.

Feh:  Feh is a simple image viewer.  For Openbox you can use it to display your wallpaper, see the linked wiki article on how to use it to do so.

Tint2:  Tint2 is a simple panel for window managers.  It gives you a list of the windows that are open on a given desktop, and with newer versions it can be set to launch programs or give you an applications menu.

Thunar:  Thunar is a really easy to use file manager.  As part of the XFCE project it’s quick to load and lightweight.  It does not need XFCE installed to be run.

 

All five of these programs can be found in the Arch repositories, as well as Openbox itself.

GKrellm!

It is sad to say, but one of the reasons I wanted to initially try Linux was so I could use GKrellm.  I really, really wanted to know how fast the fans in my case were spinning.  I had not thought about it for years, until today when I stumbled across a reference to it on an old “beautify your desktop” blog post.  I checked the Arch repositories and sure enough, it was in there.  CPU fan going strong at over 3000 RPM.  Good to know!  If I remembered my UIN maybe I’d go check out LICQ for old time’s sake too.

Arch house cleaning

It’s important to do some tidying up every now and then.  On an Arch system a quick and easy way to do some cleaning and reclaim disk space is to clean your package cache with pacman -Sc.  This will clear out packages for the old versions of your installed software and the packages for your uninstalled software.

If you are REALLY desperate for disk space you can use the pacman -Scc command to delete all the locally stored copies of your installed packages.  This is not recommended as you won’t be able to downgrade to an older version if a new version doesn’t work for you.  You can manually copy out the packages for some software if you know you might need to downgrade in the future, Postgres is a good example of a program you’d want an older version of lying around just in case.

TIGER Georeference 2010 Loader Works

A few posts ago I went through the steps to get the script that the 2009 TIGER Georeference Loader to work under Linux.  Regina Obe was nice enough to comment on that post, pointing out that the 2010 Loader that’s included in PostGIS 2.0 works just fine under 1.5.  It does work right out of the box and it downloads the 2010 TIGER data instead of the 2009.  Sweet!

One small tip, I used the Pgadmin3 query editor tool and copied the results of the Loader function to a blank text file and executed that text file as a script.  When doing so, remember to delete the first and last quotation marks you’ll get when you copy the query results.

What did I do to Chromium?

For some reason I can’t log into Yahoo Mail with Chromium. I enter my username and password, but nothing happens when I click the submit button and nothing happens when I press enter. I can login just fine with Firefox, and I can use Chromium to log into any other site. Crazy!