Available software

As multicore processing and distributed systems are currently hot topics, many researchers and technologists are turning their attention to programming language and systems support for concurrency and parallelism. Tony Hoare's Communicating Sequential Processes (CSP) is one of many formal models of computing that is specifically designed to model communication between concurrent, parallel or distributed parts of a program. In particular, CSP disallows shared memory and provides facilities for synchronous communication between (CSP) processes. This eliminates certain types of error (such as race conditions) and encourages a very elegant programming style. This style fits well with a number of common problems in concurrent, parallel and distributed systems.

python-csp is designed to be simple to use. Any callable object with the @process decorator will be run in a sepatate process and can communicate via message-passing with other procesess. No shared memory means no worrying about locks, no race hazards and fewer deadlocks. The example below shows a simple producer / consumer program which estimates the value of π using a monte-carlo method.

from csp.csp import *
from math import sqrt
from decimal import Decimal

@process
def worker(channel, iter): # Worker process
    count = 0
    i = 0
    while i < iter:
        x, y = random.random(), random.random()
        if y<= sqrt(1 - (x * x)):
            count += 1
        i += 1
    channel.write((Decimal(count))) # Write down the IPC channel
    return       

@process
def consumer(cins): # Farmer process
    alt = Alt(*cins)
    total = Decimal(0)
    for i in range(len(cins)):
        total += alt.select() # Read a value from the next available IPC channel
    print("Pi aproximation: " + str(Decimal((total / (iter * workers)) * 4)))
        
def main(num_workers, num_iterations):
    channels, procs = [],[]
    for i in range(num_workers):     # Create worker processes
        channels.append(Channel())   # Create a channel for IPC
        procs.append(worker(channels[i]), num_iterations)
    procs.append(consumer(channels)) # Create farmer process
    p = Par(*procs)                  # Run all processes in parallel
    p.start()
    return 

if __name__ == '__main__':
    main(320, 10000)

Read more... python-csp website

I maintain a LaTeX template for the University of Wolverhampton PhD thesis style here. Although the template is for our thesis style specifically, it shouldn't be difficult to customise it for other universities. My template is based on the excellent Monash metathesis written by Donald Craig.

pytoradex is a set of Python wrappers around the Oak series of sensors made by Toradex.

Supported devices

The following devices have Python wrappers with the following class names:

  • Current sensor: ToradexCurrent
  • MagR sensor: ToradexMagR
  • Motion sensor: ToradexMotion
  • Distance sensor: ToradexDist
  • Tilt sensor: ToradexTilt
  • Light sensor: ToradexLux
  • Accelerometer: ToradexG
  • Temperature and humidity sensor: ToradexRH
  • Pressure sensor: ToradexP
  • 8 channel A2D convertor: Toradex8ChannelA2D

Usage

To use one of the sensors wrapped in pytoradex, first create a Python object which corresponds to the sensor you have attached to your USB bus, then open the sensor, then call the relevant get_ method for whatever reading you want to take from the sensor. For example, with an Oak Lux sensor we might want to take an average of one hundred readings:

from pytoradex.toradex import ToradexLux
import time

numreadings = 100
lux = ToradexLux()
try:
    lux.open()

    # Turn the LED on to indicate a change of state.
    lux.led_on()
    readings = [lux.get_lux() for i in xrange(numreadings)]
    lux.led_off()
    lux.close()

    print 'Average light level: {0}'.format(sum(readings)/numreadings)

except:
    print 'Cannot open Oak Lux sensor. Please check USB cables.'
          

If you are debugging your own code you may find it useful to print out all the date coming from the sensor to the command line. You can use our debug utilities to do this:

from pytoradex.toradex import ToradexG

accel = ToradexG()
accel.open()
accel.blink_led()
while True:
    print(accel.debug())

If you have a bunch of Oak sensors connected to the USB bus, rather than creating a Python object for each one, you can use the ToradexSensorCollection class to open several devices at once:

