Posted
29 Jul 2007 @ 16:55

Categories
, , ,

Comments
None

Author
Alex

More Java & TextMate [Updated]

TextMate Bundle

Update: Unfortunately this doesn’t seem to work any more, I’ll update it soon.

A while ago I wrote a short post (here) about some additions that I had made to TextMate in order to improve it’s compiling of Java applications, I had made the changes because I had started programming in Java at university and wasn’t happy with the way that TextMate handled the files. In the post I promised a follow up post detailing some other improvements I had made to the Java bundle, finally, that post is here, sort of.

I’ve made so many changes to various bundles and themes it has become to difficult / long winded to document the changes in a post so instead, I have decided to release the changes as a small download from the website. You can find the files you will need on the relevant software page (this does not work anymore, read the update at the bottom of the page). The main changes are some slight tweaks of the Blackboard theme, the main theme I use and the addition of some new snippets, the compiling shortcuts from my previous post & some menu reordering in the Java bundle.

Make sure that you follow the instructions on the download page or in the README file when installing the files, I don’t want you to go breaking your computer now.

Sorry for the delay in this one, hope it satisfies you appetite, check back soon.

Posted
28 Jul 2007 @ 21:51

Categories
,

Comments
4 Comments

Author
Alex

Using rFlickr

rFlickr

I said it was coming and here it is, my little tutorial on how to use the rFlickr Ruby on Rails gem to create a photograph section like the one on my own website. The first thing to note is that pretty much all of the options available in the Flickr API (here) are available for use in rFlickr due to the fact it is all based around XML. There is a laborious process of configuration to go through, however, to make everything work, but once this is done you should have no problems.

Firstly install the rFlickr gem, I should at this juncture note the fact I am primarily a UNIX user so will aim these instructions at other UNIX users, mainly because I don’t know the specifics for Rails installations on Windows. So lets dive in (‘$’ denotes the terminal prompt and ‘\’ denotes line continues below):

$ sudo gem install rflickr --include-dependencies

The second thing you will need to do is make sure you have a Flickr account with some photos on it then pay a visit to http://www.flickr.com/services/api/keys/ and sign yourself up for an API key, once you have generated the key make a note of the key itself and the ‘secret’ that you are given, you will be needing these quite a bit.

The next thing to do is to basically follow the tutorial here, albeit with a few modifications, I have re-written the tutorial in full below.

$ cd /your/rails/application
$ ./script/console

To make differences clear the Rails console prompt will be shown as ‘>>’, don’t forget to replace the x’s with your information.

>> require 'flickr'
>> API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
>> SHARED_SECRET = "xxxxxxxxxxxxxxxx"
>> flickr = Flickr.new("/tmp/flickr.cache", API_KEY, SHARED_SECRET)
>> flickr.auth.token
=> nil

The above just sets up your rFlickr object and makes sure that you don’t already have a key.

>> flickr.auth.getFrob

This returns a value that you will need to save somewhere.

>> flickr.auth.login_link
=> "http://some.link.flickr.com"

Click or copy the link you are given into a browser and authorize the API for usage, don’t worry, we’re almost there.

>> flickr.auth.getToken('that_frob_number_we_saved')
>> flickr.auth.cache_token
>> exit

Right, this is as far as the tutorial online goes, but there are some other useful steps we need to take to make everything more useable, mainly the moving of the token as the ‘/tmp’ directory may get cleared by our host.

$ cp /tmp/flickr.cache /your/rails/application/config/flickr.cache
$ rm /tmp/flickr.cache

Now we can get onto the actual programming and leave the authentication business behind.

We’re going to need a controller to use, for the purposes of this tutorial I will use a controller named ‘Photography’, it should save me some time as that’s what mine is called, the page to be rendered will be called ‘view’.

In the file ‘photography_controller.rb’ we will need the following information, rename as necessary to your application.

class PhotographyController < ApplicationController
    API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    SHARED_SECRET = "xxxxxxxxxxxxxxxx"

    def index
        view
        render :action => 'view'
    end
  
    def view
        flickr = Flickr.new(RAILS_ROOT + "/config/flickr.cache", \
            API_KEY, SHARED_SECRET)
        @photos = flickr.people.getPublicPhotos( \
            flickr.people.findByUsername("YOUR_FLICKR_NAME"))
    end
end

Then in the ‘views.rhtml’ that you will have created in your ‘views’ folder (or at least, are creating now) paste the following code.

<% for photo in @photos %>
    <a href="<%= photo.flickr.photos.getInfo(photo.id).urls.values %>" \
        ><img src="<%= photo.url('s') %>" /></a>
<% end %>

And that’s it, your basically done, all the thumbnails will link directly to your Flickr page, easy wasn’t it? The main problem occurs when you load your newly created page, it’s very, very slow, due to the speed of the Flickr API (I think). In order to improve the situation I would recommend using either page or fragment caching, but that will be covered in a future tutorial.

Hopefully this will have given you a few pointers in using the rFlickr gem, read through the Flickr API for more inspiration if you are feeling adventurous. Check back soon.

Update: If you are having problems with Rails 2.0, take a look at this fix.

Update: I have written a new tutorial on caching your photos page, that should speed it up a lot, assuming you are having problems.

Posted
27 Jul 2007 @ 23:03

Categories
, , ,

Comments
None

Author
Alex

Scheduling & Photos

Things appear to be moving along more quickly than expected this week, I posted my main application iSyncIt and the My Book Icons on a few forums and the Apple software website and suddenly the visits to my website have rocketed from 200 a day up to 700 hits or more a day. Not as massive as some websites but it’s certainly an incentive for me to do some more work.

