ask the manowar fan
 

I'll let Yehuda explain the whole deal to you, how Rails 3 and Merb 2 will be the same. Why? Well, he's also doing it and I'm a nice guy dude, give credit where it is due.

What does that mean though?

I'll quote qwantz here, "like ants combining to form the shape of a giant ant"



I hope everyone feels as positively as I do about this.

 

So I got myself a tumblr. It's at http://batsysid.tumblr.com

I'm sorry if this appears twice in your RSS feed, fucking Mac blogger widget is being such a bitch.

 

Thank you for the answer Mr. anarchogeek to "you are in the middle of a conflicted merge"

"Your heart is a river that flows from your chest
Through every organ
Your brain is the dam
And i am the fish who can't reach the cord."
Death cab for cutie - Lightness

 


 

Rails 2.2 thread safe.

Oh man, this should be awesome.

Of course it only helps in certain situations, this will not guarantee your app running on steroids.

Shit like MERB might though.

 

 

Peppy CSS Selectors

Faster than a speeding bullet.

More cross-browser than Superman?

 

This idea is sufficiently plausible in an attempt to account
For the phenomenon
The sickness and the sentence of blood.
I could no longer strubble,
Every moment threatened to be the last - there was pain,
Dizziness and profuse bleeding at the pores,
How is this possible
The transmission was transfusing
In a moment the sober eye of reason would detect a vibration in the flesh.
Creeping, incoherent,
Bearing no mark of a human hand

The vision comes and goes,
But tonight I saw very clearly.
The vision comes and goes,
But tonight I saw very clearly.
Very deeply.

 

I got sick of re-writing the crawl login again and again, and I don't like using the attribute CSS selectors [attr=value]

So I wrote this.


require 'rubygems'
require 'open-uri'
require 'net/http'
require 'hpricot'

class Rule
attr_accessor :tag, :callback
def initialize(tag, &callback)
@tag = tag
@callback = callback
@preconditions = []
end

def all_ok?(tag)
@preconditions.each do |condition|
return false unless condition.call(tag)
end
true
end

def with(condition, &callback)
@preconditions << condition
self.callback = callback
self
end

def with(attribute, value, &callback)
@preconditions << lambda {|tag| tag.attributes[attribute.to_s].include?(value)}
self.callback = callback
self
end
end

class Farser
def initialize(source)
@source = Hpricot(open(source))
@rules = []
end

def find(tag, &callback)
rule = Rule.new(tag, &callback)
@rules << rule
rule
end

def farse
@rules.each do |rule|
@source.search(rule.tag) do |found|
next unless rule.all_ok?(found)
rule.callback.call(found)
end
end
end

def self.fetch(from, to)
uri = URI.parse(from)
return if File.exists?(to)
File.open(to, "wb") do |f|
Net::HTTP.start(uri.host) { |http|
resp = http.get(uri.path)
f.write(resp.body)
}
end
end
end


The usage is pretty simple


farser = Farser.new("http://something.com")
farser.find("a").with(:href, 'index').with(:name, 'someone') do |index_link|
end


No error handling and super duper method chaining.

I love it!

 

In my efforts to further make my blog prettier, I'm trying out this plugin called SyntaxHighlighter It's all Javascript and CSS and a little flash, but that's ok.

traits.each {|trait| trait.spread_awesome}


There's a nice how to use SyntaxHighlighter to post code to blogger and wordpress here.

 

Electric Sheep seriously rocks my socks. I wish I was on a Mac, cuz I've seen how pretty it is on that, but on my sweet little Dell on Windows, it's still pretty awesome.

I wonder why they called it that though.

Weird.

"Mother,
Tell your children not to walk my way"
Danzig - Mother.

 

Danzig

Posted In: , . By Sid

Her Black Wings
Devil's Plaything
777
Going Down To Die





"See she comes,
Blacker than pitch"
Danzig - Her Black Wings

 

My Word.

Posted In: . By Sid

Al Pacino in Scarface said, "I never fucked anybody over in my life didn't have it coming to them. You got that? All I have in this world is my balls and my word and I don't break them for no one."



Al Pacino in The Insider said, "I never left a source hang out to dry, ever! Abandoned! Not 'till right fucking now. When I came on this job I came with my word intact. I'm gonna leave with my word intact. Fuck the rules of the game! "



As you can see Al Pacino is trying to make a point.

You're integrity is all you're born with. What you do with it, in you're whole life is what people remember about you.

