ejdraper.com

  • About
  • Contact
  • Archive
  • RSS
  • Ask me anything

Reboot

I’ve designed and built a brand new personal site here at ejdraper.com, and have moved over this blog - all url’s from crazycool.co.uk now point to ejdraper.com/blog, and the blog integrates with the rest of my personal site, which also includes a bit about me, my portfolio of work, my code and a lifestream on the homepage aggregating content from this blog, GitHub, Flickr, Delicious and Twitter.

As part of the migration I’ve created a new feed with FeedBurner, at http://feeds.feedburner.com/ejdraper. I’ve left the old crazycool feed running too though, and pointed it at the new site, so those of you subscribed should continue to receive the latest articles, but if you get chance it may be worth switching your subscriptions to the new feed to ensure that it always works in future.

For those interested, this new site runs on Merb, and is hosted using Apache and Passenger. The blog portion still runs on Feather, however it runs as a slice inside the main ejdraper.com app. I’ve spent a fair bit of time recently on bringing the Feather codebase up to speed to make it work with the latest Merb/DM, to finish up slices support, fix some of the bigger bugs, and to make it more stable and reliable. Soon enough I’ll be wrapping up the latest code into a 0.5 gem release, so watch this space!

Any comments on the new site and design will be welcome, and I’m going to be more blogging a lot more regularly from here on out!

    • #ejdraper
    • #feather
    • #merb
    • #reboot
  • 3 years ago
  • Comments
  • Permalink
  • Share
    Tweet

Can you hear me now?

So this blog has been a little bit up and down recently, partly because the Feather installation is overdue an update, and partly because the server could do with being rebuilt, but I figured that rather than me finding out the site has been down for a day and then manually booting it, there must be an automated way of picking up these issues and restarting the site. Sure enough, there is!

God is a great gem that allows Ruby scripts to be written to describe the configuration, settings and scenarios required for monitoring a particular process, and to outline the steps to take when certain conditions are met. I was able to knock up a script to reboot the app server for this blog whenever it doesn’t get a 200 response back from the main index, and I think that’ll do the trick nicely!

So if you see this blog is down, just give it a minute or so - God is on the case and will fix the issue shortly :-) Thanks Mojombo!

    • #downtime
    • #feather
    • #god
    • #restart
  • 3 years ago
  • Comments
  • Permalink
  • Share
    Tweet

Rename

So I’ve decided to rename my GitHub account, from http://github.com/eldiablo to http://github.com/edraper. If you’re using or working against feather-plugins or merb-manage then you’ll need to reset your remote location for doing a git pull or whatever. Not sure if you’ve forked whether that’ll continue to work, probably best to check and rebase against the repo at the new url. Any questions let me know and I’ll try to help you out if it’s screwed something up.

And just for fun, here is a video of me scoring a great free kick with the brilliant Jimmy Bullard for Fulham against Arsenal.

    • #edraper
    • #eldiablo
    • #feather
    • #github
    • #merb-manage
  • 3 years ago
  • Comments
  • Permalink
  • Share
    Tweet

What’s up Proc?

So it’s awesome Ruby snippet time, and in particular I’m going to look at the ability to evaluate statements against a block, specifically to find out where the particular block came from.

The “eval” command not only takes in the command to be executed, but can also optionally take in a binding to run against. This means that instead of evaluating a command against the current, local binding, a specific binding can be used, and for our example, we are going to use the binding on a Proc object, to allow us to evaluate a statement as if it was running within the block itself.

Let’s setup a module that allows us simply to register a block to an array:

module TestApp
  class << self
    # Adds a block to our global array
    def add_block(&block)
      @@blocks ||= []
      @@blocks << block
    end

    # This just returns our block array so we can iterate through it
    def blocks
      @@blocks
    end
  end
end

Within this same file (let’s call it test1.rb), we can also register a test block. The execution of the block isn’t really important, so let’s just do:

TestApp::add_block { puts "test1" }

Now let’s setup a second script (called test2.rb) that’ll also register a block, and that will iterate through the blocks and use the “eval” command to show where each block originated from:

# Reference our first script
require File.join(File.dirname(__FILE__), "test1")

# Add a second block
TestApp::add_block { puts "test2" }

# For each block we have, run a statement that will return the "__FILE__"
# variable for each block, against the blocks own binding
TestApp::blocks.each do |blk|
  puts "Block from: #{eval('__FILE__', blk.binding)}" 
end

If we run the test2.rb script now, we should see output similar to the following:

Block from: ./test1.rb
Block from: test2.rb

So we can now differentiate between our blocks, by investigating the blocks own binding! Something to bear in mind is that obviously the paths shown are relative – if you were executing the test2.rb script using an absolute path (for example, “ruby /path/to/test2.rb”), you’d see that the absolute paths were shown instead. Either way, the information should be useful in determining the origin of a block.

Now you may be asking, what’s the use case for something like this? Our block registration code above does nothing useful, and in fact we don’t even execute the blocks themselves! Well, within Feather we use this code to find out which plugin registered a particular block – in this way, we can check at runtime (before executing the registered block) whether the plugin is active or not. If it isn’t, it won’t be executed, if it is, it will.

This is just one of those cool things you can do when you have a reference to a specific binding – there’d be nothing to stop you from interacting with the blocks bindings in other ways too.

    • #blocks
    • #eval
    • #feather
    • #proc
    • #ruby
    • #snippet
  • 3 years ago
  • Comments
  • Permalink
  • Share
    Tweet

Changes

I haven’t posted much for the last couple of weeks, the main reason being I was busy finishing one job, and starting another. After four and a half years at Nildram, it was about time for me to move on to a new, more interesting challenge. And I also wanted to take the opportunity to move from .Net to Ruby on Rails. I was able to find a great new opportunity with a fantastic company, and I’m now a Ruby on Rails developer with TouchLocal, a local business directory. I started yesterday and my first two days have been really great, I feel like I’m settling in nicely, the people are great, and the opportunity is just as good as I thought it would be. And of course it’s awesome to be working with Ruby on Rails in my day job.

I’m aiming to get back to posting a bit more regularly on the weekend, including a round-up on the most recent progress with Feather.

    • #-net
    • #feather
    • #job
    • #ruby
    • #work
  • 4 years ago
  • Comments
  • Permalink
  • Share
    Tweet
← Newer • Older →
Page 2 of 3

About

Elliott Draper runs KickCode Ltd, a web and mobile development company specialising in Ruby on Rails.

Elsewhere

  • ejdraper on Forrst
  • @ejdraper on Twitter
  • Facebook Profile
  • ejdraper on Last.fm
  • My Skype Info
  • ejdraper on github

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr