Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

More JEdit macros for rails

Posted by Jim Morris on Thu May 31 13:27:46 -0700 2007

I have been using JEdit more and more for my rails development, I have gone back and forth between it and Epsilon, however JEdit is starting to win out. I have upgraded to the latest pre version (4.3pre9).

I have modified a number of macros to do my bidding, and I dumped the Ruby Plugin because I kept running into things it did that I disliked, and it still seems a little buggy.

The best thing I did was update the ruby.xml Language mode to fully indent properly, like unindent end else rescue etc, and do this when you type those words. This is now possible with some new features in the 4.3pre9 series.

I also wrote a HAML language mode.

The plugins I currently use are...

  • Buffer Selector
  • BufferTabs
  • Common Controls
  • Console
  • CssEditor
  • CtagsSideKick
  • ErrorList
  • Highlight
  • Info Viewer
  • Latest Version
  • Log Viewer
  • MacroManager
  • OpenIt
  • Project Viewer
  • QuickNotepad
  • RecentBufferSwitcher
  • SideKick
  • SuperAbbrevs
  • SwitchBuffer
  • Tags
  • TextTools
  • XercesPlugin

The macros I have downloaded, modified or written to help with rails development are...

  • Expand_Hash.bsh - My macro to expand # to #{} when in a string
  • Go_to_Ruby_method_v0.5.bsh - Downloaded from the macromanager
  • Open_Related_File.bsh - Downloaded from the macromanager
  • Search_Ruby_documentation - A modified version of the one I downloaded, modified to use qri, and select from a list if multiple hits
  • Run_Test_Case.bsh - My macro to run a specific test case or specification. Bind it to a key (I use Shift-F11), put the cursor in a test case or specification and type the shortcut, and that specific test case will run, the results going to the console plugin.
  • Select_Super_Abbrevs.bsh - My macro to select from a list of matching SupperAbbrevs
  • Find_Next_Selected.bsh - Downloaded from the macromanager

I have linked the ones I have written or modified so you can download them if you like.

Posted in JEdit,Rails  |  Tags rails,editor,jedit,macros  |  4 comments

Show

Snow Dogs R Us a rails based social networking site

Posted by Jim Morris on Thu May 31 12:59:01 -0700 2007

I have started a new project for myself and a few friends, Snow Dogs R Us. This site just went live! (on 6/20/2007). It is a full blown Web2.0 (insert other buzz words here), social networking site for Snow Dogs and their (human) parents.

It is certainly a challenging project and taking much longer than I anticipated.

The basic features include sign-up, forgot password, login, optional profiles for the user and their snow dogs, and all the usual stuff there.

The advanced features include linking to friends for both the humans and the pets, so the humans can link to other human friends, and the pets can link to their friends too (Ala MySpace and Facebook etc). I want to eventually have a LinkedIn type of network as well, so you can see how many degrees you are away from other people, this is a real challenge to do in Rails, and I will probably actually write a Java engine to do that, as it is pretty compute and memory intensive. (Its not really an essential feature of the site, but I like technical challenges).

Of course there will be the ability to comment on everything, rate everything and tag everything, and there has to be the obligatory Mashup with Flickr and YouTube for all those cute photos and videos of our pets. (What other Web2.0 feature have I missed?).

Luckily the Rails community has already made available a lot of plugins we can use. I currently use these plugins...

  • active_scaffold - for the admin interface
  • acts_as_taggable_on_steroids - for the tagging
  • haml - For all my HTML structure needs
  • test_spec_on_rails - a better way to test
  • acts_as_commentable - pretty basic comments
  • cssformbuilder - highly customized, I need to make my mods available
  • restful_authentication - for authentication, I added the forgot password hack slightly modified
  • transactional_migrations - Ideal for Postgresql
  • acts_as_rated - I started using acts as rateable but switched
  • calendar_date_select - for inputting dates
  • sexy_migrations - Makes migrations so much easier
  • will_paginate - For paginating those pages
  • attachment_fu - For uploading the pictures (and FreeImage and ImageScience for scaling them)

I looked at has_many_friends but it was so close to what I had already done I just decided to keep my version, plus I want to add that degrees of freedom stuff later on.

There have been many posts about the friendships links in Rails, some decided to simply have a HABTM with two entries to make the link symmetric, I don't like wasting space so my solution uses a single entry for their friendship, and some SQL to find friends regardless of whether they invited you or you invited them. I'll blog about that later when I optimize it a bit more, as friendship links can grow exponentially I think it is prime candidate for optimization both in the amount of space is uses in the database and for database access, and simple has_many :through construct work but in this case will be very inefficient.

Another feature is the ability to create events and invite everyone or just your friends (think evite for dogs), this is relatively simple except keeping track of the invitations and who accepted etc. I also link to Places, because an event is usually at a place, and of course the place needs to have directions, so a link to Google maps is in order there. Of course a place needs to be taggable and commentable and rateable.

Lastly is the ability to make recommendations. In the dog community we share advice on Vets, food, dog friendly places to visit like restaurants, parks, beaches etc. These all need to be taggable, rateable and commentable and of course searchable. I've gone back and forth on how to implement that, right now it is a simple table called inputs (user input), which is taggable, commentable, and rateable. It relies on people tagging properly, IE tag with restaurant for dog friendly restaurants, and vet for vet recommendations etc. I originally had a belongs_to input_type with predefined categories, but decided to trust the user and just allow tags. We'll see how that works. Maybe the tag input field needs to auto_complete with a list of current tags so people are more inclined to tag with already used tags.

