header image

Archive for November, 2006

Cialis pills

Thursday, November 16th, 2006

Cialis pills, A short time ago in a galaxy not so far, cialis pills, far away I came across a nice blog post: 15 Exercises for Learning a new Programming Language.

Cialis pills, One could argue if these are *really* the most appropriate 15(+) exercises to learn a new programming language - however, cialis pills, the task of answering this rather complex question is left as an exercise for the reader. Cialis pills, Instead of this I will show you their implementation in Ruby - rubyrailways.com style.

Cialis pills, Why did I bother to solve these problems (including not really trivial ones, cialis pills, like a scientific calculator with a GUI) ? Well, cialis pills, actually to learn a new programming language! I still consider myself a beginner Ruby apprentice just playing it by ear in my somewhat scarce free time, cialis pills, so I thought that systematically implementing a task list like this will mean great step forward for me compared to just coding random things at random times. Cialis pills, Fortunately I was perfectly right!

Cialis pills, Before we move onto the code, cialis pills, one last disclaimer: the fact that I am still a Ruby n00b implies that the code can be somewhat hairy/not optimal/[insert any other language than Ruby here]-ish so don’t use these snippets as a textbook solution of the problems or anything like that. Cialis pills, I would be glad if someone could suggest a bit of refactoring of the bad parts but I also hope that that there are some nice parts which you can learn from (actually I am quite sure about this since I used some magick formulas from a few Ruby (grand)masters in some cases).

Cialis pills, OK, cialis pills, enough talk for now. Cialis pills, Let’s see the stuff!

Cialis pills, 1. Cialis pills, Problem: “Display series of numbers (1, cialis pills,2, cialis pills,3, cialis pills,4, cialis pills, 5….etc) in an infinite loop. Cialis pills, The program should quit if someone hits a specific key (Say ESCAPE key).”

Cialis pills, Solution: Hmm, cialis pills, well, cialis pills, errr…uh-oh… Cialis pills, I could not solve this problem fully (what a terrific start :-)). Cialis pills, If Henry Ford would sit beside me now, cialis pills, he would say : You can hit any key to exit - so long as it’s ‘C’ - and one more advice: don’t forget to hold CTRL during this action :-). Cialis pills, More on this after the code snippet:

Cialis pills,

  1. i = 0
  2. loop { print "#{i+=1}, cialis pills, " }

Cialis pills, Comments : If anyone knows how to add code which will cause this program to stop with a specific keyhit (say ‘ESC’) please, cialis pills, please, cialis pills, please drop me a note. Cialis pills, I have been researching this for at least 10% of the time of solving all the tasks, cialis pills, nearly spitting blood when I gave up :-). Cialis pills, It seems (to me) that there is no simple (i.e. Cialis pills, no threads and similar) and clean platform-independent solution for this problem. Cialis pills, I guess (hope) the author’s idea here was different than to introduce threading or writing platform specific-code…

Cialis pills, 2. Cialis pills, Problem: “Fibonacci series, cialis pills, swapping two variables, cialis pills, finding maximum/minimum among a list of numbers.”

Cialis pills, Solution:

Cialis pills,

  1. #Fibonacci series
  2. Fib = Hash.new{ |h, cialis pills, n| n < 2 ? h[n] = n : h[n] = h[n - 1] + h[n - 2] }
  3. puts Fib[50]
  4.  
  5. #Swapping two variables
  6. x, cialis pills,y = y, cialis pills,x
  7.  
  8. #Finding maximum/minimum among a list of numbers
  9. puts [1, cialis pills,2, cialis pills,3, cialis pills,4, cialis pills,5, cialis pills,6].max
  10. puts [7, cialis pills,8, cialis pills,9, cialis pills,10, cialis pills,11].min

Cialis pills, Comments: The Fibonacci code was written by Andrew Johnson (found via Ruby Quiz). Cialis pills, I like it so much that I think it would be a shame to present a trivial version here. Cialis pills, I guess the rest of the code is self-explanatory.

Cialis pills, 3. Cialis pills, Problem: “Accepting series of numbers, cialis pills, strings from keyboard and sorting them ascending, cialis pills, descending order.”

Cialis pills, Solution:

Cialis pills,

  1. a = []
  2. loop { break if (c = gets.chomp) == ‘q’; a << c }
  3. p a.sort
  4. p a.sort { |a, cialis pills,b| b<=>a }

Cialis pills, Comments: This version is accepting strings - I think anybody who got to this point can adapt it to work with numbers. Cialis pills,

