There is no magic, indeed.

January 14th, 2010

I’ve just read ”Do You Believe In Magic?” and the following quote resonated particularly well:

“It’s not magic. There is no magic involved. It’s just, if you never learnt Lisp, then you never learned to program, and Ruby’s power is exposing a deficiency in your skills.”

I find it to be very true, and I suppose one of the reasons I’m so happy about Ruby is that I learned Lisp and Scheme before.

Even though I didn’t use Lisp for any sizable project. I tried, but I found it to be quite unfriendly and ‘hairy’ in setup, environment and library support. Ruby solved all that for me w/o sacrificing almost anything power vise.

Since Github stopped to build gems we are moving to the gemcutter.

Changes in 0.2.4 since 0.2.2:

  • fixed couple of README errors (thanks Bobby Wilson)
  • changed name from ‘safe’ to ‘astrails-safe’ due to the move to gemcutter
  • added missing net-sftp dependency to the gemspec.
  • fixed bug where it would crash in a dry-run since local storage didn’t update some internal variables.

To install the latest version:

gem install astrails-safe --source http://gemcutter.org

Damn, I just found this unpublished article in the blog admin…

How come it evaded my attention for 3 months??!!

Anyway, releasing it now thought this is all quite old news, going to announce 0.2.4 in a moment :)

There is a new 0.2.2 version of astrails-safe on github.

If you don’t know it yet astrails-safe is an easy to use backup solution for Unix like operating systems. It supports filesystem, mysql, postgresql, subversion backups to local filesytem, Amazon S3 and remote SFTP.

Read the rest of this entry

I just pushed new version 0.1.9 of astrails-safe to github.

The main difference is a fix to an embarrassing bug in the S3 backup rotation code. Thanks to Thuvarakan Tharmalingam for reporting.

Again, the reason it escaped was the fact that we don't yet have full test coverage. We are getting there though....

It looks like our astrails-safe gem is quite popular :). People started to contribute new features:

I just released new version 0.1.8 on the github.

In addition to postgre/svn support this release also includes a long overdue test suite.

Read the rest of this entry

Mephisto commenting system is… how do i put it … outdated :)

And we wanted something more engaging for our blog. Looking around the web we found that Disqus was used all over the place, so we decided to integrate it into our blog instead of the native comments system.

Read the rest of this entry

Wouldn’t it be cool if you could just require “http://my-host/my-lib.rb” in ruby?

Now You Can! Using our “http_require” gem! :-)

test.rb:

require "http_require"
# this will download bar.rb and eval it
require "http://example.com/foo/bar.rb"

If a remote file (or one of its local dependencies) requires something that can’t be found locally, it will try to find it remotely from the same location as the parent.

Example

http://example.com/test/foo.rb:

# this will load "http://example.com/test/foo/bar.rb"
# if "foo/bar" is not available locally
require "foo/bar"

Stacktrace

http_require properly sets filename on eval so that the file’s URI appears in the stacktrace:

http://example.com/foo/foo.rb:

puts :foo
require 'bar'
def foo
  bar
end

http://example.com/foo/bar.rb

puts :bar
def bar
  raise
end
$ irb
>> require 'http_require'
=> true
>> require 'http://example.com/foo/bar.rb'
foo
bar
=> nil
>> foo
RuntimeError:
    from http://localhost:2000/bar.rb:3:in `bar'
    from http://localhost:2000/foo.rb:5:in `foo'
    from (irb):3
>>

Installation

sudo gem install astrails-http_require --source http://gems.github.com/

Sources

You can find sources on github

UPDATE:

There seems to be lots of similar comments that I’d like to answer here:

  • Q: This is a HUGE security hole
  • A: No it isn’t. running it directly from the web is no less secure then downloading it and then running locally. you can use same security protections, for example SSH tunnel, or SSL like you would for any other kind of ‘code delivery’ e.g. rsync, scp etc. If you control the source and the ‘tunnel’ then this is no less secure, and if you don’t, then no other method is secure unless you start encrypting/signing files.

  • Q: Why on earth would you do something crazy like this?

  • A: It is kind of cool :) Seriously though I do have a real usage in mind for this (more on that later), meanwhile consider rails app templates (rails -m app_template.rb) which do support running templates form the web, and no one seems to be crying out laud about a huge security hole :) Unfortunately though rails templates do not support (not out of the box) breaking down such remote templates into subfiles. you will need to do manual path mangeling (see app_lego for example). I guess http_require can be used to do it cleaner.

RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, TCL or PHP bindings.

Let’s run it with Ruby on Leopard.

Read the rest of this entry

Thanks a lot to Amit Hurvitz for providing a file of Virtual Disk Image (VDI) of VirtualBox, containing an up and running JRuby on Rails on Glassfish with Mysql. Image also contains some examples (actually solutions to the code camp exercises), all running on top of an OpenSolaris guest OS (can be run on many host systems).

Grab the image ~1.5GB archive.

Grab the exercises ~9.7MB archive.

We participated in JRuby on Rails with GlassFish Code Camp hosted by Sun Microsystems Inc. I was speaking about the framework in general trying to infect Java developers with Ruby On Rails. Slides are available.

Amit Hurvitz gave exciting presentation about GlassFish and short introduction into DTrace. Find out more details about the Code Camp.

Rediscovering HAML

February 11th, 2009

I was the last person in our company working with ERB to render templates. While all the rest switched to HAML. At the beginning it was quite hard for me to read HAML comparing to ERB. HAML looked for me like some completely alien thing with weird percent marks all over the place and the significant whitespace never did it for me. On the other hand ERB felt like warm home after years we spent together.

Until I did the switch.

Read the rest of this entry

Recently we looked for video transcoding/hosting solution to use in one of our client’s projects.

The best thing we’ve found is Panda. It runs on Amazon stack of services including ec2, s3, and simpledb.

Using amazon has many advantages. no contracts, pay as you go, easy and fast scaling in case your site explodes :)

Unfortunately the image that is refered in the Getting Started (ami-05d7336c) is not safe for production – it has openssh version with a serious security bug, but don’t worry, we will explain how to fix it.

Read the rest of this entry

In the process of installing Mephisto I’ve got a problem with image_science gem. It installed OK but when trying to require it the was a problem with RubyInline compilation:


astrails@alpha:~$ irb
irb(main):001:0> astrails@alpha:~$ irb -rrubygems -rimage_science
/home/astrails/.ruby_inline/Inline_ImageScience_aa58.c:3:23:
error: FreeImage.h: No such file or directory
...
CompilationError: error executing gcc -shared   -fPIC -Wall -g -fno-strict-aliasing -O2  -fPIC -I /usr/lib/ruby/1.8/x86_64-   linux -I /usr/include -o "/home/astrails/.ruby_inline/Inline_ImageScience_aa58.so" "/home/astrails/.ruby_inline/Inline_ImageScience_aa58.c" -lfreeimage -lstdc++: 256
...

is a ruby gem that allows you to write inline C code in your ruby source files and it will be compiled and linked-in when it is first used. This requires gcc and all build dependencies to be installed on the computer running it (which kind of sucks if you want to use it on an embedded device, but thats for another post)

Anyway, in this case FreeImage.h was missing which is part of FreeImage project.

Let get it back.

Read the rest of this entry

We really like Debian and we usually use the current “stable” distribution for our production servers. It all works great with one little problem: if you need very current soft it is probably not in the ‘stable’ yet.

The current Debian stable (“etch”) includes rubygems 0.9.0-5 which is way too old. We needed to upgrade to at least 1.2.

There are several ways you can try to solve such a problem. For example there are backports of selected packages from testing/unstable. Or you can compile sources yourself, which is less trivial but will help when binary backport is not available.

We are going to download sources for the newer package that is in the unstable (“sid”) distribution and compile them on the stable distribution. The procedure is simple:

Read the rest of this entry

Memory problems with gems

August 21st, 2008

Once again I’ve hit a problem of installing gems on a machine with very little memory.

Gems can use quite a lot of RAM resolving dependencies and updating gem index.

It can be a problem if you have very little memory (usual condition on most cheap VPS accounts)

In my case it was an embedded device with just 235k total memory and only about 150k free.

What happens is that kernel will kill the offending process. You’ll see in the terminal something like this:

Read the rest of this entry