Introducing ProxyFS

June 25th, 2011

I proudly present ProxyFS: https://github.com/flakks/ProxyFS

Using ProxyFS you can mount a proxy of a local directory to distribute files transparently to multiple mirrors in a live manner for replication/synchronization. Simply perform all writes on the mounted proxy to let ProxyFS replicate them to your mirrors. Every write to the mounted proxy goes to all mirrors and the local directory or nowhere (a kind of transaction mechanism). Only real unrecoverable errors (‘long’ unavailability of servers) will leave your mirrors out of sync. ProxyFS is designed for use in WANs and servers seperated from each other largely. Currently, all writes are synchronous. Therefore, the speed will differ for different connections, of course.

ProxyFS is written in ruby and uses the fuse library for ruby. It’s current state is an early alpha. Therefore, only use it on your own risk!

JS/Linux

May 18th, 2011

JS/Linux in your browser: http://bellard.org/jslinux/
Developed by the creator of Qemu.
Some technical notes can be found here: http://bellard.org/jslinux/tech.html

conference time

April 20th, 2011

i’ll speak at eh2011 this saturday (easterhegg2011) and i2cs in june (i2cs).

monkey patching will_paginate to use default_scope

March 1st, 2011

Unfortunately, will_paginate does not use default_scope like so:

class Order < ActiveRecord::Base
  default_scope :order => "id DESC", :include => [ :shipping_address, :billing_address, :order_items ]
  ...
end

But this is easy to fix:

class ActiveRecord::Base
  class << self
    alias_method :paginate_orig, :paginate

    def paginate(options)
      defaults = default_scoping.inject({}){ |res, current| res.merge current[:find] }

      paginate_orig defaults.merge(options)
    end
  end
end

strange ruby syntax issue when using rescue

August 15th, 2010
irb(main):001:0> x = "value"
=> "value"
irb(main):002:0> x = puts undefined_variable rescue nil
=> nil
irb(main):003:0> x
=> "value"
irb(main):004:0> x = puts(undefined_variable) rescue nil
=> nil
irb(main):005:0> x
=> nil

You might understand why this happens when you think about it, but it’s rather unintuitive, though.

mobile-fu rjs

July 15th, 2010

hm… hm… hm… hm

I’m a bit unsatisfied with mobile-fu for rails. Sure, it’s great in general, but I want to have different templates for mobile rjs and default rjs and i think it’s a bit clumsy to do it like that:

application.html.erb

def mobile?
  return session[:mobile_view]
end

# distinct between mobile and non-mobile js (mobile-fu)
# only supports :template paramter for mobile-enabled js

def render_mobilized_js(options = nil)
  # if we're not mobile => render like there is no mobile

  unless mobile?
    return render options if options
    return render
  end

  # render mobilized rjs template

  ops = (options || {}).dup

  ops[:template] ||= "#{controller_name}/#{action_name}"
  ops[:template] += ".mobile_js.rjs"

  return render ops
end

but now I’m able to do this

respond_to do |format|
  format.html
  format.js { render_mobilized_js }
end

But in an ideal world i don’t want to call render at all. I want rails or mobile-fu to do it for me:

respond_to do |format|
  format.html
  format.js
  format.mobile_js
end

Not yet possible – and if it would be possible it would break dependencies. Therefore i keep using my method – unless anyone points me a step towards the elegant solution… anyone?

ruby spreadsheet library

May 5th, 2010

Thumbs up for http://spreadsheet.rubyforge.org/ A ruby library for accessing .xls files. Really comfortable. Just missing a way to access columns by excel-like captions

sheet.row(0)["AA"]

Maybe i just didn’t find it, but nevertheless you can of course extend String, though

class String
  def to_excel_index
    each_char.collect{ |c| ("A".."Z").to_a.index(c) }.
      inject { |sum, n| sum + (sum + 1) * 25 + n + 1 }
  end
end

and use

sheet.row(0)["AA".to_excel_index]

My article for linux technical review

March 31st, 2010

A few weeks ago I wrote an article on virtualization security. See here http://www.linuxtechnicalreview.de/Vorschau/%28show%29/Themen/Virtualisierung/Sicherheit-in-virtuellen-Umgebungen

17th dfn cert workshop

March 31st, 2010

I was speaking on the 17th dfn cert workshop on virtualization security. It was quite cool to speak in front of such a large audience. There was quite a good response. Here is the link to the workshop website: http://www.dfn-cert.de/veranstaltungen/workshop.html

Here is the conference room when i arrived in the morning before it was full.

hping2 for the nokia n900

January 10th, 2010

I recently played with the “sdk” for my nokia n900. The “sdk” is a cross compilation platform built on scratchbox. The n900 runs maemo, a debian based linux for the arm architecture. I wanted to compile netcat for the phone until i found this, which perfectly runs on the phone. Then i decided to compile hping2 – and you can download my package and install it on your n900. I’ll upload it to the maemo garage, too.

https://garage.maemo.org/projects/hping2/