Cialis pills, 4. Cialis pills, Problem: “Reynolds number is calculated using formula (D*v*rho)/mu Where D = Diameter, cialis pills, V= velocity, cialis pills, rho = density mu = viscosity Write a program that will accept all values in appropriate units (Don’t worry about unit conversion) If number is < 2100, cialis pills, display Laminar flow, cialis pills, If it’s between 2100 and 4000 display 'Transient flow' and if more than '4000', cialis pills, display 'Turbulent Flow' (If, cialis pills, else, cialis pills, then...)"

Cialis pills, Solution:

Cialis pills,

  1. vars = %w{D V Rho Mu}
  2.  
  3. vars.each do |var|
  4.   print "#{var} = "
  5.   val = gets
  6.   eval("#{var}=#{val.chomp}")
  7. end
  8.  
  9. reynolds = (D*V*Rho)/Mu.to_f
  10.  
  11. if (reynolds < 2100)
  12.   puts "Laminar Flow"
  13. elsif (reynolds > 4000)
  14.   puts "Turbulent Flow"
  15. else
  16.   puts "Transient Flow"
  17. end

Cialis pills, Comments: Can you spot the trick in the part which is filling up the variables? They don’t go out of scope after the loop ends because they are constants. Cialis pills, Other possibility would be to use $global variables but I guess it is usually not a very good programming practice to do that.

Cialis pills, 5. Cialis pills, Problem: “Modify the above program such that it will ask for ‘Do you want to calculate again (y/n), cialis pills, if you say ‘y’, cialis pills, it’ll again ask the parameters. Cialis pills, If ‘n’, cialis pills, it’ll exit. Cialis pills, (Do while loop) While running the program give value mu = 0. Cialis pills, See what happens. Cialis pills, Does it give ‘DIVIDE BY ZERO’ error? Does it give ‘Segmentation fault..core dump?’. Cialis pills, How to handle this situation. Cialis pills, Is there something built in the language itself? (Exception Handling)”

Cialis pills, Solution:

Cialis pills,

  1. vars = { "d" => nil, cialis pills, "v" => nil, cialis pills, "rho" => nil, cialis pills, "mu" => nil }
  2.  
  3. begin
  4.   vars.keys.each do |var|
  5.     print "#{var} = "
  6.     val = gets
  7.     vars[var] = val.chomp.to_i
  8.   end
  9.  
  10.   reynolds = (vars["d"]*vars["v"]*vars["rho"]) / vars["mu"].to_f
  11.   puts reynolds
  12.  
  13.   if (reynolds < 2100)
  14.     puts "Laminar Flow"
  15.   elsif (reynolds > 4000)
  16.     puts "Turbulent Flow"
  17.   else
  18.     puts "Transient Flow"
  19.   end
  20.  
  21.   print "Do you want to calculate again (y/n)? "
  22. end while gets.chomp != "n"

Cialis pills, Comments: As you can see, cialis pills, I could not use the same trick here when asking for the variables, cialis pills, because when somebody wants to calculate again, cialis pills, Ruby will complain (although by printing a warning only) that the constants have been already set up. Cialis pills, Therefore I went for the hash solution. Cialis pills, I think the do-you-want-to-calculate-again part is straightforward so I won’t analyze that here.
“While running the program give value mu = 0.”
Ruby gives a rather interesting result in this case: infinity :-).
“Is there something built in the language itself?”
Sure: exception handling. Cialis pills, Division by zero could be caught with a ZeroDivisionError rescue clause.

Cialis pills, 6. Cialis pills, Problem: “Scientific calculator supporting addition, cialis pills, subtraction, cialis pills, multiplication, cialis pills, division, cialis pills, square-root, cialis pills, square, cialis pills, cube, cialis pills, sin, cialis pills, cos, cialis pills, tan, cialis pills, Factorial, cialis pills, inverse, cialis pills, modulus”

Cialis pills, Solution:
Since this code snippet is longer It would look ugly here - you can download it from here instead. Cialis pills,

Screenshot:

screenshot of the scientific calculator in action

Cialis pills, If you would like to try it, cialis pills, you will need the Tk bindings for Ruby (maybe you have them already, cialis pills, here on Ubuntu I did not). Cialis pills, Also note that only the regular 0-9 keys (and of course the mouse) work, cialis pills, the numpad ones do not. Cialis pills, One more little detail: % stands for modulo, cialis pills, not percent.

Cialis pills, Comments: Phew, cialis pills, this was a real challenge, cialis pills, mostly because I never did any GUI in Ruby before. Cialis pills, I was amazed that I could code up a relatively feature rich calculator in 100+ lines of code, cialis pills, without any golfing or trying to optimize for shortness. Cialis pills, What I wanted to say with this is that the shortness does not praise my programming skills (since I did not eve try to golf) but the superb terseness of Ruby. Cialis pills, OK, cialis pills, of course there are some problems (e.g. Cialis pills, cube, cialis pills, cos, cialis pills, tan, cialis pills, inverse are not implemented) but the usability/amount of code ratio is unbelievably high.

Cialis pills, The GUI is also not the nicest since I have used Tk - wxRuby or qt-ruby would produce much nicer results, cialis pills, but since I did not code any GUI in Ruby previously, cialis pills, I have decided to try the good-old-skool Tk for the first time.

Cialis pills, 7. Cialis pills, Problem: “Printing output in different formats (say rounding up to 5 decimal places, cialis pills, truncating after 4 decimal places, cialis pills, padding zeros to the right and left, cialis pills, right and left justification)(Input output operations)”

Cialis pills, Solution:

Cialis pills,

  1. #rounding up to 5 decimal pleaces
  2. puts sprintf("%.5f", cialis pills, 124.567896)
  3.  
  4. #truncating after 4 decimal places
  5. def truncate(number, cialis pills, places)
  6.   (number * (10 ** places)).floor / (10 ** places).to_f
  7. end
  8.  
  9. puts truncate(124.56789, cialis pills, 4)
  10.  
  11. #padding zeroes to the left
  12. puts ‘hello’.rjust(10, cialis pills,’0)
  13.  
  14. #padding zeroes to the right
  15. puts ‘hello’.ljust(10, cialis pills,’0)
  16.  
  17. #right justification
  18. puts ">>#{’hello’.rjust(20)}<<"
  19.  
  20. #left justification
  21. puts ">>#{’hello’.ljust(20)}<<"

Cialis pills, Comments: Amazingly lot of things can be done with sprintf() - I could solve nearly all the problems with it - but that would not really be rubyish, cialis pills, so I have decided for built-in (and one homegrown) functions. Cialis pills, However, cialis pills, mastering (s)printf() is a very handy thing, cialis pills, since nearly all big players (C (of course :-)), cialis pills, C++, cialis pills, Java, cialis pills, PHP, cialis pills, … Cialis pills, ) have it so you get a powerful function in more languages for the price of learning one). Cialis pills, As you can see, cialis pills, r/ljust is a nice one, cialis pills, too.

Cialis pills, 8. Cialis pills, Problem: “Open a text file and convert it into HTML file. Cialis pills, (File operations/Strings)”

Cialis pills, Solution: Well, cialis pills, this problem was not specified in a great detail, cialis pills, to say the least - or to put it otherwise, cialis pills, the solvers are given a great freedom to provide a solution spiced up with their fantasy. Cialis pills, This is what I came up with:

Cialis pills,

