Android: Send SMS from Your Desktop

Annoyed by the fact that you have to use your Android’s tiny (on-screen) keyboard to type your text messages? I was. Until I found SmartDog’s Android Desktop app. I think it was called “A Web Desktop” or similar in the app store. It runs a web server that you can connect to from your desktop, and send and receive text messages, synchronise the clipboard, and upload/download files from to your phone. Very cool!

Edit: (2010-01-19) This application is now called “Remote Web Desktop”.

Posted in short | Tagged , , , | Comments Off on Android: Send SMS from Your Desktop

Merging Pdf Pages

What on Earth?

This post describes one method of merging the pages of two pdf documents. That is, creating an ouput file where page 1 of the output is the result of merging page 1 of each of the inputs, page 2 of the output is the result of merging page 2 of each of the inputs and so on.

The reason that I wanted to do this was so that I could combine the publishing capabilities of Scribus with the music notation of MuseScore (which seems pretty good to me, apart from a few minor UI annoyances and the fact that it crashes every now and then). Scribus wouldn’t import pdfs nicely, so I came up with this approach instead.

What You’ll Need

My solution to this problem is presented below as a python script. Before running the script, you will need to install pyPdf. On Linux, download and unzip the source, then run python setup.py install. You will of course also need Python installed.

How It’s Done

Create a new file called merge.py and paste the following code into it. I hereby release the following python code into the public domain.

!/usr/bin/python

from pyPdf import PdfFileWriter, PdfFileReader
import sys

def main(file1, file2, outfile):
    output = PdfFileWriter()
    input1 = PdfFileReader(file(file1, "rb"))
    input2 = PdfFileReader(file(file2, "rb"))

    p1 = len(input1.pages)
    p2 = len(input2.pages)

    for i in xrange(min(p1, p2)):
        print 'Merging page %d' % (i,)
        p = input1.getPage(i)
        p.mergePage(input2.getPage(i))
        output.addPage(p)

    if p1 > p2:
        inp = input1
    else:
        inp = input2

    for i in xrange(min(p1, p2), max(p1, p2)):
        print 'Adding page %d' % (i,)
        output.addPage(inp.getPage(i))

    output.write(file(outfile, 'wb'))

if __name__ == '__main__':
    main(*sys.argv[1:4])

Now to merge two pdf files, just type:
python merge.py input1.pdf input2.pdf output.pdf

Posted in midlength | Tagged , , , , | Comments Off on Merging Pdf Pages

Things I’ve Learnt: June 2010

Here’s my list of shareworthy things I’ve learnt recently, together with some links for further reading.

Posted in short | Tagged , , , , , , , | Comments Off on Things I’ve Learnt: June 2010

Piano Music: “For Mandie”

For the music lovers out there, here is the sheet music for my piano composition entitled For Mandie. It’s a good fun piece to play, and you don’t need to be a virtuoso to be able to play it.

Top of page 1 of "For Mandie" piano music

Preview of top of page 1 of "For Mandie"

Getting the Music

You can download the sheet music for this composition here: For Mandie Sheet Music (pdf)

This work is copyright and is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License by Joshua D. Bartlett.

At some point I may provide a recording. I have not uploaded a synthesised version as I despair of ever produced one I’m completely happy with. If you make a recording of the work, please let me know so that I can link to it.

Edit: (2012-02-05) I have made some corrections to the original original pdf I uploaded. The original pdf is still available here. Specific changes: mvt 1 bar 8, both Gs in left hand should have been Fs; mvt 1 bar 59, the second E in the left hand should have been a D; mvt 3 bar 23, replaced “con rubato” with “rubato”; mvt 4 bar 8, both Gs in left hand should have been Fs.

Piece History

I began work on this composition in 2005, starting from a chord progression given to me by my friend Mandie. Since that time I’ve played with a few parts of it, making adjustments here and there.

One of my aims in composing this piece was to have a good-sounding piano composition that even someone like me—I don’t play the piano anywhere near as often as I would like—would be able to play. I think I’ve achieved that aim.

Layout Notes

In order to produce nice-looking sheet music, I used a number of technologies. First, I entered the composition into MuseScore. I used MuseScore to do as much of the layout as I could, but there were a few things it would not do quite the way I wanted. So for the pages that I wasn’t happy with, I exported to pdf, used pdf2svg to convert it into a form that I could open in Inkscape, and made the final adjustments using that.

I used Scribus to create a pdf with page numbers, title, composer, copyright text and movement numbers, then wrote a little script which used pyPdf to put all the pieces together into the final document. All of the software that I used is free software.

Posted in midlength | Tagged , , , , , , | Comments Off on Piano Music: “For Mandie”

Something Beautiful

I was inspired recently to write a computer program which draws pretty images. Here are a few screenshots.

Screenshot of swirls.py.

Screenshot of swirls.py showing purple swirls.

Screenshot of swirls.py showing many rainbow-coloured swirls.

Screenshot of swirls.py showing many rainbow-coloured swirls.

Screenshot of swirls.py, featuring mostly blue and green swirls.

Screenshot of swirls.py, featuring mostly blue and green swirls.

Getting the Code

I have uploaded the code to bit bucket. If you have mercurial installed, you can get it by typing:

hg clone http://bitbucket.org/talljosh/swirls

You will need to have python and pygame installed to run the script.

How it Works

  1. There are invisible “singularities” drifting around the screen (you can make them visible by replacing SINGULARITY.VISIBLE = False with SINGULARITY.VISIBLE = True in the code).
  2. There are a fixed number of flares, which actually do the drawing. The flares are affected by gravitational effects from the singularities.
  3. At any given point in time, every flare is leaving a trail of the same colour. Over time, the colour cycles through the various colours.
  4. To prevent slingshot effects being too extreme, there is a radius around each singularity within which flares don’t feel any gravity from that singularity.
  5. Singularities cannot leave the screen. If they hit an edge, they change directions.
  6. Flares can leave the screen, but cannot go more than half the screen’s width or height beyond the screen boundaries. If they do, they reflect back and their velocity is damped.
  7. While the left mouse button is pressed down, the flares feel a gravitational effect towards the mouse pointer, which is twice as strong as the effect of one singularity.

Settings to Play With

There are a few settings that you can tweak to get different visual effects:

  • SINGULARITY.START_SPEED—the initial speed of each singularity in pixels per second
  • SINGULARITY.COUNT—the total number of singularities
  • SINGULARITY.VISIBLE—whether to show the singularities or not
  • FLARE.START_SPEED—the initial speed of each flare in pixels per second
  • FLARE.COUNT—the number of flares
  • FLARE.MAX_SPEED—flares are not allowed to travel faster than this speed (in pixels per second)
  • FLARE.FADE_TO_WHITE—controls whether the tip of the flare trail is white or black
  • GRAVITY_CONSTANT—controls the overall strength of gravity
  • NEUTRAL_DISTANCE—how close flares can get to singularities and still feel gravity; for super slingshotting, set to 0
  • COOLING_FACTOR—controls how quickly the white tip of the flare fades to the colour
  • DIM_HALFLIFE—the time in seconds that it takes for the colours to half fade to black
  • WALL_DAMPING—controls how much slower flares go after they bounce off the “walls” that are past the edges of the screen
  • MAX_FRAME_RATE—the number of frames per second that the script aims to achieve
Posted in midlength | Tagged , , , , | Comments Off on Something Beautiful