News: Order Avandia Purchase Lasix Order Leukeran Menosan Order Brite Buy Ansaid Order Sarafem Purchase Adalat Cheap Celexa Purchase Bontril Purchase Phentermine Purchase Ophthacare Cheap Methocarbam Buy Geriforte Cheap Cephalexin Buy Ashwagandha Order Retin-A Lexapro Buy Lukol Purchase Nexium Cheap Fioricet CLA Order Cymbalta Buy Myambutol Order Nimotop Buy Rocaltrol Cheap Himcospaz Buying Didrex Order Zimulti Cheap Plendil Purchase Koflet Cheap Noroxin Cheap Deltasone Inderal Order Motrin Nicotinell Cheap Nizoral Buy Mentax Vasodilan Buy Parlodel Cheap Loprox Norpace CR Shoot Paxil Purchase Avandamet Order Requip Buy Rogaine Female Viagra Cheap Imitrex Cheap Hyzaar Buying Phentermine Lotrisone Purchase Fosamax Purchase Xeloda Zithromax Cheap Requip Buy Norvasc Purchase Quibron-T Buy Topamax Eurax Cheap Nicotinell Purchase Sorbitrate Buy Coreg Cheap Leukeran Viagra Purchase Methocarbam Purchase Zithromax Cheap Flovent Cheap Calan Purchase Cordarone Buy Pamelor Purchase Endep Purchase Menosan Buy Vasodilan Order Zerit Cheap Lotrisone Buy Seroquel Order Serophene Augmentin Buy Effects Cheap Tricor Cheap Prandin Purchase Loprox Purchase Augmentin Cheap Dilantin Lopressor Purchase High Buy Motrin Buy Zithromax Flovent Purchase CLA Cheap Superman Purchase Lisinopril Cheap Viramune Buy Abana Cephalexin Buy Protonix Buy Fioricet Order Crestor Buy Hydrocodone Order Tenormin Order Carisoprodol Atrovent Cheap Prozac Purchase Reosto Purchase Atrovent Purchase Flovent Cheap Tenuates Purchase Cardizem Buy Flexeril Cheap Styplon Order Methocarbam Purchase Pamelor Cheap Coreg Purchase Buspar ActoPlus Met Deltasone Purchase Retin-A Mentax Purchase Cytotec Buy Sustiva Motrin Purchase Ashwagandha Lariam Cheap Zerit Order Mobic Cheap Bonnisan Cheap Isoptin Order Seroquel Geriforte Cheap Accutane Purchase Lexapro Cheap Lariam Purchase Prevacid Cheap Xenacore Order Lotensin Buy Requip Buy Mevacor Purchase Norvasc Purchase Tricor Prometrium Isoptin Adalat Purchase Himcocid Purchase Flexeril Order Eurax Cheap Norvasc Pamelor Cheap Effexor Hoodia Cheap Accupril Cheap Dostinex Meridia Purchase Shoot Purchase Zebeta Order Capoten Cystone Starlix Purchase Brite Order Nolvadex Cheap V-Gel Aricept Purchase Nolvadex Cheap Flonase Buy Diakof Buy Inderal Order Kytril Arava Buy Celebrex Order Aceon Buy Clonazepam Buy Leukeran Purchase Fioricet Buy Effexor Buy Speman Purchase Diflucan Rumalaya Purchase Kytril Cheap Isordil Buy Lopid Order Diflucan Cheap Lasix Cheap Phentermine Cheap Zyloprim Fastin Cheap Nimotop Buy Famvir Buy Lotrisone Watson Cheap Lincocin Oxytrol Adderall Cheap Maxaquin Zimulti Purchase Capoten Avapro Cheap Parlodel Order Atarax Order Tulasi Buy Ismo Order Avandamet Buy Didrex Order Danazol Purchase Penisole Female Sexual Buy Darvocet Buy Lasix Buy Purinethol Purchase Ativan Penis Growth Buy Proventil Vicodin Order Pletal Oxycontin Plendil Calan Zyrtec Purchase Didrex Leukeran Cheap Pravachol Cheap Myambutol Purchase Rumalaya Order AyurSlim Buy Exelon Herbolax Buy Quibron-T Buy CLA Buy Online Renalka Cheap Aldactone Buy Noroxin Order Lopid Order Zyprexa Cheap Purinethol Buy Clarina Buy Avodart Arimidex Orgasm Enhancer Purchase Lukol Purchase Inderal Atacand Order Overnight Codeine Cheap Clarinex Buy Monoket Depakote Buying Viagra Order Amoxil Purchase Zanaflex Purchase V-Gel Purchase Prinivil Order Ephedrine Order Plavix Purchase Mexitil Order Synthroid Order Antabuse Buy Lortab Purchase Herbolax Buy Lopressor Mexitil Cheap Antabuse Buy Zanaflex Buy Pletal Cheap Motrin Buy Plan Buy Rimonabant Cheap Prinivil Order Himcospaz Purchase Mentax Order Fioricet Order Nicotinell Buy Cozaar Buy Septilin Fosamax Butalbital Purchase Adipex Purchase Septilin Order Karela Cheap Ventolin Lincocin Purchase Aristocort Coumadin Purchase Desyrel Cheap Elavil Plan B Cheap AyurSlim Order Elimite Order Viramune Buy Purim Purchase Keftab Cheap Azulfidine Cheap Atacand Buy Lincocin Order Myambutol Order Cardura Cheap Brahmi Purchase Topamax Buy Cordarone Buy Trandate Buy Triphala Purchase Clomid Elimite Order Renalka AyurSlim Buy Superman Buy Lynoral Zebeta Cheap Rumalaya Cheap Ophthacare Order Mevacor Purchase Danazol Brahmi Liv.52 Cheap Diflucan Cheap Mobic Purchase Codeine Buy Nonoxinol Viagra Jelly Purchase Detrol Order Xenacore Purchase Sarafem Order Aciphex Purchase Bactroban Chitosan Order Imdur Cheap Prometrium Buy Actos Nizoral Buy Cialis Rimonabant Buy Nimotop Buy Zyvox Order V-Gel Touch-Up Kit Cardura Buy Tulasi Purchase Diazepam Feldene Purchase Requip Buy Emsam Purchase Actos Male Sexual Prandin Septilin Buy Plendil Order Proventil Cheap Lorazepam Purchase Avapro Cheapest Ultram Buy Norco Prevacid Coreg Cheap Stromectol Buy Naprosyn Clonazepam Purchase Famvir Order Menosan Buy Xanax Buy Omnicef Cheap Zanaflex Buy Geodon Purchase Soma Buy Dospan Order Hoodia Buy Prevacid Buy Retin-A Cheap Prilosec Purchase Cozaar Order StretchNil Order Hydrocodone Purchase Evista Aciphex Acne-n-Pimple Cream Order Accupril V-Gel Purchase Zyloprim Cyklokapron Cheap Tulasi Buy Desyrel Order Isordil Purchase Lariam Order Serevent Claritin Purchase Tenuate Ventolin Buy Sarafem Order Diabecon Order Koflet Purchase Zyban Superloss Multi Purchase Xanax Cheap Gasex Cordarone Buy Penisole Ashwagandha Cheap Proventil Order Atacand Buy Proscar Order Trimox Cheap Exelon Purchase Ambien Buy Lioresal Buy Oxycontin Buy Lamictal Order Sinequan Purchase Renalka Buy Differin Purchase Didronel Order Aldactone Mentat Trimox Buy Cipro Purchase Pletal Purchase Tenormin Buy Tricor Purchase Celebrex Cheap Sarafem Viagra Soft Cheap Shallaki Lisinopril Parlodel Order Lamisil Order Watson Himcocid Cheap Bactroban Order Imitrex Proventil Phentermine Order Sumycin Order Brahmi Buy Diethylpropion Cheap Zetia Purchase Diabecon Purchase Hytrin Buy Zocor Purchase Prednisone Order Combivent Buy Fastin Order Lotrisone Order Ventolin Professional Plasma Cheap Menosan Purchase Trandate Cheap Differin Purchase Oxytrol Buy Plavix Lopid Cheap Trazodone Brafix Buy Prometrium Cheap Lopid Order Didrex Cheap Himplasia Cheap Zelnorm Cheap Famvir Cheap Clarina Purchase Noroxin Order Evista Purchase Zyrtec Order Maxaquin Kytril Order Levlen Lukol Cheap Oxycontin Cheap Mysoline Purchase Prometrium Buy Carisoprodol Cheap Zithromax Purchase Ultram Order Keftab Reosto Order Parlodel Epivir-HBV Order Adalat Altace Order Mysoline Purchase Nicotinell Cheap Loxitane Order Biaxin Cheap Nonoxinol Cheap Coumadin Buy Atarax Order Nonoxinol Buy Hoodia Buy Vantin Hoodia Weight Cheap Flexeril Purchase Rocaltrol Buy Risperdal Buy Bonnisan Order Vasodilan Purchase Combivent Order Prozac Buy Revia Cheap Avandia Buy AyurSlim Buy Flonase Buy Kytril Cheap Diazepam Purchase Cymbalta Order Gasex Order Lopressor Purchase Cipro Cheap Lexapro Buy Vicodin Order Ionamin Cheap Sorbitrate Purchase Tramadol Buy Cephalexin Purchase Isordil Grifulvin V Order Clonazepam Cheap Biaxin Purchase Zimulti Order Geriforte Cheap Diakof Purchase Snoroff Cheap Diovan Order Diovan Order Trandate Cheap Diarex Purchase Antabuse Cheap Relafen Order Sustiva Purchase Mycelex-G Buy Zimulti Buy Buspar Cheap Rogaine Purchase Confido Order Zithromax Purchase Purinethol Cheap Phentrimine Buy Avapro Nonoxinol Order Claritin Purchase Lopressor Hair Loss Order Micardis Cheap Arimidex Order Sorbitrate Cheap Omnicef Cheap Levlen Buy Lamisil Avandia Order Bactroban Buy Kamagra Buy Ventolin Order Nirdosh Accupril Purchase Crestor Order Paxil Cheap Endep Cheap Serevent Order Cephalexin Buy Brite Purchase Zocor Order Aricept Order Lasix Buy Atacand Buy Xeloda Purchase Cardura Purchase Zestril Buy Azulfidine Buy Isordil Buy Zovirax Lotensin Buy Valium InnoPran XL Buy Levothroid Purchase Percocet Zantac Cheap Zyrtec Loprox Order Monoket Cheap StretchNil Buy Glucophage Buy Vasotec Mental Booster Buy Adipex Purchase Levaquin Order Levitra Pilex Cheap Snoroff Buy Accupril Lasix Hytrin Order Zestril Cheap Zovirax Aleve Diabecon Xanax Order Chitosan Cheap Proscar Tulasi Purchase Prilosec Purchase Feldene Cheap Celebrex Cheap Prograf Soma Buy Singulair Order Zantac Cheap Ephedrine Buy Starlix Order Levaquin Purchase Cyklokapron Buy Prandin Trazodone Ismo Purchase Darvocet Flonase Purchase Micardis Buy Menosan Purchase Himplasia Cheap Brite Purchase Allegra Order Ashwagandha Cheap Pilex Order Adipex Order Exelon Purchase Bonnisan Pravachol Order Premarin Clarinex Cheap CLA Aristocort Buy Lotensin Cheap Elimite Purchase Speman Cheap Watson Norco Zero Nicotine Cheap Atrovent Cheap Acomplia Order Reosto Purchase Pilex Purchase Acticin Adipex Order Fosamax Purchase Vasotec Cheap Feldene Capoten Order Lincocin Ephedrine Order Pravachol Exelon Cheap Sinequan Order Casodex Men Attracting Himcospaz Celexa Order Buspar Cheap Tenuate Order Lariam Purchase Lorazepam Cheap Copegus Order Trazodone Order Pamelor Flexeril Cheap Aristocort Diovan Cheap Monoket Purchase Premarin Cheap Glucophage Order Prevacid Order Septilin Buy Cardizem Didrex Order Lasuna Purchase Lamisil Buy Dilantin Purchase Miacalcin Buy Avandamet Plavix Buy Elavil Virility Gum Buy Calan Darvocet Buy Vytorin Purchase Aciphex Order Naprosyn Purchase Celexa Purchase Himcolin Cheap Zebeta Buy Augmentin Cheap Depakote Cheap Aceon Buy Snoroff Purchase Protonix Order Calan Buy Shallaki Order Copegus Buy Atrovent Cheap Femcare Diflucan Cheap Levitra Buy Dosages Nexium Purchase Mevacor Avandamet Cheap Cialis Triphala Combivent Himplasia Buy Amoxil Buy Evecare Cheap Avodart Purchase Singulair Green Tea Zerit Cheap Casodex Purchase Glucophage Purchase Relafen Pletal Buy Zestril Buy Femcare Purchase Stromectol Detrol Cheap Geriforte Buy Himplasia Buy Cyklokapron Buy Amaryl Women Attracting Buy Coumadin Buy Keftab Cheap Butalbital Order Vytorin Purchase Biaxin Purchase Nonoxinol Cheap Inderal Cheap Ativan Buy Karela Buy Loprox Order Amaryl Buy Levaquin Cheap Vicodin Lasuna Hydrocodone Buy Mentat Cheap Ansaid Buy Codeine Buy Biaxin Buy Oxytrol Cheap Evista Buy Cystone Vitamin A Buy Imdur Order Diazepam Cheap Cymbalta Cheap Serophene Order Protonix Purchase Prandin Cheap Lopressor Male Enhancement Cheap Nexium Purinethol Order Prometrium Purchase Aldactone Gyne-Lotrimin Protonix Order Bonnisan Order Flovent Cheap Adalat Buy Nolvadex Order Zyvox Cheap Mycelex-G Purchase Effexor Danazol Purchase Imdur Levlen Order Plan Order Tenuate Purchase StretchNil Viramune Purchase Triphala Order Zyrtec Cheap Hydrocodone Rogaine Buy Avandia Order Norco Cheap Urispas Buy Zebeta Methocarbam Buy Methocarbam Buy Zyrtec Antabuse Cheap Ambien Buy Aricept Buy Procardia Purchase Lipitor Order Codeine Order Cordarone Purchase Zyvox Myambutol Cheap Lioresal Cipro Lioresal Cheap Crestor Order Cipro Cheap Nirdosh Purchase Sumycin Order Acyclovir Cheap Brafix Avodart Order Cardizem Aldactone Desyrel Buy Tramadol Buy Urispas Purchase Lortab Diet Maxx Order Confido Purchase Zovirax Cheap Atarax Order Zanaflex Order Emsam Purchase Zelnorm Cheap Buspar Lozol Buying Tenuate Cheap Levaquin Zyprexa

