Robin's Notes RSS

Practical observations and notes. Little of philosophical interest.

Robin Barooah's Home Page
www.sublime.org

email: robin@sublime.org

Archive

Aug
22nd
Fri
permalink

Context-Aware iPhone launcher/springboard

There are too many icons on my iPhone already, and I expect to end up installing more applications and web-app links.

To make it easier to use, I’d like Apple to make Springboard context aware. Specifically, I would like to be able to choose some of the rows of the grid to show a prioritized list of icons of applications that I last used in that context.

What would ‘context’ be?  It would be a combination of location, time of day, and day of week.  There might be other factors, such as previous application run that might be worth taking into account. How would the context be narrowed?  

Probably the system could actually work by constructing a bayesian network based on the previous uses of each application associated with those variables.  It wouldn’t actually identify contexts per-se - it would just list the applications you’re most likely to use at that time and place in reverse order of probability.

Comments (View)
Jun
28th
Sat
permalink

Concise description of OAuth (< 300 words)

“I’d like to give a site access to my Google contacts, but I don’t want to give them my google username and password.”

OAuth solves this and similar problems.

OAuth allows one website to access a users content from another website without needing their username and password.  In OAuth terminology, the site that wants to get the content is called the consumer, the site that has the content is called the service provider and the content is called protected resources.

A concrete example (taken from the OAuth site) is of a user who wants to use a printing service to print photos they uploaded to a photo sharing site.  The printing service is the consumer, the photo sharing site is the service provider, and the photos are the protected resources.  If both sites support OAuth, the user can give the printing service access to the photos without giving it their username and password to the photo sharing site.

To do this, the user makes a choice on the printing site to access the photos from the photo sharing site.  The printing service generates a request and sends it to the photo sharing site.  The printing service then directs the user to the photo sharing site where the user authenticates themselves and approves the request.  The photo sharing site then provides a token to the printing service which it can can use to authenticate requests for the photos.  To reduce the chances of abuse, the token is typically only honored for a limited period of time.

A more detailed introduction can be found here.

Comments (View)
Jun
27th
Fri
permalink
three one-legged people working together cannot outrun one person with two legs
Comments (View)
Jun
26th
Thu
permalink

Importance of spaces in scala function by-name declarations:

I spent some time today having syntax problems with scala function by-name function declarations. It turns out that a space after the colon is critical. In the end someone on the scala irc channel at irc.freenode.net. by the name of ‘mapreduce’ helped me out (thanks!).

This session should clarify what works and what doesn’t work:

scala> def some1 [T] (interval :int) (f :() =>T) (noContent:T) = {}   
some1: [T](int)(() => T)(T)Unit

scala> def some2 [T] (interval :int) (f :=>T) (noContent:T) = {}  
<console>:1: error: ':' expected but identifier found.
def some2 [T] (interval :int) (f :=>T) (noContent:T) = {}
^
<console>:1: error: identifier expected but eof found.
def some2 [T] (interval :int) (f :=>T) (noContent:T) = {}
^

scala> def some2 [T] (interval :int) (f : =>T) (noContent:T) = {}
some2: [T](int)(=> T)(T)Unit

scala> def some3 [T] (interval :int) (f: =>T) (noContent:T) = {}
some3: [T](int)(=> T)(T)Unit

Comments (View)
Jun
23rd
Mon
permalink

How to create a PayPal certificate for the Java NVP API

For some reason I found it hard to discover this information and had to piece it together myself, which makes me think it may be worth posting.

First get a certificate:

1. Log in to your paypal account.

2. Click on ‘profile’ (next to ‘Resolution Center - ignore the drop down menu)

3. Click ‘API Access’ (in the Account Information column)

4. Click ‘Request API Credentials’ (the box on the right)

5. Choose ‘Request API Certificate’

6. Click ‘agree and submit’

7. Copy the information from the “Download or Remove API Certificate’ Page

7. Click Download Certificate to download the certificate.

Then convert the certificate to the right format:

You can do this using the openssl command.  If you’re on a linux or freebsd machine, you may already have it - if not, look at the website of your software distribution.

If you’re on a mac it’s part of the base system.  Windows users may find something that works here.

The command you need is:

openssl pkcs12 -export -out certificate.p12 -in cert_key_pem.txt

You will be asked for an “Export Password”.  You should make up a password and write it down.  This will be the certificate passphrase that you will use to configure the java API.

This will result in a file called certificate.p12 which you can use with the API.

You can test this file by typing: openssl pkcs12 -in certificate.p12

You will be asked to enter the verify password and the PEM pass phrase. These are both the same as the certificate passphrase that you entered earlier.

If the file is ok and you enter the correct password you will see a line saying “MAC Verified OK” along with various other details.

Using the Java API itself is way beyond the scope of this posting.

Comments (View)
Jun
17th
Tue
permalink

How to stop scala from quoting strings in XML expressions

  • robin_: hi - does anyone know how to stop scala from turning a " into an &quot; when it's included in an XML expression?
  • robin_: e.g. val a = <p>I include "quotes"</p>
  • robin_: turns into <p>I include &quot;quotes&quot;</p>
  • robin_: and what I want is the literal <p>I include "quotes"</p>
  • dobblego: scala> xml.Unparsed("hello\" there")
  • dobblego: res8: scala.xml.Unparsed = hello" there
  • robin_: ah - nice - thank you very much
  • dobblego: scala> <p>{ xml.Unparsed("I include \"quotes\"") }</p>
  • dobblego: res9: scala.xml.Elem = <p>I include "quotes"</p>
  • robin_: thanks for your help
  • dobblego: np
Comments (View)
Jun
1st
Sun
permalink

I’ve been using Apple Numbers to help a professor friend of mine with grade calculations. It turns out that if you import a sheet from Excel, it can often get into a state where the performance becomes unacceptable - despite the actual functionality appearing to be fine.

At one point, entering a new number into a sheet with a single table of around 2000 numeric cells and no formulae at all was taking more than 5 seconds.

Exporting the data to CSV and re-importing it cured this problem.

Comments (View)
May
31st
Sat
permalink
Neither Google spreadsheets nor Apple Numbers handle text at angles other than the normal horizontal. This is understandable with Google Spreadsheets since they are limited by the browser, but an odd limitation for Numbers to have.
Comments (View)