Newest sheets

Erlang-C Implementation

An implementation of Erlang-C for use in Call Centre environments and other Queueing situations

10 March 2011. Tagged with Call Centre, erlang-c

Find md5 hash of strings

'md5' is part of the Python standard library. In order to use it, first we need to import it. So I add this line to the pre-constants usercode (the blue part of the code editor towards the bottom of Resolver)::

from hashlib import md5

Looking at the md5 documentation:
http://docs.python.org/library/hashlib.html

I see that 'md5' isn't just a simple function that we can call. There are a few lines of code needed in order to use it. So I put these lines of code into a function to make it convenient to re-use (this also goes into the blue part of the code editor):

def getmd5(text):
m = md5()
m.update(text)
return m.digest()

Now we can use our new 'getmd5' function within the spreadsheet.

I add a column of test strings in column A, and then I add a formula to the whole of column B. Select Column B, and into the formula editor near the top of the window, enter the formula:

=getmd5(A_)

This says that each cell in column B should be the result of calling 'getmd5' with the value from the corresponding cell in column A.

This works, but the resulting md5s are displayed as a bunch of garbage unicode characters, eg:

ÂYbÚ�ím/Y’/¶Bª

In order to make the md5 human readable, I modify the call 'm.digest()' in getmd5, to read:

return m.hexdigest()

Now the md5 hashes in column B look like this:

1cb251ec0d568de6a929b520c4aed8d1

14 July 2010. Tagged with hash, md5

Make a TCP request on every recalc, decoding JSON in the response to update worksheet

In this example, Resolver acts as a TCP client, sending requests for data on every recalc. Recalcs have been set to automatically re-occur every second (note, this auto-recalc stops if you suspend recalcs using the toolbar button,
or if you are editing the code in the code pane.)

Unzip the attached to provide the following three files:

json-over-tcp.rsl - a Resolver document
test-server.py - a command line script to act as test TCP server
README.txt - this file

Open the .rsl document.

Outgoing TCP messages are produced on every recalc, by the function
'request()', in the pre-constants usercode.

These will currently give the following error:

couldnt connect to server
[Errno 10061] No connection could be made because the target machine actively refused it 127.0.0.1:9999

This is coming from the print in the request() function, The error is because nothing is listening to the port on which Resolver is asking for data.

Open a command-line window, and cd to the directory containing these files.

Enter the command:

python test-server.py

It should start a TCP server, and produce the message:

listening on localhost:9999

Now, whenever a Resolver recalc occurs, the function 'request' sends a message, consisting merely of the word 'get', sent to localhost 9999.

The responses, sent back by test-server.py, contain some JSON data, containing a list of (col, row, value) triples.

The JSON response is received by Resolver in 'request()', and printed to the output pane:

-------- Recalculation Started: 16:49:50 --------
response [
[4, 4, "marigold"],
[3, 4, "pot"],
]

This JSON is converted into Python data structures in the pre-formula user code, using the dirty hack:

data = eval(json) # this works because json is valid Python

The decoded data is then used by function 'display()' to display words and colors on the worksheet.

If you click on the grid (ie. not on the code pane) then recalcs will
automatically update the sheet with new values every second.

Alternatively, requests like this could be put into button handlers instead of on every recalc. This would be arguably easier, since button handlers are magically able to persistantly update cell values, using the Formula property,
so there would be no need to use a cache worksheet any more. But button handlers can't be set to trigger every X seconds like recalcs can.

27 May 2010. Tagged with external, JSON, network, request, response, tcp, tcpip, update

Listening for TCP messages containing JSON to update worksheet

Open the Resolver document. See how it contains usercode to create a new (cache) worksheet to recieve the incoming data. Switch to this sheet, if it isn't already the current.

More usercode uses the code in server.py to create a TCP server, listening for messages on localhost port 9999. You should see some diagnostic text in the output pane reading:

listening on localhost:9999... ok

(you might have to scroll up to see it)

Now, open a command-line window and cd to the directory of these files. Type the command:

python send-test-data.py < some-json.txt

This will send the JSON in the text file as a TCP message to localhost on port 9999.

The JSON message is recieved by the TCP server, which passes the message to the function 'handler' in the Resolver document usercode.

This function does a quick and dirty conversion of JSON into Python data, and uses that data to populate some cells in the cache worksheet.

If you click on the grid (ie. not on the code pane) then recalcs will
automatically update the sheet with new values every 2 seconds.

27 May 2010. Tagged with external, JSON, listen, tcp, tcpip, update

Newtonian Body Collider

My first Resolver One spreadsheet. It detects collisions between linear newtonian bodies with constant acceleration. You can see the position and velocity of the bodies at discrete time steps, and the time and position of collision (if there is one).

It can handle separating bodies as well as bodies with no acceleration.

I don't like the way the Python was written - I'd like to be able to pass data structures around rather than just parameters. I may experiment with classes or named data cells.

EDIT 1:
Re-wrote the body physics into classes, and you can now create bodies in any cell. Also added a Controller class which I used to prototype some PID throttle controllers, and the code to keep a moving body a set distance behind another moving body.
Feedback welcome.

02 March 2010. Tagged with collisions, newton, physics

QuantLib Example

This is one of the QuantLib Python examples converted to run in Resolver One. Instead of printing the results like the original example, this sheet puts the results in the grid.

See the notes in the spreadsheet for details about the conversion.

This example assumes that you have a working installation of QuantLib and the C# bindings. If you don't, you can download a binary distribution from the link below.

29 January 2010. Tagged with api, finance, quantlib, sample

Betfair connectivity from Resolver One: part I

A simple spreadsheet demonstrating connectivity to Betfair from Resolver One, downloading a list of all of the betting markets available. You'll need a Betfair account to use this spreadsheet (which unfortunately isn't possible from the US).

14 January 2010. Tagged with betfair, betting, wsdl

A Tweeting Spreadsheet

This Resolver One spreadsheet can update your twitter account, get your friend’s list or get the list of those who are following you.

31 December 2009. Tagged with JSON, REST, Twitter, xml

Charting stock prices in 3D using Resolver One, OpenGL and Tao

A spreadsheet that uses Yahoo! Finance to download the close prices over the last two years for every stock that's currently in the Dow Jones index, then charts them in a 3D window which you can pan and zoom using the mouse.

20 November 2009. Tagged with .NET, 3d, charting, dow, finance, IronPython, jones, opengl, stock, tao, yahoo

BioPython demo

This sample demonstrates the use of Python libraries with C-extensions (namely NumPy and BioPython) from Resolver One. Normally this is problematic, because IronPython, upon which Resolver One is based, cannot use such libraries. Since release 1.7, Resolver includes our open-source project IronClad, which makes Python libraries with C-extensions available to IronPython.

10 November 2009. Tagged with bio, bioinformatics, biopython, ironclad, molecules, numpy, protiens

<< Resolver Exchange