Our flash guy, uses usual loadVars for loading external data in a flash movie and do some funky stuff like plotting of nice looking portfolio charts.

But somehow, we saw some issues with loading of charts in IE6 running flash. A quick ethreal packet sniffing showed us, that although client is making
request with “Accept-Encoding: gzip,deflate”, its not able to decode the gzip response of web server. And parsing of gzipped response at flash obviously fails.
This is quite a corner case, I suppose, but I did this, to prevent Content-Encoding for that particular controller.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class OutputCompressionFilter def self.filter(controller) controller.response.headers['Content-Encoding'] = 'identity' end end class FlashController < ApplicationController no_pref true after_filter OutputCompressionFilter layout :set_layout include REXML def index end end |
Heck, my all attempts to manage a todo list has failed.
I tried these in order:
- dev-to: A command line todo list handler
- Emacs-org mode
- gTodo : A Gnome TODO thingy
- Tomboy: Tried few times
- Evolution: todo thingy
What does it indicate, time to write yet another todo manager for gnome?
I mean and I really mean, these guys are brilliant. I can’t really say, what I like in their music, but all their tunes sound oddly familiar and coming from a distance, like a bazooka from past. I love it, I wish I could do that.
Terrifying thing is, they are not afraid to release their albums in numbers like 100 or even 5. Now, how the hell, a poor guy sitting in India would ever get his hands on something like that. I am yet to see any of their records on a music store shelf.
Here Marcus talks about artists who are too fucking big:
“No. We think they’re brilliant,” Michael demurs. “I think Kid A’s the best thing they’ve ever done,” adds Marcus in his thicker Scots slur.
“Artists whose status is somewhere between Radiohead and God,” answers Marcus, mystifyingly
Above quote is the context, when Marcus criticizes mainstream musicians or rather musicians who make
music based on pop culture. The interviewer prompts,
“Who are these Bigger Guys, Radiohead?”
Needless to say I hate this moron of interviewer.
I was listening to this song for quite sometime and was wondering, what the hell it means?
Then suddenly it came. I am not sure, if i am on the mark:
I am the next act
Waiting in the wings
I am an animal
Trapped in your hot car
I am all the days that you choose to ignore
I think, “I” is not a person, but its your innocence, its your playful spirit, who
has been lost in this material world. I know, you would say,
this theme has been repeated so many times, so
whats new?
Really isn’t it, “The song remains the same!”? True, I love the song.
Another paragraphs is:
I am a moth
Who justs wants to share your light
I am just an insect
Trying to get out of the dark
I will stick with you, because there are no others
Awesome. Is there a hope?
Assuming nobody is reading this, I would quietly mention that, I released new version of BackgrounDRb plugin today.
Checkout full announcement here:
http://rubyforge.org/pipermail/backgroundrb-devel/2007-November/001043.html
Here is a sample worker:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | class FooWorker < BackgrounDRb::MetaWorker set_worker_name :foo_worker attr_accessor :count def create puts "Starting Foo Worker" @count = 0 add_periodic_timer(4) { increment_status} end def process_request p_data user_input = p_data[:data] result = self.send(user_input[:method],user_input[:data]) send_response(p_data,result) end def increment_status puts "Registering status" register_status("stuff #{rand(10)}") end def foobar puts "Invoking foobar at #{Time.now}" end def add_values user_input p user_input return eval(user_input) end end =begin problems, with existing things. =end |
I don’t want to disappoint you
I’m not here to anoint you
I would lick your feet
But is that sickest move?
I wear my own crown and sadness and sorrow
And who’d have thought tomorrow could be so strange?
My loss, and here we go again
REM
If you have any hopes of becoming a Ruby guru, then regular dose of ruby-talk is a must. In this post, I would try to summarize some of the cool stuffs being discussed on ruby-talk.
-
In Ruby, having method names that contain “-” can be PITA. So David Black and others were quick to point following approach of doing so:
1 2 3 4 5
irb(main):002:0> class C irb(main):003:1> define_method("x-y") { puts "Weird method" } irb(main):004:1> end # At which point, the only way to call it is: irb(main):005:0> C.new.send("x-y") # Weird method
In other words, it’s not worth the trouble and you should find some
other solution. - Trans asked on ruby-talk, how can we know, which files are loading or requiring this file. Ara pointed following solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
p Kernel.requiree('main') require 'b' p Kernel.requiree('main') BEGIN { module Kernel h = Hash.new define_method(:requiree) do |of| h[of] end r = method :require define_method(:require) do |*a| r.call *a h[a.first] = caller end end }
The interesting bit around, should be noted.
1
r = method :requireWhen you call method and pass method name as a parameter, it returns a closure. Although as pointed by someone it breaks “Rubygems”, and above approach shouldn’t be used. Rather, one should use:
1
alias_method :old_require, :require
Whoa, how stupid. All you have to do is:
1 2 | if((pid = fork()).nil?) $0 = "ruby #{worker_klass.worker_name}" |
I was reading on twitter experience of scaling rails and use of dtrace. Unfortunately for GNU/Linux users “dtrace” is just a unreality. But if you just concentrate on the results, then you will find that, a major source of bottleneck was use of:
foo = @someobj.amazing rescue "not_amazing"
Above code is in vogue, because it takes care of a lot of things like:
- if @someobj is nil, then foo defaults to “not_amazing”.
- if @someobj doesn’t support “amazing” method, foo defaults to “not_amazing”.
- And of course the obvious case.
But that code succinctness comes at a cost and you may end up with deep stacktraces. This was a major bottleneck for twitter team.
Above snippet can be written as:
foo = @someobject.blank? ? "not_amazing" : (@someobject.respont_do?(:amazing) ? @someobject.amazing : "amazing")
Not so succinct, but does its job.
Read the details http://blogs.sun.com/ahl/entry/dtrace_for_ruby_at_oscon .
This post is more of a “tumbler” style, but since I am lazy and doesn’t want to elaborate more and rather I would let respective links speak for themselves.
1. When you are working to create some sort of platform from scratch, you may find that your database is kinda stopping you from going full speed ahead. You may have several backend components and each of them interact with your database. But the problem with databases are, only so few connections it can spare and it becomes a bottlebeck afterwards. Geeks at newyork times( thats right, the newspaper guys) have developed a little utility called dbslayer, which lets you perform sql queries on database using JSON and it returns JSON responses. This is pretty neat and since it does this over HTTP, your database can scale. So, the idea is basically to use dbslayer layer in applications that are not too much into database and don’t basically need a persistence connections. Here is the link: http://code.nytimes.com/projects/dbslayer . And here is a little Ruby code sample, on how to perform a sql query using dbslayer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | require "rubygems" require 'open-uri' require "json" @slayer_server = "localhost" @slayer_port = "9090" def query_url(sql) query_hash = { "SQL" => sql } url_args = URI.encode(query_hash.to_json) "http://#{@slayer_server}:#{@slayer_port}/db?#{url_args}" end def exec_query(sql) url = query_url(sql) open(url) do |f| yield JSON.parse(f.read) end end exec_query("select login from users") do |results| p results end |
2. In Ruby 1.9, matz has checked in support for Fluent Interfaces . Its pretty neat. David Flanganan talks about it here . David is the guy, who wrote “Javascript: the Definitive guide”. Good to see him working on Ruby.
3. Its hard to predict schedule of a software project because of so many uncertain things involved. Fred Brooks, Mythical man month is a milestone work on it. But looks like Joel’s team has done wonders in solving this uncertainty. Here Joel talks, how you can use Evidence bases scheduling for scheduling your project with reasonable accuracy. On a related note, here Joel talks, how having a active bug database is essential for a software project.
4. On edge rails, now you can refer fixtures as if they had associations. Its quite nice and makes job a lot easier for guys, who relied on fixtures for testing. There are certain cases against fixtures and how they make your tests “brittle”. But I have come to realize that, a combination of fixtures and mocks are probably best way to go. Here Pratik talks about latest code changes.
5. “A little Ruby” is a nice book for experienced Ruby developers who are looking to learn metaprogramming with Ruby. The sad part is, its not complete. Now, with growing interest in Ruby, the author wonders whether he should revive the project and complete the book. Vote for completion here