Archive for the 'Ruby' Category

David Black writes again!

Retris lives. Gosu rocks. Object thinking prevails.

I pushed the first version of Retris to github about ten minutes ago. It feels pretty good.

There are quite a few missing features, but it’s playable. There are probably a small handful of bugs. I’m only aware of one or two. Both are documented in the readme.

I want to thank Julian Raschke and the other gosu contributors. I love Ruby and it’s awesome to be able to concentrate on my game rather than dick around with low-level details.

As happy as I am that I’ve “finally made a game”, I have to confess, I don’t care for Tetris. I suck at it, too. I wrote it because I read in an old game programming book that Tetris is a good first game.

So what’s next? Well, I have a few things I want to finish up. As Diana Gruber says, “the last 10% of the game takes as long as the first 90%”. Or something like that.

At the very least I need to instate loss conditions. Currently, overflowing the grid simply causes the game to go on a freak rampage, creating shape after shape in the grid’s origin. It doesn’t crash, but you can’t do anything but exit when you reach that point.

I’d also like to put in a menu, pause feature, difficulty levels and a menu.

When those things are done I’ll start to think about another game.

I’d like to point out that I ditched the idea of using a matrix (nested arrays, actually) to model either the grid or shape objects. I made this move for several reasons:

  • Nested arrays require some math
  • I can’t ask a nested array meaningful questions
  • Previous attempts at using nested arrays fell short for me
  • It doesn’t feel very object oriented

