Limi's Sphere of Influence

dabbling, frivolling, idling, loafing, loitering, playing and procrastinating

Archive for the ‘Programming’ Category

If you use Synergy with Ubuntu and a Windows system you may find when you press the @ key, you infact end up with the Ω symbol, which is’nt very useful (especially if your coding Rails).

After some quick searching, I found a blog and some forum discussions about the fix, granted it took 2 years from thread starting to solution being provided, but this is it…

xmodmap -e “keycode 53 = x X greater greater greater greater”
xmodmap -e “keycode 52 = z Z less less less less”
xmodmap -e “keycode 24 = q Q at at at at”

As i’m sure you’ll agree, thanks go out to those involved! No more copy pasting one from the Windows machine! :D

Catch up time

So I think it’s about time I give a general update as to where I am with my various personal projects…

Snapr Photo Gallery

I had Snapr running on my local server for quite a while, however it being there meant I couldn’t really show my photos to the world as it depends on my ADSL being stable/fast. This also put a burden on the Internet connection which I can’t really afford since when I’m not coding, I’m usually playing games or hosting games, and to randomly have my upload disappear wasn’t great. So about 8 months ago it got turned off, however, as my holiday is quickly making an appearance I might resurrect it’s code base, but with whats going on at the moment I doubt I’ll be able to get it working again in time.

GOW Take 2

I’ve been meaning to move away from Wordpress for a while, not for any particular reason, but other than I’d like to have coded my own; especially since the closest I’ve gotten to coding a blog in rails was a very simple one for part of a big website. I want it to support all the basics such as trackbacks/pingbacks so that there is no major blog downside from using it over Wordpress. This is coming together quite quickly at the moment, it isn’t going to be a Wordpress clone, as I have no intention to support multiple themes/users. I think I’ll release the code base when its finished, but with no intention of supporting/maintaining it beyond security issues.

I Watched That

This is a project I’ve had on back burners for nearly 2 years now, it’s basically last.fm for the TV world. So you can mark which shows you watch, comment on episodes, and mark specific seasons/episodes as watched so that you can keep track of what your yet to view. This would also include a recommendation/suggestion engine, along with the usual social networking side of things. Initially started on a really old version of Rails, it’s currently being upgraded to the latest Rails 2.3.2. Taking much longer than I initially thought as most of the code I wrote back in the day is well… not so good. So big chunks are being re-written to make them more efficient and to satisfy the part of my brain that’s a perfectionist.

Host Controller

This was originally a XP only utility that I used to use while developing on Windows. It allows you to toggle entries in the Windows host file on and off whenever you like. After I switched to developing on Ubuntu I had no real use for this application, and since then it remained in a working state for XP. Since now I have a Vista machine I decided to give it a little go just to make sure it still works. Had to make some small tweaks to get it operational again, however it’s now in a working state for how my machine is setup. (So chances are, it probably won’t work on your Vista machine). I need to support UAC, which currently it doesn’t. But beyond that, it’s a small cheerful program that does its job. If you want it, you can find the source code on github and a download of the application can be found here.

So quite a quick round up on whats going on, will hopefully post some more around the Rails blog, since that’s what I’m working on at the moment in my free time. A post on default_scope is definitely on the horizon.

I recently upgraded a laptop of mine from Intrepid Ibex to the Jaunty Jackalope beta, and wanted to get Rails development up to speed on there. However it seems that I fell into the usual pit hole when installing Ruby on Ubuntu that simply going…

sudo apt-get install ruby

…isnt enough, and doing so will produce this lovely error…

