Sunday, September 1, 2013

Combine reference.conf files from a bunch of akka jars

Need to build a reference.conf from a bunch of different Akka jars?  Here's a simple way to do it from the command line:

for i in /Users/james/nexus/sonatype-work/nexus/storage/central/com/typesafe/akka/*/2.2.1/*jar ; do unzip -q -c $i reference.conf ; done > /tmp/reference.conf

That just cats together the contents of all the reference.conf files and puts it in /tmp/reference.conf.

Adjust the paths to fit your version and file locations, of course.

Monday, August 19, 2013

Using F# on iOS - need to build from source for monodevelop

If you're starting to use F# on iOS using Xamarin.iOS, you'll need to build some parts from source.  I submitted a patch to the instructions that should eventually end up on the F# foundation website.  In the meantime, you can see the instructions here in my github fork.

Saturday, August 10, 2013

v50 of AndroidProguardScala released

Just released v50 of the AndroidProguardScala Eclipse plugin. Installation instructions are here, and if you're a current user you can pick it up by asking Eclipse to check for updates.

Changes:

  • Update to latest version of dependencies (Scala 2.10.2, Scalaz 7.0.2)
  • Better checking for Proguard errors

Thursday, August 1, 2013

Glassware in Scala and Scalaz

I've been working on a Scala port of one of the Glassware samples. You'll find the code here on Github.

It has examples of a few really useful Scalaz features.  In particular, it has a bunch of examples of using EitherT in for-comprehensions.

Sunday, May 12, 2013

F# Parsing XML, aiming to get to Type Providers

For a new project, I've started using some F# again. Type providers are brand new since last I used the language, so I thought I'd start out by writing my own type provider to deal with some xml apis I'll be using.

One of things I missed from F# was sequence generators. Here's a sequence generator that turns XML into a slightly different form, hopefully easier to consume from a type provider:

Here's the output:

Monday, April 22, 2013

tinyxml issue with ctype.h

Compiling tinyxml for iOS?  Seeing this kind of error?


tinyxml.cpp:25:10: fatal error: 'ctype.h' file not found

You probably just upgraded Xcode, or just installed it.  You don't have the right simulator installed.  Go  to Xcode preferences -> Downloads tab and install the right simulator.

Thursday, April 11, 2013

Very simple Google Spreadsheet code

FYI - this blog post is from a long time ago, and I think things have changed quite a bit.  I'm leaving it here because some parts my still be useful, but definitely read the comments and don't expect it to work out of the box.   - James, 26 Nov 2013

(Update - see comment from Sean about this no longer working due to auth changes from Google)

I wanted to use data from a google docs spreadsheet in a project, and the sample code all talks about how to authenticate and get lists of documents for a user.
In my case, I already had a public document that I wanted to read. 
You’ll want to read the doc here first, but there were two gaps. 
  1. It wasn’t straightforward (at least for me) to figure out exactly what the URL for a public spreadsheet should be (the doc concentrates on private documents, and assumes you’re going to be iterating through a list of available spreadsheets, not going straight to a specific one).
  2. It wasn’t clear which Java classes mapped to the URLs I had.
So here’s a very simple sample, reading data from this public spreadsheet:

The output:
One
1
Two
2
Three
3
The code:
package com.banshee;

import java.io.IOException;
import java.net.URL;

import com.google.gdata.client.spreadsheet.SpreadsheetService;
import com.google.gdata.data.spreadsheet.CustomElementCollection;
import com.google.gdata.data.spreadsheet.ListEntry;
import com.google.gdata.data.spreadsheet.ListFeed;
import com.google.gdata.util.ServiceException;

public class SpreadsheetSucker {
  public static void main(String[] args) {
    SpreadsheetService service = new SpreadsheetService("com.banshee");
    try {
      // Notice that the url ends
      // with default/public/values.
      // That wasn't obvious (at least to me)
      // from the documentation.
      String urlString = "https://spreadsheets.google.com/feeds/list/0AsaDhyyXNaFSdDJ2VUxtVGVWN1Yza1loU1RPVVU3OFE/default/public/values";

      // turn the string into a URL
      URL url = new URL(urlString);

      // You could substitute a cell feed here in place of
      // the list feed
      ListFeed feed = service.getFeed(url, ListFeed.class);

      for (ListEntry entry : feed.getEntries()) {
        CustomElementCollection elements = entry.getCustomElements();
        String name = elements.getValue("name");
        System.out.println(name);
        String number = elements.getValue("Number");
        System.out.println(number);
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ServiceException e) {
      e.printStackTrace();
    }

  }
}