There’s no doubt in my mind nested arrays are a viable implementation to Tetris, but personally, I prefer objects.

True, I could have wrapped the nested arrays into an object and queried that, but it’s just not decomposed enough for my tastes. My landscape (objectscape?) includes Grid, GridLocation, Cursor, Shape, Location and Block objects to orchestrate the interactions required of Tetris. (There are a few more objects, but the ones I listed are my solution to NOT using nested arrays.)

Similar to my object-oriented solution to the Tower of Hanoi, (portions of) my code read like a story. Stories are easier to grasp than mathematics. At least for now they are. I’ve decided to go back to school primarily for math.

I imagine though, that even as I become more proficient with math, the “stage” my code lives in, and the messages passed back and forth, will remain largely true to my current style.

In fact, if object-oriented programming is really all it’s cracked up to be, my style will only get tighter and more nuanced; only the implementations will change.

Five years from now I just might use an (actual!) matrix object to handle the implementation for Tetris interactions. But, my guess (indeed, my hope) is that the act of sending messages to create a story will remain in force.

Here’s to the human mind.

Since when does initialize not take arguments?

Since WHEN?!

def initialze(attributes)
  @attributes = attributes
  load_xml_request
end

Since you SPELLED IT WRONG! :)

Infinitely iterate through an array in Ruby.

