Skip to content

Commit

Permalink
Use a shorter but better sample code in the homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ary Borenszweig committed Jun 7, 2015
1 parent 81bcea9 commit dfb409b
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions _includes/sample_code.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
{% highlight ruby %}
# Compute prime numbers up to 100 with the Sieve of Eratosthenes
max = 100
# A very basic HTTP server
require "http/server"

sieve = Array.new(max + 1, true)
sieve[0] = false
sieve[1] = false

(2...max).each do |i|
if sieve[i]
(2 * i).step(max, i) do |j|
sieve[j] = false
end
end
server = HTTP::Server.new(8080) do |request|
HTTP::Response.ok "text/plain", "Hello world!"
end

sieve.each_with_index do |prime, number|
puts number if prime
end
puts "Listening on http://0.0.0.0:8080"
server.listen
{% endhighlight %}

0 comments on commit dfb409b

Please sign in to comment.