My mother will never forget the fact that I lied to her about not studying for an exam when I was 5. Does that make me a bad person, I hope not. Does that make me a liar, definitely not. That just makes me someone who lied really terribly when I was 5.

I had a Principal in school. Mr Roberts. He'd say, "The thing with lies is, they have very short legs. They run very very fast, but they get caught very soon."

My Dad says, "The thing with lies is. You need to keep stock of who you lied to about what. The thing with the truth is, it's just so much easier."

Now, I have lied before. But it was always for the right reasons, or selfishness or vanity. Why am I saying all this today? Am I confused about something? ells yes!

The Oracle in The Matrix Reloaded says, "No, you've already made the choice. Now you have to understand it."



What that means is I am trying to understand a part of myself. One that says my balls and word don't break for no one.

And while I'm at it, I'll solve world hunger and poverty and terrorism.

 

My new feed

Posted In: , . By Sid

I switched to feedburner. Because I feel really important this way, when I know how many people are stalking me.

Awesome cool ask the manowar fan feed

 

"If I just stay in bed, and pull the covers around me; if I just unplug the phone, if I don't answer the mail, then whatever bad news is waiting for me can't get to me. If I can just sleep, and then just sleep some more, then I won't have to deal with it. Not now. I can't deal with it now. Maybe it'll go away on its own. Maybe I'll die and I won't ever have to deal with it"

Call me fishmeal: On being crazy

"The most lonliest day in my life.
Such a lonely day.
Shouln't exist."
System Of A Down - Lonely Day

 

On the one hand we have:

"Freedom, urge, faith - and deeper he falls
Hatred, rage, fear - the stronger denial
Anger, heat, lust - the higher he climbs"

Satyricon - The rite of our cross.

And it is my right to my own cross.

"Life's no ordeal if you come to terms,
Reject the system dictating the norms

From dehumanization to arms production,
To hasten the nation towards its destruction
Power, power, the law of the land,
Those living for death will die by their own hand"

A perfect circle - Annhilation.

Let me be the man that you hate for always being right, on THIS day.

 

So if it's news to you that I bought a Moto Rokr E8, then dude, you don't know me at all now do you?!

Apps I can't do without:

1. GMail mobile app. Dude, that shit is fast!
2. Opera Mini. Dude, that is seriously fast! Can't do without Facebook now can I?
3. Google Maps. I get lost a lot.
4. Flickr uploader. For all the photos you take!

I will update that list with more as I discover them!

 

Everyone in the whole wide world should use the new Opera mini browser on their cellphones.

Why? Because it's super fast, super-cool, speed dial bookmarks rule! And it's actually really really fast for some reason.

No, I mean it man.

I haven't tried flash on it yet, but so far kickass!

Opera mini = Jack Bauer = Chuck Norris.

"There're millions of lives at stake, and millions of people will die if you don't do what I say, NOW! Dammit, NOW!"
Jack Bauer - Every single episode of 24

 

In Rails you ought to look at before_save as your slightly bad ass friend, who you won't give control of your assets to.

You might think that's a bad analogy. When in fact it's not. Bear with me.

Truth/Sane part of analogy:

Don't modify your objects in an before_save hook. In any way, small string manipulation, prepend a dollar sign. Any of that, in any way. Of course, this argument is only valid if you're going to add validations on that object on those fields.

Example:


class Thing
before_save :underscore_most_special

private

def underscore_most_special
name.gsub!(/[-_/]/, '_')
end

end


This is all cool right, well let's say now you throw in a validation.


class Thing

before_save :underscore_most_special
validates_uniqueness_of :name

private

def underscore_most_special
name.gsub!(/[-_/]/, '_')
end

end



class ThingTest

def test_name_should_be_unique
Thing.create!(:name=>"rambo")
assert_equal false, Thing.new(:name=>"rambo").valid?
end

end



Of course this test will pass, what test won't pass on the other hand which I didn't write on the first go is.


def test_name_should_be_unique
Thing.create!(:name=>"rambo-the-dude")
assert_equal false, Thing.new(:name=>"rambo-the-dude").valid?
end


Any guesses why?

The thing that's saved is saved with underscores, and the thing that's wants to get saved is being compared with hyphens. Later on get's saved with underscores. And you end up with duplicates.

So what's the solution. Don't use those AR hooks? Hell no, hooks are awesome! Use before_validates.