import time
from pytoradex.toradex import ToradexSensorCollection

collection = ToradexSensorCollection()
print(collection.open())
while True:
    collection.debug() # Will print output of each sensor in turn.
    time.sleep(1)

For more details, see the README.

Ocaml-template is a simple template for new Ocaml projects. The template expects code should be structured roughly like this:

project/
Makefile
README
ChangeLog
...
src/
   program.ml
   interface.mli
   ...
tests/
   ...
          
The Makefile has a variable program which needs to be changed to the name of the executable file which will be produced on compilation. The Makefile will build documentation, byte-code interpreted OCaml or native binaries.

This gedit3 plugin adds support for Scala programmers. It has the following features:

  • Adds a new Scala menu with compile current document, compile all Scala files in a directory, run and restart fsc options
  • Automatically compiles files in the background every time you save.
  • Highlights compiler errors and warnings in the source.
  • Captures compiler / scala output in the "bottom panel" of Gedit (you have to turn that on in the View menu). Clicking on an error or warning scrolls you up to the line number the problem occurred on.
  • SCALA_HOME can be configured from Edit->Preferences->Plugins->flyscala->Preferences on the top-level Gedit menu.

Installation

Download and run the installer script on the command line like this:

$ wget https://raw.github.com/snim2/gedit-scala-plugin/master/install.sh
$ chmod +x install.sh
$ ./install.sh
This will install both the official Scala syntax highlighter for Scala and the plugin.

posterous.el is an emacs

mode use for posting to a Posterous blog directly from an emacs buffer.

Place the .el file somewhere on you load path (e.g. ~/.emacs.d/) and set the following variables in your .emacs or init.el file:

posterous-email    -- your email address or username on posterous.com
posterous-password -- your password on posterous.com
and you can interact with posterous.com using the functions:
M-x posterous-getsites
Creates a new buffer containing an xml-formatted list of sites that you own on posterous.com.
M-x posterous-region
post a region of text to posterous
M-x posterous-region-private
post a region of text to posterous as a private post.
M-x posterous-buffer
post a buffer of text to posterous.
M-x posterous-buffer-private
post a buffer of text to posterous as a private post.
If you do not wish to post to your default posterous site, you can customise the variable posterous-default-siteid. To find the siteids of all your sites, use M-x posterous-getsites. If you do not wish to autopost to your social networks connected to your posterous.com account, place the following in your Emacs configuration file:
(setq posterous-suppress-autopost)

tautology-checker is a simple tautology checker, written in Java, as a teaching tool.

It uses an operator-precendence parser (sometimes called a Pratt parser) to parse a file containing a proposition and print out a trace which contains the syntax tree of the original proposition, its negative normal form, conjunctive normal form and whether or not the proposition is a tautology.

The language parse by the checker is the following:

Prop ::= FF
       | TT
       | NOT Prop
       | Prop AND Prop
       | Prop OR Prop
       | Prop => Prop
       | Prop AND Prop
       | ( Prop )
There are a number of examples in the tests/ directory and a UNIX shell script check.sh which takes a file name and calls the checker. For example:
$ javac checker/Checker.java 
$ java checker.Checker tests/peirces_law.prop 

	 A Tautology Checker for Propositional Calculus
	------------------------------------------------

Input file: tests/peirces_law.prop
----------
((P => Q)=>P)=>P



Abstract syntax tree:
--------------------
((P => Q) => P) => P

RESULT OF formula.removeImplications():
--------------------------------------
(!(!(!P \/ Q) \/ P) \/ P)

RESULT OF formula.toNnf():
-------------------------
(((!P \/ Q) /\ !P) \/ P)

RESULT OF formula.nnfToCnf():
----------------------------
(((!P \/ Q) \/ P) /\ (!P \/ P))

RESULT OF formula.simplifyCnf():
-------------------------------
TRUE

Your formula is a tautology.

$