SlevenBits

All the bits you need.

Recipe: argparse with Jython 2.5.1

To quickly install the new argparse module into Jython 2.5.1, cd into the folder where jython2.5.1 is and run something like this:

wget http://peak.telecommunity.com/dist/ez_setup.py
jython ez_setup.py
jython2.5.1/bin/easy_install argparse

Tested on Mac OS X.

Hexahexacontadecimal

Just as Babylonians wisely counted in sexagesimal, the wise web developer is naturally drawn to hexahexacontadecimal. With an alphabet consisting of all unreserved URL characters:

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~

we get a radix of 66, the densest possible way to express a number in a URL. In hexahexacontadecimal the unsightly number 302 231 454 903 657 293 676 544 turns into the sleek i FsG UkO .0t sxw. Behold, the pinnacle of URL numeral systems.

def hexahexacontadecimal_encode_int(n):
  """Represent a number in hexahexacontadecimal."""
  alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~"
  if n == 0:
    return alphabet[0]
  r = StringIO()
  while n > 0:
    n, t = divmod(n, 66)
    r.write(alphabet[t])
  return r.getvalue()[::-1]

(You could have called this base66 or base 66 but why would you?)

  • Contact

    We are currently available for contract work. Reach out through our Contact page.

    Email: contact@slevenbits... (guess the rest)

  • What can we do for you?

    Desktop Software

    Partial or in full. For Windows or Mac OS X. Anything from a little widget to a full fledged database driven multi-platform solution.

    Web Applications

    Need a simple blog or a plugin to your CMS? Or do you have the latest and greatest social-location-video site in the pipe? We can do.

    Graphics

    Sometimes design and development are closely tied together. You might want a pixel perfect interface and the accompanying user experience.

    Backend Utilities

    If you're scripting up your batch processing system in Python, or need some graphs generated on demand, no problem.

  • About the Owner

    Photo of the owner.

    Name: Alexander Ljungberg

    Twitter: slevenbits

    GitHub: aljungberg

    Stack Overflow: alexander-ljungberg