This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
PSanf420's profile picture

Question regarding code reuse

Started by PSanf420, 15 May 2013 - 04:57 PM
PSanf420 #1
Posted 15 May 2013 - 06:57 PM
I am considering the possibility of writing a program to manage the publishing of CC files to Pastebin. Something like a "makefile" program for CraftOS that would make it very easy to publish programs to Pastebin, and make them easy to retieve. Now, I see that the pastebin program included with CC uses an API key to interact with pastebin. I'd like to copy/reuse/alter the pastebin program to turn it into an Lua usable API (why reinvent the wheel?) that my program can use to interact with pastebin. Is copying the API key a big no-no, or are people encouraged to use that key becuase it's the one ComputerCraft applications are known to use? Should I see about getting my own API key for this project? If so, what kind of trouble could I get into for publishing the API key so other people can use the program?

What I'm thinking about doing is creating a program that will use a text file to specify which files should be published to pastebin as part of a program. The program would publish the files onto pastebin, getting a code back for each one which tells us how to retireve them. The program would then use this information to generate a "download" script that would be used to download all the files. The script would then upload the generated file, and output *it's* code to the user. The user could then tell a friend to use a pastebin program to download the generated file for their program. Once that's done, they'd run the file and it would take care of downloading all the files needed for the program.

I'm sure similar things have been done, but I haven't seen any implementations. If you are aware of any I would appreciate a link! :-D I know the cc-get program is available, but I'd like something that works directly with pastebin. I'm thinking a program like this would make it vastly easier to share CraftOS data in a direct manner.
tom2018 #2
Posted 15 May 2013 - 07:12 PM
This topic does not belong here but.

pastebget=function(code, saveloc)
  url = "http://pastebin.com/raw.php?i="..code
  t = http.get(url)
  h = fs.open(saveloc,"w")
  c = 1
  n = #t + 1
   while c < n do
   h.write(t[c])
   c = c + 1
  end
  h.close()
end
should work

These will help.
http://pastebin.com/api
http://computercraft...wiki/HTTP_(API)
PSanf420 #3
Posted 15 May 2013 - 07:25 PM
This topic does not belong here but.

pastebget=function(code, saveloc)
  url = "http://pastebin.com/raw.php?i="..code
  t = http.get(url)
  h = fs.open(saveloc,"w")
  c = 1
  n = #t + 1
   while c < n do
   h.write(t[c])
   c = c + 1
  end
  h.close()
end
should work

These will help.
http://pastebin.com/api
http://computercraft...wiki/HTTP_(API)

Where would be a more appropriate place for this post? Is it possible for me to move it?

That function does look handy. After looking at the Pastebin API it appears that there could be more functionality put into this type of a program. The ability to have a user log in, list their pastes, and delete them means I could create a pastebin browser/cloud storage type deal.
tom2018 #4
Posted 15 May 2013 - 07:30 PM
This topic does not belong here but.

pastebget=function(code, saveloc)
  url = "http://pastebin.com/raw.php?i="..code
  t = http.get(url)
  h = fs.open(saveloc,"w")
  c = 1
  n = #t + 1
   while c < n do
   h.write(t[c])
   c = c + 1
  end
  h.close()
end
should work

These will help.
http://pastebin.com/api
http://computercraft...wiki/HTTP_(API)

Where would be a more appropriate place for this post? Is it possible for me to move it?

That function does look handy.
1.Ask a pro (just report it and ask to be moved)
2.Your welcome; I'm happy to help.
Lyqyd #5
Posted 15 May 2013 - 07:50 PM
If you think a topic is in the wrong place, report it. Unless you're a moderator, there's no need to post about it being in the wrong place.

Moved to Ask a Pro.
PSanf420 #6
Posted 15 May 2013 - 07:57 PM
If you think a topic is in the wrong place, report it. Unless you're a moderator, there's no need to post about it being in the wrong place.

Moved to Ask a Pro.

Thanks.
tom2018 #7
Posted 15 May 2013 - 08:36 PM
If you think a topic is in the wrong place, report it. Unless you're a moderator, there's no need to post about it being in the wrong place.

Moved to Ask a Pro.
I did but seeing that he was new to the forums I was just giving him advice sorry.