class Array
 
  def roll
    loop { each { |e| yield(e) } }
  end
 
end
>> a = [ 'a', 'b', 'c' ]
=> ["a", "b", "c"]
>> a.roll { |e| puts e; sleep 1 }
a
b
c
a
b
c
a
...

Comparing custom objects with uniq.

You author a Client model. You have an array of clients and you want to call Ruby’s uniq method on them. You define “unique” clients as having the same name. This doesn’t work:

>> c1 = Client.find(1)
=> #<Client id: 1, artist_id: 1, name: "Daniel Waite", alias: "Rabbit", birthdate: nil, created_at: "2008-01-13 13:20:14", updated_at: "2008-01-23 01:03:26">
>> c2 = Client.find(4)
=> #<Client id: 4, artist_id: 1, name: "Daniel Waite", alias: nil, birthdate: nil, created_at: "2008-01-14 23:44:58", updated_at: "2008-01-14 23:44:58">
 
[ c1, c2 ].uniq.size # 2

Being the clever Ruby programmer you are, you quickly modify client…

class Client < ActiveRecord::Base
 
  def ==(other)
    name == other.name
  end
 
end

Satisfied, you run the above code again.

[ c1, c2 ].uniq.size # 2

What the fuck? Frustrated, you go medieval…

class Client < ActiveRecord::Base
 
  def ==(other)
    name == other.name
  end
 
  def ===(other)
    name == other.name
  end
 
  def eql?(other)
    name == other.name
  end
 
  def equal?(other)
    name == other.name
  end
 