After many requests I have started to implement a more suitable scheduling system in iSyncIt, I added the original system for people that change their calendar and contacts very often but it seems people want more flexibility so I am currently coding something more suitable and user programmable.

Also, partially as an experiment and partially due to me wanting to unify my websites into a single website I have today programmed and uploaded a photography section to the website. This portion of the website showcases some of the better photographs that I take, for other people to see. It has been created using the ‘rflickr’ gem and my Flickr Photostream. I had several problems creating the section due to the lack of documentation for the ‘rflickr’ gem, so I will be writing a tutorial in the coming days to help other people who want to create something similar.

Well, thats all for now, check back soon.

Posted
25 Jul 2007 @ 23:30

Categories

Comments
None

Author
Alex

Quick Update

There has been a quick redesign of the caching system behind the website, this means that the cache has had to be cleared. Pages may be a little slow to load for the first time as the website cache is slowly regenerated, the search spiders help with most of the regeneration. Now the problem has been fixed you may also see slightly longer loading times on the AJAX page elements such as the archive, login and live search on the right hand side of the website.

Thanks for your patience, check back soon.

Posted
24 Jul 2007 @ 15:08

Categories

Comments
None

Author
Alex

It's Almost Complete

Rails

Today I’ve added what I believe are the final touches to the website back end. The main change is that I have finally been able to enable caching fully so the website will run much, much faster and reduce the load on my hosts server.

I thought in this post I had also better explain the architecture of the website and its caching a little bit for other people that would like to write a Ruby on Rails system for themselves. The website structure is based primarily on the 4 sections you can see in the navigation bar at the top of the page plus separate administration and account sections.

Only the 4 sections in the navigation bar have any sort of caching applied to them, all areas of these sections use page caching rather than other forms of caching, as it is generally faster. However in setting up caching I came across the problem of aspects of pages that require regular, specific modification such as the login information on the right hand side of the website or comments in blog pages, remained unchanged due to the cache. I could have sorted this by continually cleaning the caches or using fragment caching, but I wanted the website to be as fast as possible. I got around this problem through the use of AJAX.

All dynamic items on all pages of the website are called using AJAX (with the help of the Prototype framework). When you load the website you may see loading symbols in the “Account” box to the right or where the comments section is at the bottom of blog pages. The information that is called by the AJAX is not cached and is generated dynamically for every user, because the AJAX calls are JavaScript in each page only the JavaScript is cached rather than the visible product of the JavaScript.

With all modern browsers supporting the JavaScript required to implement AJAX calls, I believe this to be a valid way of using Rails page caching to my advantage.

I will write something more in depth soon, for now try http://www.railsenvy.com/2007/2/28/rails-caching-tutorial for all your caching needs.

Back soon.

Posted
22 Jul 2007 @ 12:35

Categories
, , , ,

Comments
None

Author
Alex

The Dark Side

Western Digital My Book

Today I have done the unexpected and moved to the dark side, well, for a few minutes anyway while I release version 0.4 of My Book Icons, the main change for this set of icons is the inclusion of Windows versions of all the icons, including resources for Vista. My main reason for doing this is to give people some consistency between their OS X and Boot Camp / virtualization installations of Windows. But I don’t object to pure Windows users using the icons either, so, anyone that wants them, feel free to download them here.

Now you have recovered from the shock of reading the above I can tell you about a couple of other changes, to the website mainly. In order to try any fund the website and my software / graphics development I have introduced Google Ads to the website, I’m not particularly fond of Google Adverts so I’ve tried to make them as minimal and tasteful as possible, you will only see adverts in the header above and at the bottom of blog and software pages in the form of text ads.

If you like the work I produce I would also like you to consider making a donation using the button to the right (on the website if you are viewing this through RSS), any amount you choose to donate would be helpful to me.

Any money raised through adverts / donations will go towards funding the website and my development of software / graphics. In terms of development the money will be used for my Intel Mac fund so I can develop Universal applications that I can test properly as at the moment all my development is completed on a 12" PowerBook.

Thanks for you time, check back soon.

Posted
19 Jul 2007 @ 11:45

Categories
, , ,

Comments
None

Author
Alex

So Many Changes

Well, it looks like I lied, the iSyncIt release took longer than expected, due in part to my own laziness when it comes to programming but I put the effort in and iSyncIt 1.0 has finally been released. You can download it here.

The main changes to iSyncIt are the removal of the function to remove files installed by versions less than 0.4, the introduction of a preference to change the menu bar icon to one with a little more colour – this is at the request of several people that have emailed me. The final and largest change is the introduction of scheduling for your syncs, this means that you can now tell your computer to sync with your devices every 15, 30, 60 or 120 minutes, it even takes into account your bluetooth control preference. Along with the release of iSyncIt I have also re-vamped some of my smaller applications.

Kill Dashboard, Web Server Management and Kill Front Row have all gone to version 0.2, the main changes to these applications are improved workflow and brand new icons so you can actually keep them in the dock. I’ve also had a little fun with the icons for Kill Dashboard & Kill Front Row.

To continue the theme of making new icons I have released the My Books icons I created for my own external drive to the internet. After very high demand for the icons and a large number of requests I have added the larger My Book drives, vertical versions of the icons and Leopard 512×512 resources to the icon package. You can download them here.

I don’t think I have any other news at the moment, I’m sure i’ll think of something though whilst trying to come up with my next project and more features for iSyncIt. Check back soon.