FINAL_DOC rules = {'*something*' => 'something', cialis pills, '/something/' => 'something'} rules.each do |k, cialis pills,v| re = Regexp.escape(k).sub(/something/) {"(.+?)"} doc.gsub!(Regexp.new(re)) do content = $1 v.sub(/something/) { content } end end doc.gsub!("\n\n") {"\n

Cialis pills, "} final_doc.sub!(/embed_doc_here/) {doc} puts final_doc

  1. doc = <<DOC
  2.  This is the first line in the first paragraph. <b>Cialis pills</b>, Nothing really interesting here, cialis pills, just plain text.
  3.  
  4. This is the second paragraph. <b>Cialis pills</b>, Let’s see some *strong* markup in action, cialis pills, and also /italic/. <b>Cialis pills</b>, So far soo good.
  5.  
  6. This is the last paragraph, cialis pills, with one more <strong>strong tag</strong>.
  7. DOC
  8.  
  9. final_doc = <<FINAL_DOC
  10. <html>
  11.   <head>
  12.     <title>Text to HTML fun!</title>
  13.   </head>
  14.   <body>
  15.     <p>Cialis pills,
  16.     embed_doc_here
  17.     </p>
  18.   </body>
  19. </html>
  20. FINAL_DOC
  21.  
  22. rules = {‘*something*’ => ‘<strong>something</strong>’, cialis pills,
  23.          ’/something/’ => ‘<i>something</i>’}
  24.  
  25. rules.each do |k, cialis pills,v|
  26.   re = Regexp.escape(k).sub(/something/) {"(.+?)"}
  27.   doc.gsub!(Regexp.new(re)) do
  28.     content = $1
  29.     v.sub(/something/) { content }
  30.   end
  31. end
  32.  
  33. doc.gsub!("\n\n") {"</p>\n<p>Cialis pills, "}
  34.  
  35. final_doc.sub!(/embed_doc_here/) {doc}
  36.  
  37. puts final_doc

Cialis pills, Comments: As you can see, cialis pills, besides that the text is wrapped around with a minimal HTML, cialis pills, every occurrence of words between asterisks is outputted in strong and between slashes in italic. Cialis pills, You can add as many such rules as you like, cialis pills, they will be (hopefully) substituted in the final output.

Cialis pills, 9. Cialis pills, Problem: “Time and Date : Get system time and convert it in different formats ‘DD-MON-YYYY’, cialis pills, ‘mm-dd-yyyy’, cialis pills, ‘dd/mm/yy’ etc.”

Cialis pills, Solution: Well, cialis pills, it was not really clear (for me) what should be the difference between ‘yyyy’ and ‘YYYY’ (resp. Cialis pills, ‘dd’ vs ‘DD’) so again I had to use my imagination. Cialis pills, However, cialis pills, I guess it does not matter too much, cialis pills, the solution has to be changed by 1-2 characters only if the original author had something different on his mind.

Cialis pills,

  1. require ‘date’
  2.  
  3. time = Time.now
  4. #’DD-MON-YYYY’, cialis pills, e.g. <b>Cialis pills</b>, 12-Nov-2006 in my interpetation
  5. puts time.strftime("%d-%b-%Y")
  6.  
  7. #’mm-dd-yyyy’, cialis pills, e.g. <b>Cialis pills</b>, 11-12-2006 in my interpetation
  8. puts time.strftime("%m-%d-%Y")
  9.  
  10. #’dd/mm/yy’, cialis pills, e.g. <b>Cialis pills</b>, 12/11/2006 in my interpetation
  11. puts time.strftime("%d/%m/%Y")

Cialis pills, 10. Cialis pills, Problem: “Create files with date and time stamp appended to the name”

Cialis pills, Solution:

Cialis pills,

  1. #Create files with date and time stamp appended to the name
  2. require ‘date’
  3.  
  4. def file_with_timestamp(name)
  5.   t = Time.now
  6.   open("#{name}-#{t.strftime(’%m.%d’)}-#{t.strftime(’%H.%M’)}", cialis pills, ‘w’)
  7. end
  8.  
  9. my_file = file_with_timestamp(test.txt)
  10. my_file.write(‘This is a test!’)
  11. my_file.close

Cialis pills, Comments: Maybe a more elegant solution could be to subclass File and override its constructor - but maybe that would be an overkill. Cialis pills, I have voted for the latter option in this case :-).

Cialis pills, 11. Cialis pills, Problem: “Input is HTML table. Cialis pills, Remove all tags and put data in a comma/tab separated file.”

Cialis pills, Solution: Since web extraction is both my PhD topic and my everyday job (and even my free-time activity :-)) I will present 3 solutions for this problem. Cialis pills, First, cialis pills, the classic old-school regexp way (by Paul Lutus), cialis pills, then with HPricot and finally with scRUBYt!, cialis pills, a simple yet powerful Ruby web extraction framework currently developed by me.

Cialis pills,

  1. table = <<DOC
  2. <table>
  3.   <tr>
  4.     <td>1</td>
  5.     <td>2</td>
  6.   </tr>
  7.   <tr>
  8.     <td>3</td>
  9.     <td>4</td>
  10.     <td>5</td>
  11.   </tr>
  12.   <tr>
  13.     <td>6</td>
  14.   </tr>
  15. </table>
  16. DOC
  17.  
  18. rows = table.scan(%r{<tr>.*?</tr>}m)
  19.  
  20. rows.each do |row|
  21.    fields = row.scan(%r{<td>(.*?)</td>}m)
  22.    puts fields.join(", cialis pills,")
  23. end

Cialis pills, Now for the HPricot solution (in the further examples let’s consider that table is initialized as in the previous example):

  1. require ‘rubygems’
  2. require ‘hpricot’
  3.  
  4. h_table = Hpricot(table)
  5.  
  6. rows = h_table/"//tr"
  7. rows.each do |row|
  8.   child_text = (row/"//td").collect {|elem| elem.innerHTML }
  9.   puts child_text.join(‘, cialis pills,’)
  10. end