end

Huffing and puffing, you carefully run your code again…

[ c1, c2 ].uniq.size # 2

ANGER SHARKS ARE SWIMMING!

But fear not my friend, for you have sought, and so the answer shall be revealed to you…

class Client < ActiveRecord::Base
 
  def hash
    name.hash
  end
 
  def eql?(other)
    name == other.name
  end
 
end

Wearily, you try again…

[ c1, c2 ].uniq.size # 1

Success!

Yes, both methods must be overridden.

You may have never seen it, but the hash method is available to all objects. I’m not quite sure how or why this works, but it does. Rejoice.

**UPDATE**

Russ pointed out that for new or unsaved objects, yes, all you have to override is the eql? method. However, to compare for equality for existing objects (i.e. objects retrieved from the database) you must override both methods.

This makes things more interesting, too. If you wanted to define equality between clients as having both the same name and the same birthdate, you can write…

class Client < ActiveRecord::Base
 
  def hash
    %{#{ name }#{ birthdate }}.hash
  end
 
  def eql?(other)
    hash == other.hash
  end
 
end

And now you have a more complex definition of what equality means. Gotta love Ruby.

The Ruby forum is hot, hot today!

An avid Rubyist proposes a very interesting #as method. It definitely looks rubyesque, but others disagree, namely James Gray and a bright fellow named Ara.

The original posting that generated a lot of good debate on the merits of such an approach.

The OP’s second attempt at gaining the hearts of others, only to be fucking smashed by Ara. Beautiful.

I don’t mean to be sensational about it, but the code presented by Ara was simply gorgeous. It reeked of solid programming and, more importantly, a fundamental understanding that if you’re resorting to “neat tricks,” you your code needs to be smothered into submission.

That said, I still like the idea of #as. It’s different, and there are some drawbacks (mentioned on the forum), but I think it’s worth feeling out. It’s easy as hell to implement:

class Object
 
  def as
    yield(self)
  end
 
end

So it’s worth trying.

Here are the two examples in question.

Ara’s suggestion (”traditional” method, in my mind):

guesses = stems.map{|stem| "#{ stem }.#{ guess_extension stem }"}
basenames = transform2 source_files + transform1(guesses)
expanded = basenames.map{|basename| File.join dir basename}

FC’s suggestion with #as:

expanded = stems.map { |stem|
  "#{ stem }.#{ guess_extension stem }"
}.as { |guesses|
  transform2(source_files + transform1(guesses))
}.as { |basenames|
  basenames.map { |basename|
    File.join dir, basename
  }
}

Now, I will not use curly braces for multi-line blocks. Forget about it. Here’s what it looks like with do…end.

expanded = stems.map do |stem|
  "#{ stem }.#{ guess_extension stem }"
end.as do |guesses|
  transform2(source_files + transform1(guesses))
end.as do |basenames|
  basenames.map do |basename|
    File.join dir, basename
  end
end

Not so pretty, is it? It’s definitely less sentence-like than with curly braces.

In the end I suppose it comes down to style and being flexible. If I were so dead-set against { and } for multi-line blocks I could definitely see using it. On the other hand I question my conviction in that area… is it worth missing out on a potentially useful feature just to follow dogma?

Programming. It’s definitely an art.

In case you ever forget the order of Ruby’s alias method.

Think of it like this…

alias :new_method, :original_method

Create a new method called ‘new_method’, based on the contents of the method called ‘original_method’.

Example…

class Rabbit
 
  def eat
    puts "You eat a carrot."
  end
 
end
 
irb(main):008:0> Rabbit.new.eat
You eat a carrot.
class Rabbit
 
  def eat
    puts "You eat a carrot."
  end
 
  alias :eat_original :eat
 
end
 
irb(main):010:0> Rabbit.new.eat
You eat a carrot.
=> nil
irb(main):011:0> Rabbit.new.eat_original
You eat a carrot.
=> nil

You can now call both methods and they do the same thing, because they are copies.

class Rabbit
 
  def eat
    puts "You eat a carrot."
  end
 
  alias :eat_original :eat
 
  def eat
    puts "You eat celery."
    eat_original
  end
 
end
 
irb(main):015:0> Rabbit.new.eat
You eat celery.
You eat a carrot.

Now you have two methods, each one is different, but one calls the other, so we have just added functionality to the original method name without losing the original functionality.

The above technique is used a lot in Rails. (Although they have a helper called alias_chain_method, which I won’t go into here, but if you’re interested, Err has a good writeup.)

One more time, for posterity:

alias :new_method, :original_method

Create a new method called ‘new_method’, based on the contents of the method called ‘original_method’.

Now if anyone can tell me how to use alias with methods that end in a question mark I’d be happy!

Pinging Technorati (or anything) with Ruby.

Searching Google has probably led you to _why’s code. While it works, I’m not satisfied with it. Why? Frankly, I don’t understand it. Not that the code itself is horribly difficult, but I’ve read Technorati’s page on how you generate your own ping, and I see very little of what they describe in _why’s code.

Technorati describes a ping as an HTTP header and an XML document. Well… okay… How do I make that? How do I tell Ruby to send what is essentially an arbitrary HTTP request out over the wire?

Enter Net::HTTP.

There’s some documentation for Net::HTTP, and even some good examples, but by and large, it’s a confusing set of libraries. It’s been a few days since I wrote this code, and I doubt I could retrace my mental steps, so I’ll just lay it on you. As with most code I’m sure it can be made better, but here she is, a fairly manual, custom ping to Technorati:

require 'rubygems'
require 'hpricot'
require 'uri'
require 'net/http'
 
xmlrpc_request = <<EOF
<?xml version="1.0"?>
<methodCall>
  <methodName>weblogUpdates.ping</methodName>
  <params>
    <param>
      <value>Rabbit Creative</value>
    </param>
    <param>
      <value>http://rabbitcreative.com/</value>
    </param>
  </params>
</methodCall>
EOF
 
url = URI.parse('http://rpc.technorati.com/rpc/ping')
request = Net::HTTP::Post.new(url.path)
request.body = xmlrpc_request
request['User-Agent'] = 'Ruby'
request['Host'] = 'rpc.technorati.com'
request['Content-Type'] = 'text/xml'
request['Content-Length'] = 250
resource = Net::HTTP.new(url.host).start do |http|
  http.request(request)
end
 
document = Hpricot.XML(resource.body)
puts document.search(:string).inner_html

The Hpricot bit isn’t necessary, but I figured I’d throw it in there in case you wanted to make your own interface and wanted to grab the result of the ping.

Oh yeah, the W3C actually has some decent documentation on request headers, and I will mention that the User Agent attribute could be (and probably should be) a little more accurate. From the W3C:

This line if present gives the software program used by the original client. This is for statistical purposes and the tracing of protocol violations. It should be included. The first white space delimited word must be the software product name, with an optional slash and version designator. Other products which form part of the user agent may be put as separate words.

Their example: User-Agent: LII-Cello/1.0 libwww/2.5

So perhaps my User Agent could be… User Agent: Ruby/1.8 Net::HTTP or something like that.

All in all everything I’ve shown you is pretty damn procedural, but it’s meant to shed light on the questions left after reading Technorati’s ping docs and _why’s code. Think of it as a shallow peek into the internals of how Ruby’s XMLRPC library could possibly work.

As always, feel free to desecrate anything here and rebuild; that’s how you learn!

Escaping URI strings the Ruby way.

You could say:

URI.encode('hello world') # hello%20world

But that’s ugly, so why not:

'hello world'.encode # hello%20world

Much nicer and more rubyesque!

Here’s one way to do it:

require 'uri'
 
class String
 
  def encode
    URI.encode(self)
  end
 
  def decode
    URI.decode(self)
  end
 
end

Why do you use decode and encode instead of escape and unescape?

Because encode and decode make more sense to me. :)

