You're now viewing all of my posts relating to Ruby. Enjoy!
Link Crawler Again
October 03, 2007
Whoops. I got everything fixed with the file format issues. Steve, check out the Google Code Repository for a version of the script that should actually work.
Permalink |
Add to delicious |
4 Comments
| Tagged: LinkCrawler, Ruby, Programming
Lunch With David Yields a Link Crawler
August 31, 2007
I had tasty lunch with David at the China Restaurant yesterday. It was good to see an old friend that I met on the Internet ages ago. Hopefully sometime soon I'll get to see his babby.
Anyway, he mentioned that he was in need of a link crawler while at lunch yesterday. As we all know, I have trouble resisting psuedo-challenges like that... and oh look. What's this? Could it be? A garbage file? Put there by none other than Elingson's elite sysadmin... oh, what's this? Is this the secret bank account that the money was stashed in? Oh, I think it is. Man. You know, I kind of feel like God...
Oh, wait... sorry. Really and truly, it would appear as though rather than my usual night of BioShock and/or Metroid Prime: 3 I tore myself away to write some code. Well David, here's your link crawler! It's not heavily tested or terribly robust, but it runs against a handful of test sites and I think it does exactly what you described.
Update - 2007/10/02
I've published a bazaar repository for this project. You can find information and an updated version of this file at this posting.
Permalink |
Add to delicious |
2 Comments
| Tagged: Lunch, Ruby, Friends, Life, Programming
Computing Royal Flush Probabilities in Ruby
August 30, 2007
In a surprising turn of events the other day, I actually willingly performed some math. Andy mentioned the odds (different from probability!) of getting a Royal Flush in a game of poker... well intrigued I decided to go about modeling it in Ruby. Maybe I'll try Haskell later...
cards=52
hand=5
winning_combinations=4.00
def factorial(n)
(n==1) ? n : n*factorial(n-1)
end
combinations=factorial(cards)/( factorial(hand) \
* factorial(cards - hand) )
p=(winning_combinations/combinations.to_f)
o=p/(1-p)
printf("Combinations: %d\n", combinations)
printf("Winning Combo: %d\n", winning_combinations)
printf("Probability: %0.07f\n", p)
printf("Odds: %0.07f OR %0.07f:%0.07f\n", o, p, (1-p) )
printf("Adjusted Odds: %d:%d\n", 1, \
(combinations-winning_combinations)/winning_combinations )
Combinations: 2598960
Winning Combo: 4
Probability: 0.0000015
Odds: 0.0000015 OR 0.0000015:0.9999985
Adjusted Odds: 1:649739
Dr. Ernst would be proud. :)
Permalink |
Add to delicious |
2 Comments
| Tagged: Math, Ruby, Programming
New Ruby Site!
September 12, 2006
There's a new Ruby-Lang site, and it looks oh so delicious! The old one was terrible looking and a pain to show people who you were introducing the language in. The new design makes me want to find more converts! I really love the little Ruby code breakout towards the top. Very nice.
Permalink |
Add to delicious |
1 Comments
| Tagged: Design, Ruby