Cialis pills, and last, cialis pills, but not least scRUBYt!

  1. require ’scrubyt’
  2.  
  3. table_data = P.table do
  4.                P.cell1
  5.              end
  6.  
  7. table_data.generalize :cell
  8.  
  9. puts table_data.to_csv

Cialis pills, Some explanation: first of all, cialis pills, at the moment scRUBYt! is avaliable on my hard disk (and partially in my head) only - it should be released around XMAS 2006. Cialis pills, I am using this solution for a little bit of self-promotion :-). Cialis pills,

Cialis pills, The example works like this: extract something (in this case a HTML <table>) which has something (in this case <td>) which has ‘1′ as its text (well in reality much more is going on in the background, cialis pills, but roughly along these lines). Cialis pills, This little code snippet will extract the first <td>s of ALL <tables> on a HTML page. Cialis pills, With the ‘generalize’ call we tell the extractor that it should not extract just the first <td> in a table (which is the default setting), cialis pills, but all of them.

Cialis pills, scRUBYt! can handle much, cialis pills, much, cialis pills, MUCH more complicated examples than this (like an ebay or amazon page) and has loads of sophisticated functions… Cialis pills, so stay tuned!

Cialis pills, 12. Cialis pills, Problem: “Extract uppercase words from a file, cialis pills, extract unique words.”

Cialis pills, Solution: (you can find some_uppercase_words.txt here and some_repeating_words.txt here

Cialis pills,

  1. open(’some_uppercase_words.txt).read.split().each { |word| puts word if word =~ /^[A-Z]+$/ }
  2.  
  3. words = open(’some_repeating_words.txt).read.split()
  4. histogram = words.inject(Hash.new(0)) { |hash, cialis pills, x| hash[x] += 1; hash}
  5. histogram.each { |k, cialis pills,v| puts k if v == 1 }

Cialis pills, 13. Cialis pills, Problem: “Implement word wrapping feature (Observe how word wrap works in windows ‘notepad’).”

Cialis pills, Solution: Unfortunately I am not a Windows user and I have seen notepad a *quite* long time ago - so I am not sure the task and it’s implementation are fully in-line - I have tried my best. Cialis pills, Here we go:

Cialis pills,

  1. input = "Lorem ipsum dolor sit amet, cialis pills, consectetur adipisicing elit, cialis pills, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <b>Cialis pills</b>, Ut enim ad minim veniam, cialis pills, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. <b>Cialis pills</b>, Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <b>Cialis pills</b>, Excepteur sint occaecat cupidatat non proident, cialis pills, sunt in culpa qui officia deserunt mollit anim id est laborum."
  2.  
  3. def wrap(s, cialis pills, len)
  4.   result = ”
  5.   line_length = 0
  6.   s.split.each do |word|
  7.     if line_length + word.length + 1  < len
  8.       line_length += word.length + 1
  9.       result += (word + ‘ ‘)
  10.     else
  11.       result += "\n"
  12.       line_length = 0
  13.     end
  14.   end
  15.   result
  16. end
  17.  
  18. puts wrap(input, cialis pills, 30)

Cialis pills, 14. Cialis pills, Problem: “Adding/removing items in the beginning, cialis pills, middle and end of the array.”

Cialis pills, Solution:

Cialis pills,

  1. x = [1, cialis pills,3]
  2.  
  3. #adding to beginning
  4. x.unshift(0)
  5.  
  6. #adding to the end
  7. x << 4
  8.  
  9. #adding to the middle
  10. x.insert(2, cialis pills,2)
  11.  
  12. #removing from the beginning
  13. x.shift
  14.  
  15. #removing from the end
  16. x.pop
  17.  
  18. #removing from the middle
  19. x.delete(2)
  20.  
  21. #we have arrived at the original array!

Cialis pills, 15. Cialis pills, Problem: “Are these features supported by your language: Operator overloading, cialis pills, virtual functions, cialis pills, references, cialis pills, pointers etc.”

Cialis pills, Solution: Well this is not a real problem (not in Ruby, cialis pills, at least). Cialis pills, Ruby is a very high level language ant these things are a must :).

Finally, cialis pills, you can download all the solutions in a single archive from here. I would like to see the implementation of these tasks in both Ruby (different (more optimal) solutions of course) as well as in anything else. Cialis pills, If you set out to do something like that, cialis pills, be sure to drop me a note.

