December 14, 2009

PathTools and iTerm instead of Terminal

Filed under: applescript, automation, eclipse, iterm, osx, pathtools, Uncategorized — michaelangela @ 9:44 am

So as noted, I tried using PathTools with FleBuilder under Eclipse 3.5 except FlexBuilder just has too many issues under 3.5. I gave up on PathTools with FlexBuilder but it’s been just awesome with the recent JaveEE 3.5 build. I only had one not-even-gripe as there really isn’t anything to complain about. It opens Terminal for the new paths instead of iTerm. Fortunately a little scripting later and it’s all good based on some code from the iTerm site and also this snippet.

You can see in the PathTool preferences what is called in order to do some of the interaction. Launching a terminal in the selected path is simple enough and is located here: /Applications/eclipse/configuration/org.eclipse.osgi/bundles/685/1/.cp/scripts/cdterminal.scpt

Changing that to the following makes it launch iTerm instead, with a little simple error correction. I hadn’t done Applescript stuff before so was just trying it out. I love these little bits of integration/customizations that are possible.

on run argv
set cdTo to item 1 of argv
tell application “iTerm”
— talk to the first terminal
tell the first terminal
— launch a default shell in a new tab in the same terminal
launch session “Default Session”
on error
display dialog “There was an error creating a new tab in iTerm.” buttons {“OK”}
end try
tell the last session
— cd to the requested cdTo path
write text “cd ” & cdTo
on error
display dialog “There was an error cding to the requested path.” buttons {“OK”}
end try
end tell
end tell
end tell
end run

December 11, 2009

How to package a jar for groovy with maven?

Filed under: automation, groovy, maven — michaelangela @ 4:14 am

Unfortunately the docs are still TODO

Building Groovy Projects – GMaven – Codehaus

groovy-jar Packaging

However there are some helpful links out and about:

NBT Consulting – Groovy with Maven Quick Start

A Groovy based Maven project can come in at least two different packaging/artifact types: groovy-jar and war . For more information about groovy-jar packaging, see http://mojo.codehaus.org/groovy/groovy-maven-plugin/mixed-compilation.html This document contains two sets of quick start instructions depending on the packaging/archive type the Maven project is to build:

  • Option A: Creating a new groovy-jar Package Groovy-based Module Maven Project (Non-web)
  • Option B: Creating a new war Package Groovy-based Module Maven Project (Web)
    • Bonus: Add Some Ajax Examples with GSP as the Server-side

And another example using Processing.org exported code:

NBT Consulting – Processing.org, Groovy and Maven Together Quick Start

This Quick Start Guide will demonstrate how to create, build and run two Processing sketches written in Groovy incorporated into a project that uses Maven to build. According to the book “Groovy in Action”, Groovy can be run in either direct mode or precompiled mode . In this guide, one Groovy script will be compiled to a Java class file (precompiled mode) and the other Groovy script will be left uncompiled (direct mode).

Building groovy projects with maven

Filed under: automation, groovy, maven — michaelangela @ 4:02 am

So now that I know that Java and Groovy can coexist, the next question is can maven be used to compile a groovy project.

Building Groovy Projects – GMaven – Codehaus

GMaven has kick-ass support for compiling Groovy projects with Maven!

And not only that but it can generate POM files for you tooBuilding Groovy Projects – GMaven – Codehaus

To help get Groovy projects started faster, you can use the gmaven-archetype-basic. This will create a new project with the basic POM configuration and some example classes to get you started quickly:
mvn archetype:generate -DarchetypeGroupId=org.codehaus.groovy.maven.archetypes \
-DarchetypeArtifactId=gmaven-archetype-basic -DarchetypeVersion=<version>

December 2, 2009

R and statistics

Filed under: automation, data processing, python, r, tool — michaelangela @ 11:41 am

