I am happy to announce the availability of as3dribbble, an ActionScript client library for working with Dribbble.com APIs. The library is strongly-typed, pagination-aware, and rate-limit aware for accessing all the current APIs. The library also exposes a convenience class called DribbbleInvoker that may be used to add more APIs (should they get added in future and this library looses track). The invoker is rate-limit safe.

Usage

A simple example to use is as under,

private function getShotDetails():void {
    var client:DribbbleClient = new DribbbleClient();

    // the requestID can then be used to check which request failed
    var requestID:uint = client.getShot(12, showShot, errorHandler);
}

private function showShot(shot:Shot):void {
    trace('received shot details: ' + shot);
}

private function errorHandler(id:uint):void {
    // error occured when fetching shot details
}

Pagination Support

All API methods that support pagination have a corresponding, pagination-aware method available as well. For example, when fetching comments for a shot you may do,

var client:DribbbleClient = new DribbbleClient();

private function getShotComments():void {
    var requestID:uint = client.getShotComments(123, showComments, errorHandler);
}

private function showComments(list:CommentList):void {
    // do something with these comments

    var requestID:uint;

    // check for more comments
    if(list.getPage() < list.getPages()) {
        // fetch results from page 2
        requestID = client.getShotComments(1, showComments, errorHandler, 2);

        // or, may provide the number of results to fetch as well
        // fetch results from page 2, with 15 results per page
        requestID = getShotComments(1, showComments, errorHandler, 2, 15);
    }
}
The current default for number of results per page is 15 per Dribbble API. Refer http://dribbble.com/api for more details.

Rate-Limiting and Exceptions

By default, the DribbbleClient will throw a DribbbleApiRateLimitException run-time error when the request rate goes over the board. This makes sure that your client does not need to catch unnecessary exceptions during invocation. In case you wish, you may catch this exception and delay the request to a future time as,
private function getShot():void {
    var shot:Shot = null;
    var shotID:uint = 1;

    try {
        var requestID:uint = client.getShot(shotID, showShot, errorHandler);
    } catch(e:DribbbleApiRateLimitException) {
        // wait for a minute
        setTimeOut(getShot, 1000 * 60); // call again after a minute
    }
}
If you wish to prevent the code from throwing the DribbbleApiRateLimitException exception, you can do so when creating the client.
var client:DribbbleClient = new DribbbleClient(false);
Any invocations on this client, will not throw the error, but return a null back as the result to the completion handler you specified.

Dependencies

The library does not depend on any third-party libraries and is self-contained. The library has been compiled and tested using Adobe Flex 4.6/Adobe AIR 3.0.

Project Links

More details on the project can be found on project home page, http://www.sangupta.com/projects/as3dribbble.
Source Code: https://github.com/sangupta/as3dribbble
Downloads: https://github.com/sangupta/as3dribbble/downloads
Issue Management: https://github.com/sangupta/as3dribbble/issues
Usage Instructions: https://github.com/sangupta/as3dribbble/blob/master/README.md

Keep Dribbbling!

written by Sandeep Gupta

Saturday, April 28, 2012 at 1:12 PM

I am happy to introduce PepMint, a JAVA wrapper over the awesome Python's Pygments code syntax highlighting library. With Pepmint you can easily syntax highlight your own piece of snippet using code. This essentially helps us to build tools that consume code and output HTML - blog engines, presentation tools, documentation generators etc.

Usage

Super-easy way to use the library is described in the example below,

public String highlight(String code, String language) {
    Pepmint pepmint = null;
    Lexer lexer = pepmint.newLexer(format);
    Formatter formatter = pepmint.newHtmlFormatter(formatterParams);

    String formattedCode = pepmint.highlight(code, lexer, formatter);
    return formattedCode;
}

Dependencies

The library is self-contained and does not depend on any third-party library. It is built using,
  • Java 1.6
  • Jython 2.5.6
  • Pygments 1.4

Project Links

More details on the project can be found on project home page, http://www.sangupta.com/projects/pemint.
Source Code: https://github.com/sangupta/pepmint
Downloads: https://github.com/sangupta/pepmint/downloads
Issue Management: https://github.com/sangupta/pepmint/issues
Usage Instructions: https://github.com/sangupta/pepmint/blob/master/README.md

Have Fun Highlighting!

written by Sandeep Gupta

Monday, April 23, 2012 at 3:27 PM

I am happy to finish and open-source a strongly-typed, rate-limited Java Client library for Dribbble called dribbble-java-client.

dribbble-java-client is a strongly typed Java library for accessing http://dribbble.com API. The library provides support for rate limiting requests. All objects implement the necessary equals, hashcode and toString methods for easier usage. Also, implemented is the Comparable interface for comparison and sorting.

The library also exposes a convenience class called DribbbleInvoker that may be used to add more APIs (should they get added in future and this library looses track). The invoker is rate-limit safe.

Usage

DribbbleClient client = new DribbbleClient();

// get info on shot with ID: 1
Shot shot = client.getShot(1);

// get info on this shot's player
Player player = client.getPlayer(shot.getPlayer().getId());

// do more...

Pagination Support

All API methods that support pagination have a corresponding, pagination-aware method available as well. For example, when fetching comments for a shot you may do,

DribbbleClient client = new DribbbleClient();

CommentList list = getShotComments(1);

// do something with these comments

if(list.getPage() < list.getPages()) {
    list = getShotComments(1, 2); // to get default page 2

    // or, may provide the number of results to fetch as well
    list = getShotComments(1, 2, 15);
}

// get more comments

The current default for number of results per page is 15 per Dribbble API. Refer http://dribbble.com/api for more details.


Project Links

More details on the project can be found on project home page, http://www.sangupta.com/projects/dribbble-java-client.
Source Code: https://github.com/sangupta/dribbble-java-client
Downloads: https://github.com/sangupta/dribbble-java-client/downloads
Issue Management: https://github.com/sangupta/dribbble-java-client/issues
Usage Instructions: https://github.com/sangupta/dribbble-java-client/blob/master/README.md

Hope this helps.

written by Sandeep Gupta

Wednesday, April 18, 2012 at 2:35 PM