Internet contains huge number of opportunities to earn money online. Cialis pills, Simply create a site that you think has the potential to sell hot items using ruby on rails. Cialis pills, Register a relevant domain name and purchase a web hosting service through hostgator, cialis pills, one of the better web host out there today. Cialis pills, Get a internet connection through one of the wireless internet providers to upload your site. Cialis pills, Work on search engine optimization to get a better traffic and also use affiliate marketing program for the same reason. Cialis pills, Finally get a free voip phone service to contact customers directly. Cialis pills, The pc to phone system is the most effective method of marketing.


Similar Posts:order zoloft,cialis pills,cheap zoloft,buy cheap ultram online,bactrim for order

Posted in Devel, Ruby, Tutorial | 31 Comments »

Viagra pharmacy

Tuesday, November 14th, 2006
  1. Viagra pharmacy, Sliced bread (1928, viagra pharmacy, Otto Frederick Rohwedder)
  2. Viagra pharmacy, Ruby (1995, viagra pharmacy, Yukihiro “Matz” Matsumoto)
  3. Viagra pharmacy, HPricot (2006, viagra pharmacy, Why the lucky stiff)
  4. Viagra pharmacy, Ruby on Rails (2005, viagra pharmacy, David Heinemeier Hansson)

What a relief! I really had the urge to tell everybody how cool HPricot is, viagra pharmacy, just did not know the way yet - until now. Viagra pharmacy, The cosmic balance is somewhat restored now that I blurted out this post :-).

Needless to say, viagra pharmacy, you need to take this list with a tiny droplet of humor: Of course if we consider development time, viagra pharmacy, amount and scope of offered solutions, viagra pharmacy, innovation, viagra pharmacy, community, viagra pharmacy, book coverage etc. Viagra pharmacy, etc. Viagra pharmacy, then Rails is a clear winner (and anyway, viagra pharmacy, the two players are not in the same league). Viagra pharmacy, However, viagra pharmacy, HPricot is a great example of how a not-new-at-all thing can be made much more usable, viagra pharmacy, fast and “heaps of fun to use” (really) just by clever design and usage of the right tools (and a dash of a cool programmer’s charisma). Viagra pharmacy, It is one thing to come up with a purple cow on a non-saturated market with lots of space for innovation, viagra pharmacy, and a different story to do the same when everything has been already said and done. Viagra pharmacy, And _why did it. Viagra pharmacy, Again.

I am writing a (not so) small web extraction framework in Ruby (planned release XMAS 2006) which heavily relies on HPricot as the HTML query language - so I dare to say I know (at least some parts of) HPricot pretty well, viagra pharmacy, yet it still keeps me totally amazed. Viagra pharmacy, What I like the most about it (besides that it is lightning-on-steroids fast compared to anything available for the same task, viagra pharmacy, feature rich, viagra pharmacy, reliable, viagra pharmacy, stable etc. Viagra pharmacy, etc.) is that it takes the ‘principle of least surprise’ to the next level: I would call it ‘principle of almost no surprise’. Viagra pharmacy, If someone has a bit of knowledge about org.w3c.dom, viagra pharmacy, XML, viagra pharmacy, XPath, viagra pharmacy, XSLT and/or has experience with other HTML/XML parsers/tools will have to refer to the documentation very rarely (of course there is a period of learning the basics and soaking into the HPricot-philosophy, viagra pharmacy, but the learning curve is really steep).

Before I get to the proof that HPricot is able to solve the food problems in Africa or something, viagra pharmacy, I need to cool down a bit :-): HPricot is not for everyone and not for every problem. Viagra pharmacy, If you need complex XPath evaluation for instance, viagra pharmacy, you will have to stick with the good old REXML (for now , viagra pharmacy, at least - I read that _why will add more XPath support and other goodies in the future). Viagra pharmacy, In the present version, viagra pharmacy, you won’t be able to evaluate things like axes (e.g. Viagra pharmacy, ancestor::html) or XPath functions (e.g. Viagra pharmacy, normalize-space) and not even XPaths with indices (like html/body/table[1]/tr[2]/td[5] - though I wrote a small script to remedy this problem temporarily.)

There are a lots of HTML-extraction related questions on the Ruby mailing list (like how to extract every table cell from a <tablle:> etc.) My advice is to alwways check out HPricot first: Sometimes it can be an overkill to use it (if you can get what you want with a simple regexp, viagra pharmacy, for example) but usually it is the right tool to parse and query even the ugliest HTML pages out there- unless you need heavy XPath/XQuery machinery which is rarely the case in the real life.

