Jump to content


mrpoopy345's Content

There have been 16 items by mrpoopy345 (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#250808 PHP HTTP

Posted by mrpoopy345 on 23 April 2016 - 08:08 PM in Ask a Pro

View PostTYKUHN2, on 22 April 2016 - 06:45 PM, said:

I'd start by looking at what your browser sends when you login. Chances are it is encrypted, but judging how it isn't SSL, probably not impossible. Your ComputerCraft computer just needs to mimic what your browser sends. I have a program I can use to look at the connection and I'll get back with a packet of it.

EDIT:
Not sure what path is but these cookies are important! Keep track of them!
PHPSESSID=estl7aiml19dc3ib4ij1s97q87; path=/
Also yes I do know I "leaked" personal information except the fact I don't own an account associated with the session.

And of course: Less secure than expected. I logged in with username "test" and password "tester" and this was sent. Capitalization may be different.
log_username=test&log_password=tester

It is inside a POST not a GET

Sorry for the noobish question, but how exactly do you inspect what your browser sends when you login? Can I do it without third party software?



#223511 <eof> expected

Posted by mrpoopy345 on 27 June 2015 - 04:25 PM in Ask a Pro

The reason it is giving you that error is because I accidentally didn't post the whole code, sorry. Could you tell me where you removed that missing end later in the file?

EDIT: Got it, thanks for the help!



#223505 <eof> expected

Posted by mrpoopy345 on 27 June 2015 - 03:55 PM in Ask a Pro

I am trying to build a koth style bot competition. At the beginning of my run function, I have all the ways the bots can win/lose. After adding a new elseif statement, I get the error 70:<eof> expected near end. I know this means too many ends (Or code after a loop break, but I have no "break" in that function) but whenever I remove an end it says end expected. My source code (I doubt you will need all of it, mainly just look at the run function)
http://pastebin.com/JaQLVRWZ



#222877 Can this program be golfed any more?

Posted by mrpoopy345 on 23 June 2015 - 04:38 PM in Ask a Pro

Returns the correct string, but also returns an extra int. I'm pretty sure that isn't allowed



#222871 Can this program be golfed any more?

Posted by mrpoopy345 on 23 June 2015 - 04:10 PM in Ask a Pro

On the stackexchange code golf website there was a topic called "stretching words" and here is the basic concept:
Write a program or function that duplicates letters in a word, so that all the duplicated letters arranged in order would form the input array.

For example:

Input: abcdefghi, abc
Output: aabbccdefghi

Here is my shot at it in lua (76 bytes):
function f(x,y)for i=1,#x do g=y:sub(i,i);x=x:gsub(g,g..g,1)end print(x)end
My question is, can this code be golfed down anymore/is there a different way to approach this that is shorter?
Thanks!



#220395 Timing a function?

Posted by mrpoopy345 on 08 June 2015 - 05:17 PM in Ask a Pro

This might be off topic, as I know how to do this in computercraft but my question is about vanilla lua. I have a function and I want to see how long it takes to execute (To the millisecond)
This is my current code:
function Test_Function()
    for i = 1, 100 do
        local s = math.log( i )
        s = math.sqrt( s )
    end
end

t1 = os.clock()
    Test_Function()
t2 = os.clock()

print( os.difftime(t2, t1) )
However this is returning the amount of seconds it takes, not the amount of milliseconds. Is there a way to measure how long a function takes to executes to the millisecond in vanilla lua?



#219630 Graphical Rednet Network

Posted by mrpoopy345 on 01 June 2015 - 10:11 PM in General

Learn lua! If you come to this forum wanting someone else to do the work for you, as the famous Hank Green would say, "ur doin it wrong". Study up on lua and computercrafts api, its not that hard!



#219629 function X

Posted by mrpoopy345 on 01 June 2015 - 10:10 PM in Ask a Pro

Lua will not take into account functions that you have not declared yet in your code.
You must tell the code what test() is before you use it.
By the way, are you trying to make x a function or what test returns? If you are trying to make x what test returns than use this code:
function test()
--Code here
end
local x = test()
if x == nil then
os.reboot()
else
test()
end



#219549 Loadfile error checking not working?

Posted by mrpoopy345 on 01 June 2015 - 10:55 AM in Ask a Pro

@Valithor It worked! Thank you so much! Follow up quesiton, can you ever have a seed that makes it take more than 2 steps to get to an error quine?



#219546 Loadfile error checking not working?

Posted by mrpoopy345 on 01 June 2015 - 10:32 AM in Ask a Pro

If the seed is, say "abcdefghijklmnopqrstuvwxyz" It will go "newgolf.lua:syntax error near <eof>" which then compiles and gives the error "newgolf.lua:1: <name> expected near '1'"

Valithor, I am testing what you said right now, I'll edit my post when I have tried it.



#219477 Loadfile error checking not working?

Posted by mrpoopy345 on 31 May 2015 - 06:53 PM in Ask a Pro

I am trying to make a program that makes an error quine using the following algorithm:

Start out with a seed (A piece of code that errors)
Take the error the code produces and make that error the new program (Done with a remote program)
Continue step 2 until the source code of the program = the error it produces

This is my code in the main program (This is in golf.lua and the program the seed is in is newgolf.lua, I know the name of the programs are weird, they were just empty lua files I had)
r = 0
s = "newgolf.lua"
while true do
h = io.open(s, "r")
l = h:read("*all")
h.close()
tempfunc, errmsg = loadfile(s)
if errmsg == l then
	print(r)
	break
else
	r = r+1
	h = io.open(s, "w")
	h:write(errmsg)
	h:close()
	print(r..": "..errmsg)
end
end
If I make the seed in newgolf.lua something like oi;gzsjgd or anything where I just bang my head against my keyboard it works as expected, however if I put valid "looking" lua code that actually errors (Something like printfunction({}) ) it says that errmsg is nil even though tempfunc would error. Why is this, and how can I fix it?



#218942 Random number generation

Posted by mrpoopy345 on 27 May 2015 - 10:25 PM in Ask a Pro

Then there must be something wrong with my lua installation or code, because:
numofheads = 0
k= 1000
for i = 1, k do
	math.randomseed(os.time())
	l = math.random(1, 2)
    if l == 1 then
    	numofheads = numofheads+1
    end
end
print(numofheads)
Always returns 0 or 1000. Is there a reason for this?

EDIT: Ah, I see the problem. I have to set the randomseed before the loop. Thanks for the clarification.



#218938 Random number generation

Posted by mrpoopy345 on 27 May 2015 - 09:51 PM in Ask a Pro

In vanilla lua, before generating a random number you have to use math.randomseed(os.time()) In order to stop from generating the same random number over and over again. The main problem with this is that if you are generating 50 random numbers in a row in say a for loop, they will all be the same because in the time it takes to generate all of them os.time() does not change. However, in computercraft, if you do something like
for i=1, 50 do
print(math.random(1,2))
end
All the random number will be different, which is not the case in regular lua, as I explained. How does computercraft achieve this? I looked through the source and could not find any redefinition of math.random (At least in the lua section) yet it seems to work differently. How is this achieved, and how can I do it in vanilla lua?


P.S. We have a stackexchange tag now :D



#216927 Move Your Feet video in ComputerCraft - Visual Demo 2 (DemoScene)

Posted by mrpoopy345 on 12 May 2015 - 10:39 AM in Media

So theoretically you could do this with any music video, no matter how pixelated?



#216331 Why is this code erasing the file?

Posted by mrpoopy345 on 05 May 2015 - 09:39 PM in Ask a Pro

I am trying to make a golfing language in lua (Stupid, I know, but fun) and this is the code for my compiler:
tbl = {}
h = fs.open("testfile", "r")
r = h.readLine()
while r do
if string.find(r, "if ") then
 table.insert(tbl, r.." then")
 ify = 1
else
 if ify == 1 then
  if string.sub(r, 1, 1) ~= " " then
   table.insert(tbl, table.getn(tbl)+1, "end")
   ify = 0
  else
   table.insert(tbl, r)
  end
end
end
r = h.readLine()
end
h.close()
h = fs.open("testfile", "w")
for k,v in pairs(tbl) do
 h.writeLine(v)
 print(v)
end
And what this code is supposed to do is turn this:
if 2 == 2
 print("Yes")
into this:
if 2 == 2 then
 print("Yes")
end
But for some reason it just wipes the file and there becomes nothing in tbl. Why is this?



#215980 Problem comparing numbers?

Posted by mrpoopy345 on 01 May 2015 - 10:50 AM in Ask a Pro

I am writing a code to test if the area of a circle is (circumfrence/2)*radius. My code is:
pi = 3.1415926535
for i = 1, 200 do
area = (i^2)*pi
circ = (i*2)*pi
if area == (circ/2)*i then
 print("Worked")
else
    print(area..": "..(circ/2)*i)
end
end
But this produces a weird result, as shown here:
http://gyazo.com/4d7...6f8eb804cdbf1bc

Most of them work, but some say they don't work, even though clearly (circ/2)*pi is the same as area.
What is wrong with this code?