Act..Act..Activator!

2012-07-17 05:00:48 +0000

With the wife happily moved over to an iPad for most of her computing needs (and the laptop back in my grubby hands) we needed something for her to be able to print from iOS since although my little HP laserjet 1012 is fairly old, it keeps chugging right along and I’m too cheap to rush out and buy yet another printer unless I need it.

There were a couple of solutions that cost a couple bucks, but turns out there is also AirPrint Activator which seems to work just fine as magical airprint glue for either local or shared printers. I just run that from my desktop (which is running more often than not) and we can print from all our random iOS devices - not that elegant, but the price is right.

Still happy with the FreeNAS box, swapped motherboards to a sandy bridge based gigabyte board and put in a i3 2120t since I don’t need that much umph to serve our family and its running even better than the old phenom II. Tempted to update to full FreeBSD so I can dink around more with it … nah, it works and don’t have the time.

FreeNAS 8.0.4

2012-06-26 04:26:32 +0000

After the update to 12.04 for my ubuntu-based file server went awry, I took another look at the FreeBSD based FreeNAS as a replacement. Turns out it was pretty easy to set up and I’m digging how it runs

The Good:

The not so good:

I did run into a couple of other problems. Trying to copy data back to the server I got these pesky Error - 50 messages that would abort the copy over AFP. Turns out from looking at the logs, I had a number of  .AppleDouble files I needed to delete first to get the copy  using a

find . -d -name .AppleDouble -exec rm -rf '{}' \;

I also have a few scripts that use rsync to copy data around on a regular basis and need to use key based authentication with SSH however for that was giving me woes at first as well. Turns out looking at the logs I need to go back and make sure the permissions and ownership of all the mount directories (something like this) were correct otherwise SSHD gets grumpy.

A Bit of Git

2012-02-18 22:55:32 +0000

I’ve been playing around with git for a while now for my own projects and thought I’d give a couple of quickie shout outs to some useful sites & tools. Via total coincidence, turns out they are both from *Atlassian even though I came to them independently.

First of all, after you download the command line tools and start to get familiar with them if you’re like me you also want a graphical tool in your pocket. If you’re just messing around you might not want drop a lot (or any) cash either on something like Tower either. If thats the case, I’ve found SourceTree works decently, looks nice, and is the right price (free). Too bad I grabbed it from the App Store, looks like there are some issues with the upcoming restrictions there and you’ll have to grab it straight from their site instead.

Next, you might want somewhere external to host. Of course everyone has heard of GitHub and thats great if you have a few open source projects you would like to share, but what if you just want something for your personal stuff? GitHub wants $7/mo minimum in this case  but for up to 5 collaborators, BitBucket gives you unlimited repos for free. Nice!

*Atlassian: I still wish you hadn’t removed wiki markup from Confluence …grrr

My First Scala Program

2009-08-03 22:41:52 +0000

A while back for my birthday, I got the Odersky Programming in Scala book and today I finally got a chance to crack it and play around. I had been interested in trying to pick up one of the new wave of dynamic JVM langagues like Groovy, JRuby, or Jython and had settled on Scala. I had read a suggestion that Project Euler would make for a fertile playground of test problems to learn on, and having already done the first several in Java that rang true for me. So, here is my overly complicated solution to the simple first problem..

 //If we list all the natural numbers below 10 that are multiples of 3
 //or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
 //Find the sum of all the multiples of 3 or 5 below 1000.
 
 import scala.actors._


 object Adder extends Actor {

	var sum = 0
	def act() = {
		react {
			case (num: Int) =>
				sum += num
				act()
				case "REPORT" =>
				Console.println("Total = " + sum);
		}
	}
}

object ProblemOneRunner {
	def main(args: Array[String]): Unit = {
		Adder.start
		for(i <- 1 to 999) {
		if(i % 3 == 0 || i % 5 == 0 ) {
			Adder ! i
		}
	}
		Adder ! "REPORT"
	}
}

It starts out looking something like a Java program with an import statement, although Scala uses the _ notation to import everything instead of * since * is an identifier. Scala supports a lot of flexibility in its import statements, they can show up anywhere and you can use them to remap names or set up exclusion filters - but lets not get to far astray.

Next, you’ll notice that my program has two objects and no classes. Its not that Scala doesn’t have classes, its just that Scala classes don’t have the Java concept of static - if you want a singleton object, you use the object keyword. The solution I have above uses one singleton as the main program entry point and another Adder singleton that extends Actor. This is just so I could play with Scala’s built in multithreading and message passing support - obviously this problem doesn’t really require it but I thought I’d try it out anyway for fun.

The Adder has its own sum variable it uses to keep track of the numbers it will add up - Scala uses the var keyword for variables that can be reset and val for ones that can’t. You’ll notice the lack of any type declaration here, its not that Scala variables are not typed, its just that it uses type inference to figure out what they are. Also, Java users will notice the lack of semicolons - semicolons are optional in Scala in most cases. The Adder overrides the act method, the entry point for threads, and then calls react which will look for a message in the actor’s inbox and if it doesn’t find one, put the actor to sleep. Unlike some of the other constructs Scala provides for Actors like receive, the thread will die at the end of react instead of looping so we have to put a call to act() at the end of the int message we send it to keep it alive.

In the main method, we start up our Actor thread, then loop through 1 through 999 looking for numbers divisible by 3 or 5 to send to our Adder, then once we are done we send a message to the thread to report and finish its loop. Again, Java users will notice the easy condensed for loop and the ! message passing syntax.

I’ve barely scratched the surface of Scala here, I’ll try to get a couple more problems done and posted that likewise abuse language features as I get time.

Cerebral Imprint 2.5

2009-06-23 21:10:24 +0000

Whew! I just finished a major rewrite on my flash card app, Cerebral Imprint. One of the early design decisions I made way, way back when I first wrote the application (ouch, was it really back in 2004?) was to make it a single document application. The application would store all its information about the user’s data in a single file in the user’s Library directory. This was simple, however as time went on and my personal flash card library grew I realized it just wasn’t going to cut it.

The next thing I did was to hack on support for the application to read and write its flash card data to other files. When the application would start up it would prompt the user if they wanted to open an existing file or start a new one. Only one file could be open at a time but it was the least invasive way to get multiple file support without changing a lot of code (and how the user interface works). It worked but I wasn’t really happy.

Thing is, there is way to this the right way. You base your application off NSDocument and Cocoa provides all sorts of functionality for you. It was really bugging me that Cerebral Imprint wasn’t acting like a normal document-based application for the Mac should behave so I decided on perhaps a overly drastic course of action - I started from scratch with a totally fresh NSDocument application and imported code as I needed from my old project. It took a lot of time but ultimately it was worth it since as I imported the old code I took the opportunity to scrub cruft going back in some cases to 2004 that was no longer being used and really clean things up.

I also added some new functionality along the way. For instance, I’ve been playing around with flash cards apps on my iPhone but haven’t felt like tackling writing an iPhone app right now so I’ve added export functionality so I can export my cards into apps like Notecards to tote with me.