What else do I need to add? Great job, viagra pharmacy, _why. Viagra pharmacy, Thanks man.

Similar Posts:cheap tramadol,viagra pharmacy,nolvadex online stores,cheapest prozac,order klonopin

Posted in Ruby | 35 Comments »

Buy viagra

Friday, November 10th, 2006

These have been dugg and dzoned and [fill in your favorite social bookmarking site]d so nothing really new here , buy viagra, but they made me laugh out loud - so in the case anyone missed them:

:-)

Similar Posts:cheap cialis,buy viagra,order cipro,order reductil,buy generic xenical

Posted in Devel, Fun | 4 Comments »

Cheapest viagra

Thursday, November 2nd, 2006

Before everything else, cheapest viagra, getting ready is the secret of success. Cheapest viagra, (Henry Ford)

Cheapest viagra, For the last few months of my professional/geek life I have felt like I am sitting on a huge roller coaster – reaching the sky today just to find myself at the bottom of a cozy swamp tomorrow. Cheapest viagra, Sometimes I have days when I achieve the work of ten people and I am filled with so much energy and enthusiasm that my family is afraid I might blow up in any minute :-). Cheapest viagra, Even after such a very busy day I usually can not sleep too well because I am thinking/dreaming about how this or that unit test or piece of code could be improved and how will I tackle it tomorrow morning.

Cheapest viagra, However, cheapest viagra, more frequently then I would like it to happen, cheapest viagra, the very next day everything may turn out quite the opposite: Working may be mixed with browsing, cheapest viagra, playing video games, cheapest viagra, watching TV etc. Cheapest viagra, instead of focused and effective work that was fueling me to the boiling point yesterday.To add to the frustration, cheapest viagra, it is more or less unpredictable in advance when and why are the ups and downs coming and how long will they persist. Cheapest viagra,

Cheapest viagra, My overall average productivity is about equal with a well balanced person: both of us is working 200 hours a month. Cheapest viagra, However, cheapest viagra, the balanced guy achieves this by working 50 hours a week whereas my pattern is absolutely unpredictable – it may be 30 + 80 + 20 + 70 or 20 + 30 + 40 + 110 or anything that sums up to 200. Cheapest viagra, I guess 200 + 0 + 0 + 0 did not happen for only single reason yet: because a week has just 168 hours. Cheapest viagra,

Cheapest viagra, Someone could argue: why bother then? After all, cheapest viagra, the job gets done and that is all what matters. Cheapest viagra, Well, cheapest viagra, for me this is not the only thing that matters: to effectively pursue a wide range of activities, cheapest viagra, some kind of planning is needed in order to be able to process them all at once, cheapest viagra, ensuring that each gets the proper weight at due time. Cheapest viagra, While the hectic model was OK during the campus life (i.e. Cheapest viagra, watch a season of 24 (24 hours), cheapest viagra, do the work of yesterday and today (20 hours), cheapest viagra, get some sleep at last (20 hours), cheapest viagra, rinse, cheapest viagra, repeat etc), cheapest viagra, the balanced way of doing things is recommended if you have a family and job yet you still would like to stay involved in a diverse array of activities. Cheapest viagra,

Cheapest viagra, My wife used to laugh at me in the mornings when I put on my loser or winner face. Cheapest viagra, With her constant teasing she made me understand that the fact that how I feel the given day and what I am able to do depends only on me and not on certain circumstances. Cheapest viagra,

Cheapest viagra, My biggest problem seems to be that after the first excitement I tend to easily lose my interest in about everything I start. Cheapest viagra, This of course leads to cooling down and eventually drifting off the track right before the finish line. Cheapest viagra, Why? Well, cheapest viagra, to jump into some “more interesting stuff” of course. Cheapest viagra, The result: constant feeling of failure and no results to show up. Cheapest viagra, Sad but true. Cheapest viagra,