My biggest problem is the web design or look and feel, I am a programmer not a designer, so I can solve the complex programming issues and implement all the functionality, but I get really stuck when I try to figure out how to present that information. If this was a "for pay" project I would hire a web designer, but it is definitely a not-for-profit project so I can't afford that, so I'll struggle with the design.

I'll post more entries on some of my solutions to the technical problems as I go.

A few things I have learned, is to use piston for managing plugins, and avoid alpha plugins :)

Posted in Rails  |  Tags rails,social,networking,web2.0  |  9 comments

Show

Updated Capistrano local subversion and perforce

Posted by Jim Morris on Sun Feb 18 15:32:14 -0800 2007

I have updated the Capistrano local subversion module and added a perforce one.

The original article is here.

I have added rsync as an option to speed up the deployment to remote servers, To use that option install this version, in the example below I have installed the file into my rails projects lib/tasks directory.

When the rsync option is set the deployment method will use rsync over ssh to synchronize between a local cache of the subversion project and a remote cache, minimizing the amount of data uploaded to the server.

To use rsync use this in the deploy.rb...

  require 'lib/tasks/local_subversion_rsync.rb'
  set :scm, Capistrano::SCM::LocalSubversionRsync

  set :repository_is_not_reachable_from_remote, true
  set :use_rsync, true
  set :local_rsync_cache, "/home/user/projects/aproject/cache"
  set :remote_rsync_cache, "/var/www/webapp/cache"

  set :rsync_username, "ausername"
  set :rsync_excludes, ["*.bak", "*.log"]

The rsync_username and rsync_excludes are optional.

The :rsync_username option sets the username that ssh uses to login to use rsync. Leave it blank if it is the same as your current login name.

The :rsync_excludes option allows you to pass --exclude options to rsync, using the rsync syntax for exclusions, this is an array of patterns to exclude.

Note you must do a local SVN checkout to the directory specified by local_rsync_cache at least once before using this method.

Also the directory specified by remote_rsync_cache must exist on the server.

The perforce version of the scm module that allows the perforce server to be accessed locally only is here, note that this does not currently support the rsync option or write to the revisions.log.

Posted in Rails  |  Tags capistrano  |  1 comments

Show

Getting beagle compiled on KUbuntu 6.10 edgy

Posted by Jim Morris on Sat Feb 03 22:32:35 -0800 2007

The version of beagle available as a standard package with Ubuntu Edgy 6.10, is horribly buggy and uses a lot of memory (2Gbytes on my machine).

I wanted to build the latest version of Beagle (0.2.15.1) on my system which is actually KUbuntu, and this required a lot of effort! I had to install a bunch of added support libraries for gtk which do not appear to be installed by default on KUbuntu. I downloaded the latest source from here.

Here is a list of what I installed using sudo aptitude install many are suggested here the rest I discovered by trial and error.

libmono-sharpzip2.84-cil
mono 
mono-devel
libmono-dev
libgdiplus
libxml-parser-perl
libsqlite0
libsqlite0-dev
libexif12
libexif-dev
shared-mime-info
libgmime2
libgmime2-dev
gtk-sharp2
libgmime1
libgmime-2.0-2-dev
libgmime2.2-cil
libbeagle0
libmono-sqlite1.0-cil
mono-gmcs
mono-classlib-2.0
gnome-vfs-extfs
libgnome-vfs-dev
libxml2-dev
libgconf2-dev
libbonobo2-dev
libbz2-dev
fam
libfam-dev
libgnomevfs2-dev
libgnome2-dev
libgtk2.0-dev
librsvg2-dev
python-gtk2-dev
gnome-sharp2 
gtk-sharp

It turned out that the installed version of mono is not high enough to build the latest version of beagle, so I installed the latest version of mono manually into /opt/mono. You can get it here, I got the Generic Mono 1.2.2.1_1 Linux installer from here.

To use this the following exports need to be done, usually in ~/.bashrc

export GTK2_RC_FILES=$HOME/.gtkrc-2.0
export PATH="/opt/mono/mono-1.2.2.1/bin:$PATH"
export PKG_CONFIG_PATH="/opt/mono/mono-1.2.2.1/lib/pkgconfig:$PKG_CONFIG_PATH"
export MANPATH="/opt/mono/mono-1.2.2.1/share/man:$MANPATH"
export LD_LIBRARY_PATH="/opt/mono/mono-1.2.2.1/lib:$LD_LIBRARY_PATH"

Additionally I needed to do this...

export MONO_PATH=/opt/mono/mono-1.2.2.1/lib/:/opt/mono/mono-1.2.2.1/lib/mono/gtk-sharp-2.0:/usr/lib/cli/gmime-sharp-2.2:/usr/lib/cli/gsf-sharp-0.0

when I got a bunch of build errors, and run errors, presumably from mono.

I am not a c sharp programmer, and know nothing about mono, so I am not sure why these search paths are needed, but they are.

After all the above you can use the standard...

./configure
make
sudo make install

to build and install beagle.

I also turned on extended attributes on my ext3 partition as explained here.

Then run beagle (making sure the above export is done first otherwise it uses the wrong version of mono and can't find some of the mono libraries.)

As far as I can see it is now running and indexing my disk, and the memory usage is pretty low, and the cpu usage is tolerable.

If anyone can add good explanations please do so in the comments section.

UPDATE This recipe also works with beagle 0.2.16

Posted in Linux  |  Tags kubuntu,edgy,beagle  |  1 comments

Show