If I have a database and I need to do some random queries where I need to do experimental queries interactively, I turn to python’s SqlSoup. But if it’s CSV, I used to just do some file handling in Python, load it up, and use lists (which are very cool) or some other straightforward data processing on it. Python’s good at that. Then I heard about R. I don’t have a lot of time to dig into the details at the moment but the link below really opened my eyes to what it can do. And how easily at that.

Basic statistics using R

The following page is a quick guide for using R to do most statistics necessary in an introductory statistics class.

Like loading in a table as a dataset:


I mean seriously! While it didn’t pop up a dialog on iTerm (using latest R for OSX) I just pasted in the path to the file and my data was there as


ready for manipulation. Some searches on filtering led to this post showing:

>tt <- matrix(1:20, ncol = 4)
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   16
[2,]    2    7   12   17
[3,]    3    8   13   18
[4,]    4    9   14   19
[5,]    5   10   15   20
tt[tt[,1] < 3, ]
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   16
[2,]    2    7   12   17

and I tried

 tt[tt[,1]>3 & tt[,3]<15]

based on a conditional seen here just to see if I understood it and got

[1]  4  9 14 19

which is what I expected but didn’t realize how easy that would be. Nice! The subset command is more explicit though with its named columns. Either way, wow that’s really nice to work with. Of course, there is also RPy:

RPy is a very simple, yet robust, Python interface to the R Programming Language. It can manage all kinds of R objects and can execute arbitrary R functions (including the graphic functions). All errors from the R language are converted to Python exceptions. Any module installed for the R system can be used from within Python.

Two flavours are available: rpy and rpy2.

Best of both worlds? 🙂

FB4 and Unit Testing

Filed under: automation, flash builder, test driven development — michaelangela @ 9:35 am

This makes me want to use Flash Builder 4!

Introduction to Unit Testing – Activetuts+

Unit testing is relatively new to ActionScript projects. Although FlexUnit has been around for a while it wasn’t intuitive to set up and there were a lot of inconsistencies with the documentation. Lucky for us, FlexUnit is now built into Flash Builder 4. Although the documentation is still sparse, this tutorial will be a good primer for setting up a Test Suite, going over several unit test examples and showing how to run/analyze them.

November 24, 2009

Revealing an asset in Eclipse in the Finder

Filed under: automation, cool, eclipse, tip — michaelangela @ 3:35 pm

So my previous post about using PathTools isn’t working at the moment but the tip below does get the file open in Finder (well Pathfinder in my case). External Tools can obviously be quite powerful.

In eclipse, reveal current file in filesystem – Stack Overflow

Great tip. On Mac OS X, replace the location with /usr/bin/open and the arguments should be just ${container_loc}. – zvikico Jul 22 at 5:27

Quicksilver + pbpaste + pbcopy

Filed under: automation, cool, osx, tip, tool — michaelangela @ 3:07 pm

After seeing the following post, many possibilities came to mind.

Notes: Pretty print XML

But working with XMPP and SAPO Broker, I’m always copy&pasting XML from one place to the other and it would be nice to format the XML snippet sitting in the clipboard.

This pipe does the trick quite nicely:

pbpaste | xmllint –format – | pbcopy

I wrapped this into a script, called x-xml-format-clipboard and now its just one command away from gratification.

In the end I came up with a couple that I use a lot after searching the web. The possibilities are endless but these are neat for me. In Eclipse I can’t easily transform text unless I install AnyEdit which I have on other systems. But I haven’t yet on this one. So the transforms are simple:

upper to lower:


pbpaste | tr '[:lower:]' '[:upper:]' | pbcopy

lower to upper:

#!/bin/bash<br /><br />pbpaste | tr '[:upper:]' '[:lower:]' | pbcopy<br />

remove blank lines:

#!/bin/bash<br /><br />pbpaste | grep -v '^

These are made into executable scripts on my path which I can then pull up with Quicksilver. So now to remove blank lines, I select the text in any editor, trigger Quicksilver, highlight the command, press enter, and paste it back. Nice. Of course this means that you can do just about anything with this kind of thing as discussed here. | pbcopy
These are made into executable scripts on my path which I can then pull up with Quicksilver. So now to remove blank lines, I select the text in any editor, trigger Quicksilver, highlight the command, press enter, and paste it back. Nice. Of course this means that you can do just about anything with this kind of thing as discussed here.

Nice set of Photoshop actions to add a little spice to images

Filed under: automation, photoshop, tool — michaelangela @ 2:42 pm

Note to self: check this list again later.

20 Photoshop Actions to Add Flair to Your Photos

The non-professional photographers among us are often left with boring and flat shots from our cameras, the photos lack the flair and energy that is achieved with expert techniques and equipment. Photoshop Actions on the other hand, can help recreate some amazing photo effects, just by pressing a button! This post rounds up 20 of the best Photoshop Actions that allow you to easily spice up your photos with popular effects, including HDR, Soft Focus, Lomo, Velvia and more!

September 22, 2009

Messy XML that needs a quick clean up?

Filed under: automation, cool, tip, tool, xml — michaelangela @ 12:26 am

Really neat and nifty. This is for when you have those one liner strings of XML in a log or something (like CharlesProxy’s response pane) and you want to view it all nicely. Normally CharlesProxy does an excellent job… for well formatted XML. At least some code I was working with really wasn’t well formatted and even the noble Charles just gave me a oneliner. xmlling cleaned it right up though. Nice.

Notes: Pretty print XML

In case you didn’t know, you can pretty print XML with the xmllint command line tool that comes with libxml2, and its installed by default with Mac OS X.

September 9, 2009

And an example on how to use JSFL

Filed under: automation, cool, flash, tip, tool — michaelangela @ 1:14 am

And this is cool, too. I’m always looking for productivity tips and this is very cool. It really opens up a lot of possibilities.

deleteaso » Fix Textfields JSFL

Today Seb was having some issues when dealing with embedded fonts – read his post. He came up with some ActionScript ways to get around it. Well another way would be to use JSFL. A couple of my team members at Fuel Industries wrote the following JSFL script. It goes through your library and searches out any dynamic textfields. Once it finds one it makes sure it’s on a whole pixel, turns the auto kern off, embeds “UpperCase, LowerCase, Numerals, Punctuation” characters, and makes it not selectable. But you could make it do pretty much anything you can through JSFL.

August 21, 2009

Generated getters and setters in Flex

Filed under: as3, automation, cool, eclipse, flex, tool — michaelangela @ 1:11 am

So for this particular Flash AS3 project I am doing that uses Flex as the code editor, I was just about to write a getter/setter pair and thought “perhaps someone has made a way to automate this…”

Quick Google later…

No More Writing Getters and Setters in Flex

eokyere blog has one of the best Flex productivity tips I have seen in quite a while. I build AS3 components all day, and spend way too much time manually typing getter and setter methods. Using the Dash plugin for Eclipse and eokyere’s productivity with with dash in eclipse, you’ll never write another getter and setter again!

October 16, 2008

Remember to check your emoticon path for Expression Engine!

Filed under: automation, expression engine, ruby, tool — michaelangela @ 5:50 pm

Getting ready to move a site from dev to production. I often use Charles just to make sure paths are doing what they are supposed to do. I had done an initial test moving from localhost to an actual IP address just to run through the process. I got everything except emoticons and it took a little while to track it down:

Expression Engine Migration Notes | WikiLab Notes

go to Admin > SYSTEM PREFERANCES > Emotican Preferences

Voila. Problem solved. To aid with this sort of thing in the future, this older post has some very helpful tips.

Configuring Expression Engine for multiple servers

The one remaining problem is that, upon installing EE, it hard-codes your site URL and application installation path all over the place, from config files to options stored in the database. This is what makes Expression Engine so unportable — moving from one server to another, say from development to production, requires updating this URL and path information in literally about a dozen places.

To aid with this process, a kind soul has written this ruby script:

Migrating ExpressionEngine from development to production – deeden.co.uk

I’ve never succeeded in migrating successfully using the manual method. I always miss something and have to deal with some small problem that inevitably crops up. Finally, I decided to make it easier on myself, so I wrote a script to perform the update for me. This will not be for everyone, however if you’re comfortable with command line scripts and ruby this may do the job for you.

I haven’t tried the config method or the ruby script yet but it’s good to know.

October 15, 2008

grep instead of python?

Filed under: automation, bash, cool, linux, one-liner, tip — michaelangela @ 5:29 pm

I have an xml file with a listing of images that I need for a site. Typically I fire up IPython with Amara and do my xml wrangling there. But I also needed the files. I thought about using python to also grab and save the files but a little search led to this post. Ironically, while the tip to use Python is good, there was a tip to use curl to get the feed, grep to parse the images, and finally xargs to feed it to wget for downloading.

Thinking Serious » Using Python to Grab Images From a Web Site

curl -s http://99designs.com/contests/6999/feed | grep -Po “src=\”.*(png|jpg)” | grep -o “http.*” | xargs wget -q

My situation is a bit different though. There are no extensions on the files, they are in a tag, and I need to rename them with extensions. After a little Googling I used this which worked very well.

curl -s http://domain.tld/feed | egrep -o "<tag>.*</tag>" | egrep -o "<tag>(http.*)</tag>" | sed -e 's/<[^>]*>//g'
for f in *; do mv ./"$f" "${f}.jpg"; done

I still need to do some xml wrangling with Amara but the files are now just need to be moved to the right directories. Nice.

October 11, 2008

Notes: Photoshop Sparklines Script

Filed under: adobe, automation, javascript, photoshop cs3, tool — michaelangela @ 11:17 pm

Tufte Sparklines Photoshop Script | La Photo Vita

Sparklines can be hard to produce. Most graphing packages are designed to produce large graphs or charts, and it can be very hard to generate the wide-but-thin lines for incorporation in documents. This was the motivation for writing a Photoshop script that would automate the production of sparklines. It works by reading a data series from a text file and plotting a sparkline image as a Photoshop path, and then stroking it with the pencil tool. This produces a bitmap image which can then be cut-and-pasted into the target document. The user retains control of the color and line style of the sparkline by setting the Photoshop foreground color and pencil tool settings before running the script.

Notes: LOMO Photoshop script

Filed under: adobe, automation, javascript, photoshop cs3, tool — michaelangela @ 11:16 pm

Flickr: Discussing Fake-LOMO Adobe Photoshop Script in Technique

I saw that there are some PS actions for doing LOMOing but they don’t seem to handle multiple sized images well. I threw together this PS script to handle multiple sized images as well as non-flattened images.

Notes: Photoshop recursive save to web script

Filed under: adobe, automation, javascript, photoshop cs3, tool — michaelangela @ 11:15 pm

Ovidiu Predescu’s Weblog: Recursive export to Web in Photoshop CS3

Yesterday I was looking for a way to take a subset of the pictures I
have and convert them to JPG. I want to use the JPGs on a small Mac
Mini to make presentation in FrontRow using a newly acquired Canon SX7 digital projector (more on this in a later entry).

Unfortunately Adobe Lightroom does not offer such a functionality.
You can export all the pictures in a directory to JPG, but there’s no
way to take a directory, and recursively export all the pictures within
it to JPG while maintaining the directory structure they are in.

I could have written a small shell script to do this, but I have a
mixture of TIFF, JPG and RAW images that had to be processed. I wanted
to get the image processing capabilities from Lightroom or Photoshop,
instead of using dcraw. Adobe Lightroom doesn’t have a way to script
it, so I looked at Photoshop CS3 to do it.

Photoshop can be scripted in JavaScript, in addition to AppleScript. I came up with a small script that does the conversion.

July 6, 2008

Getting rid of the dreaded “can’t encode” errors with Python and MySQL and SqlSoup

Filed under: automation, cool, dev, mysql, python, sqlalchemy, sqlsoup, tip, xls — michaelangela @ 10:47 pm

So I was getting problems inserting data that has the ‘™’ symbol in it. Brutal stuff. Couldn’t find a way around it. Did it by hand in the end. Nasty. The problem was that I was getting

UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2122' in position 12: ordinal not in range(256)

where the '\u2122' is the ‘™’ symbol. There were some others as well. Finally happened upon this post which, fortunately, cleared it up. To use this tip with SqlSoup, the connection string needs a couple of extra parameters.

Instead of

db = SqlSoup('mysql://user:password@host:port/database')


db = SqlSoup('mysql://user:password@host:port/database?charset=utf8&use_unicode=0')

The requirement of course is that the database tables are set up with the UTF-8 charset.

But now I can thrash data at will! Mwahahahaha! Sorry… but now I can pull in unicode data from an Excel file and throw it into a database with rediculous ease. OK not rediculous ease but wow this simplifies it.

[edit]I like to use iPython to do my data thrashing with SqlSoup and SqlAlchemy. If you use the second connection string with the charset and use_unicode options, don’t reset the db connection to the previous one without those. Once doing that I couldn’t set it back and had to exit and restart the session. Bummer.[/edit]

mysql unicode issues – sqlalchemy | Google Groups

a. have use_unicode=0, set charset=’utf8′ on the connection, AND

b. ensure you have
table options = {‘mysql_charset’: ‘utf8’} when creating tables, and
all should be well.

April 8, 2008

Local subversion on 1and1

Filed under: 1and1, automation, cool, dev, eclipse, education, svn, tip, tool, webfaction — michaelangela @ 4:15 am

1and1 had an update. Good. It broke subversion. Bad. 😦 After a short fight with subversion 1.4.6 (which didn’t work) I thought about using 1.4.5. Fortunately that’s pretty straightforward and… it works! So here are the commands for that. I develop on Eclipse using a JumpBox Trac/Subversion server locally. Changes to my Django app and Flex app are stored there. Then I can pull it from outside over ssh. Very helpful. Well… 1and1 is only file hosting. Webfaction hosts the fun stuff.

cd ~/some/src/directory
wget http://subversion.tigris.org/downloads/subversion-1.4.5.tar.gz

wget http://subversion.tigris.org/downloads/subversion-deps-1.4.5.tar.gz
tar xvfz subversion-1.4.5.tar.gz
tar xvfz subversion-deps-1.4.5.tar.gz
cd subversion-1.4.5
./configure --prefix=$HOME
make install

April 7, 2008

Another python audio library that can handle FLAC

Filed under: audio, automation, cool, dev, python, tip, tool — michaelangela @ 5:18 am

Just a note about another one.

TagPy | Andreas Klöckner’s web page

TagPy is a set of Python bindings for Scott Wheeler’s TagLib. It builds upon Boost.Python, a wrapper generation library which is part of the Boost set of C++ libraries [3].

Just like TagLib, TagPy can:

  • read and write ID3 tags of version 1 and 2, with many supported frame types
    for version 2 (in MPEG Layer 2 and MPEG Layer 3, FLAC and MPC),
  • access Xiph Comments in Ogg Vorbis Files and Ogg Flac Files,
  • access APE tags in Musepack and MP3 files.

Python and FLAC audio files

Filed under: audio, automation, cool, dev, python, tip, tool — michaelangela @ 5:16 am

Kinda neat this library is. Even works on multilingual song files.

Development/Mutagen/Tutorial – Ex Falso / Quod Libet – Trac

      from mutagen.flac import FLAC
audio = FLAC("example.flac")
audio["title"] = "An example"

Create a free website or blog at WordPress.com.