Updates from February, 2007 Toggle Comment Threads | Keyboard Shortcuts

  • Dark Liquid 10:47 am on October 1, 2009 Permalink | Reply
    Tags: , , , useful, vlad   

    Dynamically Defined Targets for Remote Tasks in Vlad 

    Typically things like Vlad and Capistrano make the assumption you already know where you want to run your tasks. They assume you already have some servers somewhere ticking over just fine and you want to do stuff on them according to some predetermined pattern.

    However, what happens when you want to write some tasks you can run on any remote server? What happens if you don’t have any servers and you want to build some dynamically and then run some remote tasks on them?

    Well, I’ve been asking these questions and I found an answer that helped me out and thought I’d share it here.

    Using the dependency system of rake and the lazy role evaluation of vlad along with the fact that it provides some very useful public class methods (so they are presumably safe, rather than hacking into the internals with send or the like) I wrote the following simple test script:

    What’s going on here is that I have a remote task using a role server which as of yet I haven’t defined. When I run rake server that runs the server task. The server task is dependent on the server_config task which sets up a role ‘server’ with the given string (ideally something like user@server.com). The remote task then executes, evaluating the value of the role, which is now set to the users input, and connects to the server you’ve set at run time. How awesome is that?

    Of course, this is a contrived example, you could use a system to setup roles automatically from other things rather than pulling in user input but the lesson to take away here is that is is possible to use vlad tasks on dynamically defined targets easily.

     
  • Dark Liquid 9:20 am on May 6, 2009 Permalink | Reply
    Tags: , , ,   

    Stuff 

    Wow, things have been a little crazy recently. Work has been ish and we’re down to just me and the boss for the time being which is pretty sad. Hopefully thing’s will pick up again soon and we’re taking this as an opportunity for a company reboot so we’ll see.

    My WiiFit exercise regime isn’t happening. I’m always busy with something it seems so I never get time. I’ve not actually used it for exercise in about 3 weeks now. Terrible I know. At least my body seems to be pretty happy hovering around 15.5st rather than still ramping up the pounds of fat :)

    I’ve still been trying to write as much as possible and have managed to get Dru to start contributing more to protagonize which I am now a moderator of! So now I get to abuse my power for evil good. Woohoo!

    I’ve been trying to keep the Bournemouth.rb Ruby Group up and running recently. So far we’re only small, but we’ve managed to run a few meetups so far. Currently we’re trying to find some projects to hack on together – if you have any ideas post them up on the Bournemouth.rb wiki. I’m quite enjoying this whole community lark. Let’s hope it lasts! If you are a rubyist in Bournemouth or if you’re just interested in the Ruby programming language and looking to get into it then try coming along, signup on the Bournemouth.rb mailing list for more info.

     
  • Dark Liquid 5:34 pm on February 24, 2009 Permalink | Reply
    Tags: liquid, ,   

    Accessing Context in Liquid Drops 

    Have you ever thought it would be nice to be able to access the context from within a custom Liquid::Drop when using the Liquid template system?

    Turns out, you can.

    On Drops there is a method ‘context=’ which gets set by the parser when it comes across a Drop object. From within the drop, all you need to do is access the @context variable and you’re away.

    Why this isn’t advertised more is beyond me, or maybe I’m just an idiot and missed it, but I couldn’t see how to do this at all until I decided to sit down and essentially try and write it myself and delved into the code in Liquid that deals with processing variables. Turns out it’s already there and it works a charm. Nice for writing Drops that behave differently in different contexts, depending on register settings and the like.

    Anyway, I thought it was useful, hope this helps someone else before they pull all their hair out.

     
    • Mike Larkin 3:37 pm on July 28, 2009 Permalink

      I was halfway bald when I found this. Thank you!!

    • Dark Liquid 3:41 pm on July 28, 2009 Permalink

      No problem, I know how you feel. Lack of documentation is the bane of my existence!

  • Dark Liquid 7:49 am on November 5, 2008 Permalink | Reply
    Tags: , , , scm   

    Git tracking 

    We’ve been switching to git recently and something mildly annoys me about it not to mention certain colleagues of mine have a dread fear of editing configuration files. In most git tutorials I’ve seen, once you have created your git project and then want to set up tracking of your master branch against a remote server you are required to edit config files. Git has so many nice little tools for doing everything else, why not something for this? So, for swift justice, we decided to remedy the situation with some bash-fu.

    With the above snippet in your bash conf (yes, I recognise the irony of editing a config file to give you a command to avoid editing a config file) you can just type:

    to track the branch you are currently in against the same branch in that remote. Simple.

     
    • Ed Spencer 5:59 pm on November 5, 2008 Permalink

      Nice script, this has been a pain point for me in the past too!
  • Dark Liquid 10:55 am on October 31, 2008 Permalink | Reply
    Tags: csv, excel, , office 2007,   

    Simple Office 2007 Excel file to CSV hack 

    I needed to convert a very simple Office 2007 Excel file into a CSV. I don’t have Office 2007 so I hacked up some Ruby goodness to convert it.

    Hope someone finds this useful.

     
  • Dark Liquid 8:47 am on October 13, 2008 Permalink | Reply
    Tags: , , ,   

    Legacy Capistrano Issues 

    I have some apps deployed with older versions of capistrano but I still want to be able to use the latest capistrano on newer projects. Ideally I’d update the older apps to use the newer capistrano, but sometimes that requires a lot of work for not much benefit when I have a perfectly good copy of the old capistrano laying around to run those old deploy scripts with.

    However, by perfectly good, I mean broken. It breaks because it doesn’t specifically require the correct versions of other gems but this you can fix. This is how I fixed it for my particular use case. I’m assuming you have a recent version of rubygems where you can use the gem method for specifying require’s gem versions.

    Open up your old cap program, mine was here:
    /usr/local/lib/ruby/gems/1.8/gems/capistrano-1.4.1/bin/cap

    Before the “require ‘capistrano/cli’” line add the following:

    I also edited my lib/tasks/capistrano.rake file to have the following code in it.

    Then I created a new symlink.

    Now I can run my old stuff and I have my old cap program as well.

     
  • Dark Liquid 11:04 am on September 17, 2007 Permalink | Reply  

    Testing without the database 

    We’ve been embracing the whole testing without the database for our unit tests, making use of unit_record. However, with a recent update I found a lot of my tests failing. I eventually narrowed it down to something to do with query caching. Well, apparently query caching only gets activated if there are ActiveRecord configurations, so, since we aren’t using the database anyway, it should be okay to clear the configuration for our unit tests – right?

    Well, it was, and this is what I put in my unit_test_helper file:

     
  • Dark Liquid 11:49 am on March 25, 2007 Permalink | Reply  

    I just released my first Ruby Gem! 

    Just a few minutes ago I released my first rubygem – tuxdroid an api for interfacing with the tuxdroid robot from kysoh.

    It’s sweet being able to just do:

    Of course, you’ll need ruby-usb installed as well, which isn’t a gem as of yet so you’ll have to compile that manually.

     
  • Dark Liquid 1:18 pm on March 8, 2007 Permalink | Reply  

    Where are the Rubyists in Bournemouth? 

    Hello? Is anyone out there?

    I’m looking for other Rubyists in the Bournemouth area. There doesn’t seem to be a local Ruby User Group and so I’ve created a basic entry for one for Bournemouth at RubyHolic. Are there any other ruby guys or girls anywhere near me? I’d love to meet you.

    I’m not very good at this whole organising groups thing, so be gentle when it comes to arranging a meet up :)

    Since I didn’t see an option to add personal member details at rubyholic I’ll introduce myself here:

    I’ve been using Ruby since 2+ years ago when I started using Rails. I work with it professionally as web developer and sysadmin for a local Bournemouth web design/development company called SonicIQ (SonicIQ are hiring by the way). I’m interested in all things Ruby and am currently working on a simple Ruby/SDL-based tile engine in my spare time among other various projects. I’m mostly a Linux guy and try to attend the local LUG with some kind of regularity but I also love my MacBook.

     
    • Paul Hamblin 11:18 am on June 8, 2008 Permalink

      I live in Bournemouth but I’m on a ship in the Gulf at the moment as I’m in the Navy.

      I plan to learn RoR and probably get into it in a big way over the next few months.

      It’s good to see RoR is being developed in Bourne, hopefully I will get good enough to bring something to the table in the future but at the mo I am very much a newbie.

      I am also thinking about buying a mac because I’m getting sick of PC’s being rubbish.

      Feel free to contact me.

      Paul

  • Dark Liquid 11:01 am on February 11, 2007 Permalink | Reply  

    Ruby on Rails Exchange – Part 2 

    In my last post I wrote up the first half of my attendance of the RoR eXchange hosted by skillsmatter up in London.

    Now I’m going to cover the talks by James Cox, Damien Tanner, Ben Griffiths, Eleanor McHugh and the after-show party.

    (…)

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel