nimrod-pastebin

I’ve been working on more projects to help teach myself to program in Nimrod, and this is the result of one of them. It’s a Nimrod wrapper for the Pastebin API. Currently it  has the following functions:

  • createPaste() – creates a new paste.
  • createPasteFromFile() – creates a new paste from the contents of a file.
  • createAPIUserKey() – creates a user session key, for use with other functions.
  • listUserPastes() – lists a user’s pastes.
  • listTrendingPastes() – lists the top 18 trending pastes.
  • deletePaste() – deletes a paste.
  • getUserInfo() – gets information about a user.
  • getPaste() – gets the contents of a paste.
  • getPasteToFile() – gets the contents of a paste and writes it to a file.

There are two functions I haven’t yet finished (listTrendingPastes() and listUserPastes()), but that’s just because Nimrod’s XML parsing modules are missing some pretty important functionality, and I’ll add them as soon as I figure out a way around that limitation. (There’s no ability to get the value of a Node, for example.)

EDIT: Turns out the functionality is there, but there are two method for working with XML and the documentation isn’t the clearest thing in the world. Back to work…

EDIT2: And all done.

In addition to the functions, there are two other modules, one (pastebin_constants.nim) that contains constants for privacy values and expiration dates and another (pastebin_formats.nim) that contains constants for the formats used for syntax highlighting.

The code is on GitHub, but I haven’t quite finished the documentation yet.

Advertisements

extmath.nim

I’m still not quite certain what I want to do with the geology application, so I’ve put that on hold for now. In the meantime, I’ve started working on other things.

I while ago I discovered a programming language called Nimrod, and absolutely loved it. It’s syntax is very reminiscent of Python, but it’s also compiled and statically typed. To help teach myself this language, I started porting my JavaScript math library to Nimrod.

The result is (very creatively named) extmath.nim. The functions are almost exactly the same as in the original, with a few exceptions. First, as Nimrod is statically typed, you can’t pass any argument to a function; it has to be of the correct type. Because of this some of the functions are overloaded, with one for ints and another for floats. Second, the Complex class is missing, as Nimrod already has a better implementation. Third, some things (like reverseFactorial()) I simply can’t implement due to the lack of a float modulus operator.

Anyway, the code is all done, and is available on GitHub. The functions are all documented, but only in the code; I haven’t finished converting the rest of the documentation.