Computing.Net > Forums > Programming > Speeding up a script i use

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Speeding up a script i use

Reply to Message Icon

Name: drew1302
Date: October 17, 2008 at 20:35:02 Pacific
OS: vista 32bit
CPU/Ram: 1.9GHz/1014mb ram
Comment:

require 'open-uri'

#email/encrypted password#
$user_email = "EMAIL HERE"
$user_password = "PASSWORD HERE"

class SocketAAA
attr_accessor :url, :user_agent, :uri, :exit_conditions, :wait_conditions, :file

def initialize(email, password, file, uri)
@user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
@uri, @wait_conditions, @exit_conditions = uri, [], []
@url = "http://a3.alienaa.com/cgi-bin/%s?&email=%s&pass=%s" % [file, email, password]
end

# expects the source of the page as an argument (page.read etc)
def check_conditions(page)
gets and exit if @exit_conditions.detect {|e| page[/#{e}/i]}
emulate_human_response(5) if @wait_conditions.detect {|e| page[/#{e}/i]}
end

# connects to the site with a block and makes the page open-uri
def connect
open(@url + @uri, "Referer" => @url, "User-Agent" => @user_agent) do |page|
yield page if block_given?
end
end

# simulates human response time
def emulate_human_response(time_to_wait = 0.00002)
sleep(rand(0.00005) + rand(time_to_wait))
end
end

# replace "socket.emulate_human_response" with
def easy_sock(uri, file = "view.fcgi", email = $user_email, password = $user_password)
socket = SocketAAA.new(email, password, file, uri)
socket.wait_conditions.push("throttle")
socket.exit_conditions.push("important message", "banned from logging into", "georgetown jail", "no cookies", "getting overwhelmed", "fished out", "out of dough")
socket.connect do |page|
$source = page.read
socket.check_conditions($source)
end
#socket.emulate_human_response
end

$source = ""

easy_sock("&step=pit&do=2&lvl=13")
#easy_sock("&step=pit&showmap=1")


prev_dir = " "
directions = ["w", "n", "e", "s"]
loop do
puts prev_dir
easy_sock("&step=pit&do=2&lvl=13")
if (/&step=pit&leave=1/ =~ $source && prev_dir != "left")
easy_sock("&step=pit&leave=1")
puts "entered!"
prev_dir = "left"
next
elsif (/&step=pit&next=1/ =~ $source)
easy_sock("&step=pit&next=1")
next
end

if (prev_dir == "left")
prev_dir = " "
end

# Check to see for a mine, then mine it
if (/&step=pit&mine1=1/ =~ $source)
easy_sock("&step=pit&mine1=1")
puts "Mined!"
next
end

# Sets it up to get moving!
if (prev_dir == " ")
if (/&step=pit&go=s>/ =~ $source)
easy_sock("&step=pit&go=s")
prev_dir = "s"
next
elsif (/&step=pit&go=w>/ =~ $source)
easy_sock("&step=pit&go=w")
prev_dir = "w"
next
elsif (/&step=pit&go=e>/ =~ $source)
easy_sock("&step=pit&go=e")
prev_dir = "e"
next
elsif (/&step=pit&go=n>/ =~ $source)
easy_sock("&step=pit&go=n")
prev_dir = "n"
next
end
end

if (prev_dir == "s")
unless (/&step=pit&go=w>/ =~ $source)
if (/&step=pit&go=s>/ =~ $source)
easy_sock("&step=pit&go=s")
prev_dir = "s"
next
elsif (/&step=pit&go=e>/ =~ $source)
easy_sock("&step=pit&go=e")
prev_dir = "e"
next
else
easy_sock("&step=pit&go=n")
prev_dir = "n"
next
end
else
easy_sock("&step=pit&go=w")
prev_dir = "w"
next
end
end

if (prev_dir == "w")
unless (/&step=pit&go=n>/ =~ $source)
if (/&step=pit&go=w>/ =~ $source)
easy_sock("&step=pit&go=w")
prev_dir = "w"
next
elsif (/&step=pit&go=s>/ =~ $source)
easy_sock("&step=pit&go=s")
prev_dir = "s"
next
else
easy_sock("&step=pit&go=e")
prev_dir = "e"
next
end
else
easy_sock("&step=pit&go=n")
prev_dir = "n"
next
end
end

if (prev_dir == "n")
unless (/&step=pit&go=e>/ =~ $source)
if (/&step=pit&go=n>/ =~ $source)
easy_sock("&step=pit&go=n")
prev_dir = "n"
next
elsif (/&step=pit&go=w>/ =~ $source)
easy_sock("&step=pit&go=w")
prev_dir = "w"
next
else
easy_sock("&step=pit&go=s")
prev_dir = "s"
next
end
else
easy_sock("&step=pit&go=e")
prev_dir = "e"
next
end
end

if (prev_dir == "e")
unless (/&step=pit&go=s>/ =~ $source)
if (/&step=pit&go=e>/ =~ $source)
easy_sock("&step=pit&go=e")
prev_dir = "e"
next
elsif (/&step=pit&go=n>/ =~ $source)
easy_sock("&step=pit&go=n")
prev_dir = "n"
next
else
easy_sock("&step=pit&go=w")
prev_dir = "w"
next
end
else
easy_sock("&step=pit&go=s")
prev_dir = "s"
next
end
end


end



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: October 20, 2008 at 20:07:19 Pacific
Reply:

Is this ruby?


0

Response Number 2
Name: drew1302
Date: October 22, 2008 at 08:08:54 Pacific
Reply:

yes its ruby i need help to speed it up because my friend uses the same one but he did something to it and it runs 5x the speed of mine's


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


batch change file modifie... VBScript to connect to SQ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Speeding up a script i use

I need help creating a script www.computing.net/answers/programming/i-need-help-creating-a-script-/16174.html

Ping Script www.computing.net/answers/programming/ping-script/15062.html

Find oldest file in folder www.computing.net/answers/programming/find-oldest-file-in-folder/14755.html