extconf.rb:8:in `require’: no such file to load — mkmf (LoadError)

So, to combat this, you need to do instead…

sudo apt-get install ruby1.8-dev

or for Ruby 1.9…

sudo apt-get install ruby1.9-dev

And then the error will magically disappear.

In patch 3.0.8 Steady Shot was nurfed by 10% damage, so I have re-written my mashable macro a little to weave in Arcane Shot to increase it’s damage.

#showtooltip Auto Shot
/cast Kill Shot
/castsequence reset=shift/target Hunter’s Mark, null
/castsequence reset=target/3/alt Arcane Shot, Serpent Sting, Steady Shot, Steady Shot, Arcane Shot, Steady Shot, Steady Shot, Steady Shot

Basically the same as the first version I made, which you can find here along with the explanation on what everything does.

WARNING – THIS MACRO HAS BEEN UPGRADED, THE NEW VERSION CAN BE FOUND HERE

After a very long stretch of not playing around with macro’s in WoW, I decided to see just how far the legal macro system could be pushed. After various browsing, testing and changing I’ve come up with a key mash macro…

#showtooltip Auto Shot
/cast Kill Shot
/castsequence reset=shift/target Hunter’s Mark, null
/castsequence reset=target/3/alt Serpent Sting, Steady Shot, Steady Shot, Steady Shot, Steady Shot, Steady Shot, Steady Shot, Steady Shot

Now what does it actually do?

Start auto-shooting, then if it can, cast Kill Shot, otherwise (if shift is pressed or target has changed) cast Hunter’s Mark, after that cast Serpent Sting, followed by 7 Steady Shots (will reset if target changes, alt is pressed, or if macro is’nt used for 3 seconds). It has not been designed to cope with the Glyph of Serpent Sting, but if you do have that glyph changing this macro is as easy as adding 2 or 3 more Steady Shots.

This is designed to keep Serpent Sting on your target at all times, so that the bonus 10% damage from Glyph of Steady Shot will be applied on all your Steady Shots. It’s debatable if kill shot should be after hunters mark, but I decided to put it at the start so that if you can kill shot you do it as soon as possible, rather than waiting for Hunters Mark + 1.5seconds GCD. It should also be noted that if hunters mark fades, it will not automatically re-cast it, you’ll need to hold shift to get it to re-cast.

Enjoy

WARNING – THIS MACRO HAS BEEN UPGRADED, THE NEW VERSION CAN BE FOUND HERE

An odd titled name for something that I had to remember how to do today. If you need to sort something by the number of its has_many object, eg…

Album has_many photos, listing albums with the most photos first
Forum has_many posts, listing forums with the most posts first
Group has_many users, listing groups with the most users first

…and you want to show these parents ordered by the number of children objects they have you need to do this…

a = Album.find(:all).sort { |x,y| x.photos.size <=> y.photos.size }

Obviously you can use named_scopes and conditions to restrict it down if you don’t want all of a certain object, either child or parent.

Hopefully this helps someone out.

  • 1 Comment
  • Filed under: Programming, Rails, Ruby
  • Had to go look this up today as we are using more named_scopes at work now, although couldn’t off the top of my head remember how to get a named_scope to take an argument nicely. Anyway, the solution is…

    named_scope :recent, lambda { |*args| {:conditions => ["created_at >= ?", (args.first || 10.minutes.ago)] } }

    Hopefully this helps someone out

  • 0 Comments
  • Filed under: Programming, Rails, Ruby
  • This is the easiest way to get RMagick installed in Ubuntu Intrepid Ibex for Ruby….

    sudo apt-get install libmagick++9-dev

    …then…

    sudo gem install rmagick

    Job done!

    If you had a previous installation of Aptana Studio in hardy and now that you’ve upgraded to ibex it no longer works then you aren’t alone. It no longer works since during the upgrade Firefox 2 was removed from your system, and there isn’t a way to put it back in as its been removed from the package manager.

    Luckily the fix is easy…

    sudo apt-get install xulrunner

    Then you’ll need to either edit or create a startup script for Aptana to use. So make a file called “runAptana.sh” in /usr/local/aptana and inside that put…

    #!/bin/bash
    export MOZILLA_FIVE_HOME=/usr/lib/xulrunner
    /usr/local/aptana/AptanaStudio

    Then, whenever you want to run Aptana use that script instead; otherwise you’ll get those nasty errors which hamper your daily work efforts!

    Subclipse is a SVN plugin for Aptana, and it allows you to interact with the SVN server from within the IDE. However getting this running properly on my Ubuntu 8.04 machine proved to be more challenging than just installing it.

    The problem I was having was that when I went to talk to the SVN server, it would always ask me for my username and password, there was no option to remember it. I thought this a little strange and upon visiting the preferences dialog (Window->Preferences->Team->SVN) I was greeted by a nice error “Failed to load JavaHL library”. Which of course meant I couldn’t change any options without it bitching that it wasn’t available.

    So how do we fix this? First off…

    sudo apt-get install libsvn-java

    Then, if you’re lucky, you should just have to restart Aptana in order for it to now detect it. However, if your machine was like mine and it didn’t detect it then you’ll need to do the following. Go to where Aptana is installed, for me this was /usr/local/aptana

    cd /usr/local/aptana
    gedit AptanaStudio.ini

    You’ll then need to add the following line to the end of this file

    -Djava.library.path=/usr/lib/jni

    That’s technically it, all you should need to do now is save the file, restart Aptana and it’ll be working for you. Well, I say you, I mean me :P

    So now that JavaHL is installed correctly, when I next talked to the SVN server, it once again, asked me for my login details, however a lovely “Save Credentials” checkbox appeared saving my sanity from inputting my details everytime. :D