Cheapest viagra, Since I am an optimistic person and I hate to be in unpleasant situations if I can choose not to, cheapest viagra, after all that struggling I decided to come up with a plan to “visit” the finish line more often ;-) The points I have identified work for me pretty well so far and I am updating and extending them from time to time based on the results in practice. Cheapest viagra, At the moment this is what I have:

  1. Have a clear vision – if you do not know exactly what do you want to reach or where you want to end up, cheapest viagra, you will never reach that point. Cheapest viagra, (Even if you would, cheapest viagra, how would you know? :-)
  2. Make a detailed plan – if you see the progress, cheapest viagra, it motivates you to continue. Cheapest viagra, You can break down any task to small pieces. Cheapest viagra, By the end of the day, cheapest viagra, looking at your to-do list you can put up your “I made a great step forward today” smile with reason. Cheapest viagra, I break down even the household chores to small tasks, cheapest viagra, so after looking at my all-checked to-do list my wife thinks I am the fastest and most effective clean-up guy on the globe ;). Cheapest viagra, “Nothing is particularly hard if you divide it into small jobs.” (Henry Ford)
  3. Find a partner – even the most excited people lose their enthusiasm over time. Cheapest viagra, A good partner can help you to stand up when you feel like falling or loosing interest and makes you go further if you are just about to give up.
  4. Value yourself and the progress you have achieved – do not be too critical but also do not overestimate yourself. Cheapest viagra, It leads to frustration and ruins your motivation step by step. Cheapest viagra,
  5. Always determine your current level correctly and try to expand from there - it is not the biggest problem if you are weak in certain areas (since that can be improved). Cheapest viagra, However, cheapest viagra, it is much worse if you don’t admit this to yourself (which means you won’t release any effort to improve it). Cheapest viagra, Once you acknowledge your current position (e.g. Cheapest viagra, that you can work only 10 minutes continuously) you can gradually improve it (e.g. Cheapest viagra, by working without break for 1 more minute daily) until you reach the desired goal (e.g. Cheapest viagra, Alt-Tab-less working for 2 hours). Cheapest viagra, Don’t be ashamed or blame yourself for any clumsiness – identify it and get rid of it!
  6. Do not be impatient - be realistic about the amount of work you are capable to do for the given period of time. Cheapest viagra, There are some things that can be done overnight. Cheapest viagra, (I wanted to finish my Ph.D. Cheapest viagra, in a week and I failed miserably ;-)
  7. Never give up – do not stop before the finish line. Cheapest viagra, Nothing is worst than a work without results. Cheapest viagra, It consumes too much time. Cheapest viagra, By looking at just the achievements (which is usually the practice in the real life) it is useless. Cheapest viagra, No credits, cheapest viagra, no recognition. Cheapest viagra, Never stop at 99%, cheapest viagra, since that is still an unfinished job. Cheapest viagra, Even 10 * 99% = 0 (and not 990%, cheapest viagra, which is 9 by rounding) - thus 1 * 100% > 10 * 99%. Cheapest viagra,
  8. Do not be sorry for yourself – it does not help and drags you down. Cheapest viagra,
  9. Do not look around too often – too many people fail because they look at their surrounding and can not step over the boundaries of the tiny world around them. Cheapest viagra, Who cares if the guy next door is ten times better at bugfixing or writes his papers ten times faster while you are struggling with every word? Even if you may feel this on your own skin, cheapest viagra, believe me that staring at the abilities of others and the constant comparison leads to a dead end. Cheapest viagra, After some time it makes you believe you are truly useless and stupid. Cheapest viagra, Do not believe everything – probably those “Supermans” are not half as good as they seem to be, cheapest viagra, and half of the stories about them are urban legends. Cheapest viagra, And what if they are really so superb? Does it change your abilities in any way? Of course not. If there is only one point you remember, cheapest viagra, this be it. Cheapest viagra, Believe me, cheapest viagra, it can make your life much easier. Cheapest viagra, At least it made mine.
  10. Do not look for excuses – it is the simplest way to get stuck.
  11. Do the interesting and annoying things side by side – it is easy to fall to the “trap of interesting parts”. Cheapest viagra, Unfortunately the most hated parts are also part of the project (at least I have not met a project with solely “fun” parts) and need to be done as well. Cheapest viagra, Do not leave them to the end if you do not want ot struggle just before the finish line. Cheapest viagra, If you do them aside with the fascinating jobs the suffering will “disappear”.

+1 Believe in yourself - “To succeed, cheapest viagra, we must first believe that we can.” (Michael Korda) or as Henry Ford put it: “If you think you can do a thing or think you can’t do a thing, cheapest viagra, you’re right.”. Cheapest viagra,

Remember: the work you have done is measured by the final result, cheapest viagra, not the time and effort you have invested in it. Cheapest viagra, Once you start something, cheapest viagra, never look back - just from behind the finish line.

Similar Posts:prozac sale,cheapest viagra,discount clomid,lexapro sale,cheap meridia

Posted in Devel, Productivity | 6 Comments »


Bad Behavior has blocked 1233 access attempts in the last 7 days.