More fun with extend.

To complement a previous post about using extend, here’s a fun tidbit:

module Consume
 
  def eat
    "You eat a carrot."
  end
 
end
 
String.extend(Consume)
String.eat # You eat a carrot.
 
s = String.new
s.extend(Consume)
s.eat # You eat a carrot.

Moral of the story? The extend method can be used at the class- or instance-level. Neato!

Next Page »

online pharmacy prescription viagra dogs tramadol viagra nasal spray ambien overnight ups darvacet and ambien viagra purchase online incredibly cheap viagra viagra houston diet ephedra phentermine overnight fedex ambien prescription cheap us phentermine xanax interaction with ambien c o d phentermine is valium diazepam safe for dogs discount phentermine online discount 30 effects mg phentermine side phentermine 37.5mg generic order tramadol overnight valium picture online pharmacy and phentermine overnight viagra price strategy phentermine and adipex 50mg cialis cheapest prices for tramadol sale viagra valium on line with prescription buy tramadol cod buy ultram phentermine and hypothyroid 5generic cialis softtabs chantix and phentermine and bupropion buy cheapest phentermine online crohn's viagra phentermine who buying valium uk lipitor phentermine remeron lotensin xalatan aricept tramadol neurontin ambien creativity cialis viagra australia supply online prescriptions for cialis tramadol to treat hydrocodone withdrawal diabetes viagra viagra verses cialis buy phentermine viagra meridia ultr pay for phentermine with e-check what brand phentermine is the best alcohol viagra phentermine diet pills lawsuits viagra cialis online sales cheapest ambien overnight saturday delivery diazepam valium australia ambien cheap phentermine net viagra cocaine died dj valium omen 3 adipex ionamin phentermine free ambien diet pills phentermine online consultation prescription drug liability vioxx viagra phentermine paid buy cod can i buy phentermine any buy no perscription phentermine 375mg order phentermine without a presciption looking thim phentermine cialis viagra propecia levitra erectile dysfunction cheap viagra from pfizer real phentermine diet pills via viagra guys cialis what is it used for about viagra buy viagra on line cialis or viagra mixing cialis and viagra legit website for phentermine viagra of the amazon cialis tadalafil contents arnold cialis buy cialis onlinebuy cialis online tramadol online om mixing vicodin and cialis tramadol 537 guide online order viagra pill splitter viagra medicine phentermine viagra duration time can phentermine make you gain weight non-prescription valium reactions for phentermine free samples cialis cialis study tramadol ship on saturday natural herbal viagra acetaminophen hcl par tramadol growing heather viagra world news viagra find site computer does viagra help raynauds does valium help high blood pressure tranquilizers valium 247 phentermine viagra makes you last longer my ebay bidding buy tramadol buy dreampharmaceuticals from online tramadol mixing flexeril and tramadol hydrochloride ambien info overnight cod phentermine pricing viagra tramadol shelf life viagra can cause reduced eye pressure buy dot phentermine phentermine information site familydoctor org sildenafil viagra safe to take hydrocodone and ambien viagra print ads phentermine no prescription overnight ambien narcolepsy dream all night mixing vicodin viagra tramadol false positive pcp order phentermine 37.5 mg tramadol dosage for dog difference between valium and clonazepam online rx phentermine valium dogs dosage to buy valium generic viagra vega sildenafil citrate rx med online pharmacy phentermine cialis generic viagra hydrocodone liquid buy phentermine chubbuddiesforum phentermine info facts tramadol dose dog phentermine before and after pics tramadol maximum dosage cialis viagra levitra tramadol overseas tramadol best price viagra alternative zenegra cheap phentermine no prescription 90x90 cialis online description chemistry ingredients tadalafil buy tramadol buy cheap tramadol online generic viagra minnesota phentermine no prescription buy phentermine price comparisons valium online overnight ambien cr dosage instructions msds on tramadol generic viagra 0d 0a phentermine no prescription in california viagra side affects phentermine to canada phentermine forums and chats ambien causes night eating valium no prescription required price of viagra compared to cialis phentermine clear blue safe internet shopping generic viagra eng viagra cutter phentermine site about phentermine best prices on phentermine phentermine 30mg no doctor approval ambien drug effects viagra nz where to buy phentermine discussion boards zolpidem vs ambien rainbowpush discussion board buy viagra valium diarheah dog veterinary calm valium viagra and light sensitivity connecticut generic meltabs viagra phentermine without cheap online generic viagra cialis where tramadol 50mg synthesizing valium camille west viagra in the water tramadol hcl 50 mg active ingredients phentermine withdrawal symptoms chemical structure cialis tramadol seizure buy ambien 10mg diflucan tramadol can ambien cause priapism free online prescription phentermine 37.5 viagra penis pump pharmacy phentermine overnight buy phentermine united kingdom viagra classification phentermine zoloft viagra lawsuit settlements tramadol for vicodin detox pictures of phentermine hcl ionamin mastercard valium over the counter generic viagra on line viagra no ejaculation fedex delivery phentermine cheap cheap levitra tramadol ultram xenical hgh phentermine body detoxification best valium benzodiazepine no online pharmacy prescription valium buy online online pill viagra viagra phentermine prices pharmacy online herbal aphrodisiacs and natural viagra generic ambien manufacturers cheap tramadol online prescriptions zyrtec zyrtec price of valium on the street ionamin phentermine brand viagra 100 phentermine price comparison for phentermine soma phentermine overnight pharmacy ambien and muscle pain prednisone cialis combine compare levitra viagra and cialis ambien sample qoclick $2.00 viagra cialis mfg phentermine 37 5 mg tablets no online rx valium arthritis phentermine rheumatoid therapy affiliate best phentermine buy cialis fda