Want more features on Pastebin? Sign Up, it's FREE!

Numerology

By: vivex42 on Dec 10th, 2013  |  syntax: Ruby  |  size: 1.68 KB  |  views: 86  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #use warnings;
  2.  
  3. #use strict;
  4.  
  5. #use HTTP::Server::Simple;
  6. #my $server = HTTP::Server::Simple->new();
  7. #$server->run();
  8.  
  9.  
  10.  
  11. require 'sinatra'
  12.  
  13.  
  14. =begin
  15.  
  16. $accumulator=0
  17.  
  18. #words=IO.readlines("numerology_chase.txt")
  19.  
  20. words=open("code.txt",&:read).split("")
  21.  
  22. #File.open("numerology_chase.txt").each_line do |line|
  23.  
  24. for i in words
  25. $accumulator += i.to_i
  26. end
  27.  
  28. accumulator_data = $accumulator.to_s
  29.  
  30.  
  31. numerology=accumulator_data.split("")
  32. $i=0
  33. for i in numerology
  34.         $i+=i.to_i
  35. end
  36.  
  37. puts "And the number is: #{$i}"
  38.  
  39. =end
  40.  
  41.        
  42.  
  43.        
  44.  
  45.  
  46. #$a.extend(numerology)
  47.  
  48.  
  49. before do
  50.         content_type :text
  51.         require 'mechanize'    
  52. end
  53.  
  54.  
  55. def numerology(url)
  56.                 agent=Mechanize.new
  57.                 read = agent.get(url)
  58.                 save_as = read.save_as("webpage_#{Random.rand(0..(10**100+10*100)).to_s}_.html")               
  59.                 return save_as                 
  60. end
  61.  
  62. #$page_counter=0
  63. get '/url_num/*' do
  64.        
  65.        
  66.        
  67.         a=numerology("#{params[:splat].shift}".sub!(/\//,'//'))
  68.        
  69.         file_name=a
  70.        
  71.  
  72.         $accumulator=0
  73.  
  74.         #words=IO.readlines("numerology_chase.txt")
  75.  
  76.         words=open("#{file_name}",&:read).split("")
  77.  
  78.         #File.open("numerology_chase.txt").each_line do |line|
  79.  
  80.         for i in words
  81.                 $accumulator += i.to_i
  82.         end
  83.  
  84.         accumulator_data = $accumulator.to_s
  85.  
  86.  
  87.         numerology=accumulator_data.split("")
  88.         $i=0
  89.         for i in numerology
  90.                 $i+=i.to_i
  91.         end
  92.  
  93.         "And the number is: #{$i}"
  94.        
  95.         #numerology_proc=$agent.get("#{params[:splat]}")
  96.         #"You passed in #{numerology_proc.inner_html}"
  97. end
  98. =begin
  99. set :views, File.dirname(__FILE__) + '/public' #set views to ./html (current directory/html)
  100. def load_pictures
  101.         Dir.glob("#{File.dirname(__FILE__)}/*.{jpg,JPG,gif,GIF,PNG}")
  102. end
  103.  
  104. get '/' do
  105.        
  106.         @pictures = load_pictures
  107.        
  108.         erb :index
  109. end
  110. =end
clone this paste RAW Paste Data