Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

March 29 2008


To demonstrate:

class MyClass
    def say_hello(name)
        puts "Let's go back to my place, #{name}."

my_object = MyClass.new
So we get smacked if we try:
> my_object.say_hello
Nomethoderror: private method `say_hello' called for #<MyClass:0x820b4>
	from (irb):8
	from :0
but instead:
> my_object.send :say_hello, "world"
Let's go back to my place, world.


Now, honestly, this strikes me as odd. Conceptually, I don't see whysend should function differently from an ordinary method call with respect to access control.

Josh Staiger: The Ruby send hack: how to gain access to an object's privates

Sparkline PHP Graphing Library

But where's the Ruby Version? -_-
= Exception Notifier Plugin for Rails

First, include the ExceptionNotifiable mixin in whichever controller you want
to generate error emails (typically ApplicationController):

  class ApplicationController < ActionController::Base
    include ExceptionNotifiable

Then, specify the email recipients in your environment:

  ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com)

And that's it! The defaults take care of the rest.
— script/plugin install http://svn.rubyonrails.org/rails/plugins/exception_notification/

March 28 2008


I <3 Ruby On Rails

at my ruby nightjob i hack for fun. this is a part of the urbantakeover "who or what the fuck are you looking for?" just like Wikipedia's disambiguation pages.

The quick & dirty way only searches for Users and Spots at the moment, which works for astera (spot & user) but fails at metalab (spot & team).

Thus we'll hack together a dynamic solution:
stuff = []
[User, Spot, Team].each do |model_class|
stuff << model_class.find_by_name params[:name]

if stuff.size == 1
thing = stuff.first
  redirect_to :controller => thing.class.name.downcase, :action => 'show_by_name', :name => thing.name
#shows a wikipedia style "disambiguation" page
@things = stuff
render :template => 'disambiguate'
note, i haven't tried this yet, but it *should* work.

eval is your friend

at my python dayjob i'm writing a chat protocol. it should be possible to extend the protocol later on by adding new subprotocols (command sets) to achieve this i use listeners for each additional subprotocol.

the quick and dirty way to get some is:
self.listeners = {
'chat' : ChatListener(environment, self),
'table' : TableListener(environment, self),
'stats' : StatsListener(environment, self) }

but as soon as you have to add a lot of listeners it get's tedious to duplicate all the <code>*Listener(environment, self)</code> cruft.

so to keep things DRY i took the dynamic route:
listener_names = ['chat', 'table', 'stats', 'more', 'evenmoar', 'cthulhu', 'lol', 'catz']
self.listeners = {}
for listener_name in listener_names:
_class = eval("%sListener" % listener_name.capitalize())
self.listeners[listener] = _class(environment, self)

which looks super confusing, but is SUPER EFFECTIVE!

also circular references are teh suck. i want code running in contexts. to be able to omit the self parameter.

but maybe i'm doing it wrong.

@hacking @starred
Bam Oida! :-)
Reposted fromupsidedown upsidedown
9052 2ae7 390
UTO invades hamburg (thanks astera) :D
1 799 U.S. dollars = 1 146 Euros
— OMG LOL! via Google

March 27 2008

4772 c5ea 390
also: you can change your teamcolour now and everything is nicer.
4768 9358 390
due to a code error we now again have colour circles:

also: preparations for flickr are done.
also: email notifications should work shortly
also: different city guy still missing %/

March 21 2008


March 19 2008

Reposted fromweb web viaSven Sven


 += tupalo integration.

claim any spot without an address. works if it's on tupalo. yay hooray!

also: bugfixes and stuff.

March 18 2008


this reminds me get a non-competitive element in the game.

also: yay for using the stickers to post notes/comments!
Reposted bytim tim
custom stickers? yeah!
Older posts are this way If this message doesn't go away, click anywhere on the page to continue loading posts.
Could not load more posts
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Just a second, loading more posts...
You've reached the end.

Don't be the product, buy the product!