Jump to content




Question regarding code reuse



  • You cannot reply to this topic
6 replies to this topic

#1 PSanf420

  • Members
  • 10 posts

Posted 15 May 2013 - 05: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.

#2 tom2018

  • Members
  • 135 posts

Posted 15 May 2013 - 06: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)

#3 PSanf420

  • Members
  • 10 posts

Posted 15 May 2013 - 06:25 PM

View Posttom2018, on 15 May 2013 - 06:12 PM, said:

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.

#4 tom2018

  • Members
  • 135 posts

Posted 15 May 2013 - 06:30 PM

View PostPSanf420, on 15 May 2013 - 06:25 PM, said:

View Posttom2018, on 15 May 2013 - 06:12 PM, said:

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.

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 15 May 2013 - 06: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.

#6 PSanf420

  • Members
  • 10 posts

Posted 15 May 2013 - 06:57 PM

View PostLyqyd, on 15 May 2013 - 06:50 PM, said:

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.

#7 tom2018

  • Members
  • 135 posts

Posted 15 May 2013 - 07:36 PM

View PostLyqyd, on 15 May 2013 - 06:50 PM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users