Coach Thrasher
rtmpdump
Wow, Luke Kenneth Casson Leighton is pissed at Adobe for DMCAing RTMPdump. I believe in free software, and not breaking copyrights, so I side with him on those points. However, when he brings his 7-week old daughter into the argument with an f-u sign, that crosses the line. Bad form Luke, baaaaaaad.
Posted at 01:05PM May 25, 2009 by jason in Software | Comments[1]
GMail via Spring JavaMailSenderImpl
Sometimes I hate Google. It can give too many wrong answers. Yet, they look so enticing, like I'm a little kitten playing for hours with a ball of yarn. It gets me nothing.
None the less, here's how to properly configure Spring's JavaMailSenderImpl to -properly- send mail through Google Mail using your gmail account.
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="defaultEncoding" value="UTF-8"/>
<property name="host" value="smtp.gmail.com"/>
<property name="port" value="465"/>
<property name="username" value="${mail.username}"/>
<property name="password" value="${mail.password}"/>
<property name="javaMailProperties">
<value>
mail.debug=true
mail.smtp.auth=true
mail.smtp.socketFactory.class=java.net.SocketFactory
mail.smtp.socketFactory.fallback=false
</value>
</property>
</bean>
Posted at 04:55PM Mar 31, 2009 by jason in Software |
SVN diff with Meld
Every time I setup a new machine for development I forget a whole bunch of extra little bits that make developing more efficient and enjoyable. Most recently a new Macbook Pro has been my platform of choice. I like the visual diff implemented by Meld, and it works nicely using X11 with the Meld build coming from Fink. (Don't even try installing Meld from MacPorts... after 24 hours of hardcore Python pain it totally failed.) Here's a little script to launch a visual diff against the SVN repository that I keep misplacing (captured on my blog so I can find it again).
1) download it
2) move it to ~/bin/svn-diff-meld
3) chmod +x ~/bin/svn-diff-meld
4) echo "alias sd='svn diff --diff-cmd ~/bin/svn-diff-meld'" >> ~/.bash_profile
Then on the command line, run SVN diffs against the repo with something like:
$ sd -r 27003
or
$ sd path/to/some/file.txt
or
$ sd -r 27003 path/to/some/file.txt
Posted at 09:21AM Aug 15, 2008 by jason in Software |
RegCM and the Scientific Method
My wife is doing her graduate work at UCSC and using the RegCM regional climate model to simulate atmospheric conditions during the Eocene era. She frequently finds bugs in the code (FORTRAN), but she has no way to keep track of what changed other than creating a versioned tar ball of the whole code tree for each version change.
Recently she found a bug that affects all of the research she's done for the past 3 years. The bug likely affects countless other researchers and their published work, possibly invalidating their findings. This sounds incredibly troubling to me, but there's no way to understand what bugs those other researchers may have been affected by because they don't reference a version, branch, or tag, of any code tree.
How can any of their research be repeatable if they don't reference a version of their code? This seems like a fundamental flaw in implementation of the scientific method.
This has been driving me crazy because I would never embark on a large software project without a source control system. I would go insane tracking all of the changes, and trying to ascertain what happened when something didn't work.
After a little searching, I found a free SVN hosting solution at Code Spaces for her to use. It's not hosted at SourceForge, Google Code, or other OSS access points because we have little understanding of the licensing controls on the code, which is managed by some nice Italian climate researchers.
If anyone is interested in using the SVN system to track changes, here's where it lives:
http://svn.codespaces.com/regcm/regcm/
To check it out, just run:
svn co http://svn.codespaces.com/regcm/regcm/trunk regcm
Posted at 12:30PM Jun 27, 2008 by jason in Software |
TTL of Maven Repositories?
While building Spring Security 2.0.2 from their SVN tag I ran into what is increasingly becoming a major Maven annoyance. Namely, access to or maintenance of public Maven repositories is becoming problematic. They don't seem to be maintained, and when they are broken, many OSS projects aren't fixing references to them.
Spring Security, on the 2.0.2 SVN tag, won't build because it can't find the appropriate JetS3t. This is because the JetS3t jar doesn't exist where it once did. While I had no idea where it once lived, even the JetS3t Downloads page has incorrect instructions to find it: the referenced Maven repository URL doesn't seem to reference a valid S3 bucket. Maybe someone stopped paying the S3 bills?
So, while I was trying to update my JCaptcha code for AppFuse, I couldn't build the main Spring Security tree, nor the sandbox/captcha module required for JCaptcha. What a pain in the butt. Now I had to hunt down the correct version of the JetS3t jar to get Spring Security to build.
It turns out there's an interesting S3 based storage service called S3Browse that links to what appears to be a mirror of the former JetS3t maven repo path here: http://s3browse.com/explore/maven.springframework.org/external/. It's a bit shady because the jar isn't coming from the JetS3t file's owner, and I have no idea what's compiled into the version sitting on S3browse. Considering S3Browse's homepage doesn't seem to have been updated since 2007, I'm skeptical the link will live long.
So that begs the question: whats the time to live of OSS Maven repositories? I have faith Apache's will stick around, but there seems to be an opportunity for a repo-aggregator here to suck up the slack.
Posted at 10:43PM Jun 12, 2008 by jason in Software |
Glass Door
I just read about Glass Door, which shows salaries of companies that I'm competing against in the hiring relm. Specifically, we're competing against Google and Yahoo to hire the top talent in the Bay Area.
I'm very happy to say that 4INFO pays at the same level across the board. We need the brightest people, and must show that we'll compensate them appropriately in order to hire. It turns out that we're doing just that. I couldn't be prouder of Software Engineering at 4INFO!
Posted at 06:27PM Jun 12, 2008 by jason in Software |
Parameterized user.home for Maven on Windows XP
I found a handy way to reference the Java system property ${user.home} within a Maven build that supports Windows' ridiculous path name to home/profile directories:
c:\Documents and Settings\jason.
The problem is, when using Maven, this parameterized property doesn't get passed through as one property value, but as three, because somewhere in the build Maven chokes on the spaces or back-slashes and interprets it as either three arguments:
"c:\Documents", "and", "Settings\jason"
or treats the windows back-slash as an escape character and removes them so my parameterized user.home becomes:
"c:Documents and Settingsjason"
Why would this matter? Well, if you want to share build configurations with other developers, and can't check some of your files into a source control management system (because, for example, they contain private keys or certificates that don't belong in SCM), then you need a common, parameterized place to reference them that will work for every developer without much trouble. In my case, it's integration with Amazon's web-services that necessitates managing public/private PEM and P12 files.
For Amazon, I want to reference the AWS pem and p12 files like this from either the Maven pom.xml, or the settings.xml file:
${user.home}/aws/cert-BLAH.pem
${user.home}/aws/pk-BLAH.pem
${user.home}/aws/awskeystore-BLAH.p12
However, on Windows XP, unless I set the user.home on the build path every time, the back-slash escaping or space issues cause the files to not be found.
To fix it, add this profile to the $M2_HOME/conf/settings.xml file:
<profile>
<id>laptop-xp</id>
<properties>
<user.home>C:/Documents and Settings/${user.name}</user.home>
</properties>
</profile>
Then add an appropriate entry to the activeProfiles:
<activeProfile>laptop-xp</activeProfile>
Now every user will be able to use the user.home property to reference their home path correctly on the Windows box.
Posted at 10:13AM Jun 08, 2008 by jason in Software |
Mac OSX Terminal Colors
By terminal colors, I don't mean the colors of death, I do mean the command prompt. This dude has a great post on how to enable terminal colors on OSX. It's quite useful for reducing fatigue on the eyes (black background), and syntax highlighting within vi for different file extensions. My eyes get lost in the black and white of XML or Java after a few minutes on the stock terminal prompt.
Posted at 03:30PM Jun 02, 2008 by jason in Software |
Facebook API Better Stronger Faster
Okay, I've released my "better stronger faster" Facebook API on Sourceforge for all to use. It’s code name is F8-API, and it’s available for all to download or browse from the SVN repository and try out.
A download package hasn't been released yet, as I'd rather people provide feedback to validate that a release is warranted before packaging it for distribution. Use this command to get the files from Subversion:
svn co https://f8api.svn.sourceforge.net/svnroot/f8api f8api
I had signed up as a "Facebook developer" in several of the Facebook apps tools, and received about 1 query a day from people looking to "build the next killer app". Unfortunately, I found that people tended to make the assumption that I was a college student with lots of time on my hands to do this, and I'd work for peanuts. Well, that's not the case, but I do reflect fondly on college, and I can afford my own peanuts, thank you. As I result, I decided to give away some of this love on Sourceforge, and such, the project was born.
Today the F8-API is a lightweight stateless interface to Facebook’s web services. It uses Apache HttpClient, and Log4j, and it processes data quickly through SAX parsers. It is completely functional for all API calls today, and it supports both desktop and web based Facebook applications. You can also write unit tests that will hit the live Facebook account and interact with your test environment using Maven and JUnit, for both desktop and web apps.
Hopefully people will find this useful as it is. There is some room for improvement though. The data model used by Facebook needs to be flushed out so a "higher level" API can be interfaced that will act on model objects. As an applications developer, you usually don’t want to fiddle with low level things like the transport layer of an API that you’re interfacing. So, some flushing out is needed here.
I also need to write some example code to show how easy it is to use. If you’re subscribed to my RSS feed, you’ll see the update notice posted to the feed soon.
Posted at 10:44AM Sep 13, 2007 by jason in Software |
YAY, I Fixed my Facebook API :)
Like everyone and their little brother, I've been working on a killer Facebook app. The platform offers so much potential for revenue generation; I just can't pass the opportunity up. I found quite a few architecture issues with the Java Facebook API that Facebook released. It worked, but it wasn't enterprise ready... in particular there were no JUnit tests, no logging, HTTP connection memory leaks, it’s not thread safe, etc. It works for "Hello World", but not my app.
The Javabook API looks cool, but I needed desktop support. I also didn't want to use JSON since FQL returns buggy (ambiguous) results that way for queries (see the Facebook docs, I do like the name though, “JSON” == great name :).
Aside: what’s the business goal of releasing a 3rd party Facebook API? I don’t think the answer is anything close to the logic that created Apache.
So, I've finally fixed my API bug. I don't mean to beat-up on Facebook (because their site, app, business, and developers absolutely rock), but the issue was related to their API documentation. The references to "session", "session key", "session secret" and "secret" for desktop apps versus webapps are ambiguous in their API docs. They are used on different pages in different context to mean similar and different things, depending on the page. Ack! Good documentation is critically important for communicating with others, and this issue just highlighed that for me.
I posted a Mavenized Facebook api (the Facebook original code plus a few JUnit tests plus Maven wrapping) a few days ago. It's been interesting to see how many downloads per day there are... not many == ~4. But heck, there are downloads! So there must be demand for something like this.
If anyone is interested in a more robust API for desktop and webapps, using HttpClient with logging, and per-UserId sessions, thread safety, local callback support, and Maven let me know. It supports all Facebook API calls, including FQL. The code is fully documented with Javadoc. It'll do XML and JSON. It supports Spring-based configuration out of the box. It has a Facebook data model, with MVC style stateless API calls. It'll put your API key and secret through their paces for all API calls using JUnit. It's so good, it'll get you a beer when asked. I’ve got it humming right here and would be happy to license it out.
Posted at 11:14PM Aug 07, 2007 by jason in Software | Comments[1]
It Feels Like Everyone's Making Facebook Apps... But Me.
I'm totally sick of API's right now. Especially buggy ones. That is to say (tounge in cheek), especially ones that I didn't write (ha!).
I've been working an a Facebook app ties a bunch of disparate services together, that you wouldn't normally put together, and each service has an API. But, they don't play well at all. They are either stateful, stateless, are based on a web service, or Windows COM, and it's just spinning my head to glue them together.
Ack! It's time to step away from the computer for a while.
Posted at 08:36PM Aug 05, 2007 by jason in Software |
Mavenized Facebook API
I've been fiddling with a Facebook app recently and created a Maven2 build of their API with a few JUnit tests. I find the mavenized package easier to use since nearly all of my own work is managed this way. It's posted for anyone to use.
To build, you must set the "facebook.apikey" and "facebook.secret" values in the pom.xml file. You'll also need to install the JSON library to your Maven repository. (It's not in the central Maven repo as of July 26, 2007.)
Posted at 04:10PM Jul 26, 2007 by jason in Software |
Extendable Maven-BASH Auto Completion
I was so excited about using Maven with bash_completion, I decided to fix it, and add more commands. Now you can support any Maven commands, or plugin commands, including Java "-D" style properties, by appending them to the command set file. You don't need to know BASH shell to make the changes.
Download mvn_completion.zip to get the files, with instructions. It's a 5 minute install.
It really helps with typing long Maven commands, and to jog your memory about what the command options are, with just the [TAB] key.
Something like this:
mvn -Ds[TAB] cl[TAB] co[TAB] int[TAB] ins[TAB] site\:s[TAB] site\:d[TAB]
becomes:
mvn -Dsurefire.useFile=false clean compile integration-test deploy install site\:site site\:deploy
Not sure which hibernate3 goal to run? Just double-tab it ([TAB][TAB]), and all of the options will print out:
$>mvn hibernate3\:[TAB][TAB]
hibernate3:hbm2cfgxml
hibernate3:hbm2ddl
hibernate3:hbm2doc
hibernate3:hbm2hbmxml
hibernate3:hbm2java
hibernate3:schema-export
hibernate3:schema-update
Thanks to Apache for supporting Maven: it rocks.
Posted at 05:53PM May 28, 2007 by jason in Software |
Fixing Maven 2.x BASH auto completion on CYGWIN
I just figured out how to turn on auto completion for Maven 2.x commands from my cygwin shell on WinXP using bash_completion. The Apache Maven site is getting flushed out with documentation, and they've put up a mini guide for Maven 2.x auto completion. However, it didn't work out the box.
To fix it, I had to:
1) Run the cygwin's "setup.exe" and add the "bash-completion: Bash completion enhancements" package (version 20060301-2) to my cygwin install (bash v3.2.9-10 was already installed).
2) Configure the cygwin bash shell to use bash_completion. I found out how to do this from the cygwin-announce mailing list archive, but I extended their notes to apply the change to all users. It's not enabled by default, even after it's installed, so to add bash_completion for all users, you have to manually edit the /etc/bash.bashrc (usually at "c:/cygwin/etc/bash.bashrc") and add this line:
source /etc/bash_completion
3) Get the auto completion script and follow the instructions to install it to the file:
/etc/bash_completion.d/m2
4) Now, fix a bug in the script which keeps it from running on cygwin. This is the bug:
mvn ecl[TAB]-bash: ${ COMP_WORDS[COMP_CWORD]}: bad substitution
Fix it by editing /etc/bash_completion.d/m2 and changing this line (removing the extra space):
cur=${ COMP_WORDS[COMP_CWORD]}
to this:
cur=${COMP_WORDS[COMP_CWORD]}
Restart the xterm for this to take effect. Now, when you type:
mvn eclip[TAB]
the auto-completion will turn it into:
mvn eclipse:eclipse
Other Maven commands will auto-complete as well. You can add commands for new plugins by editing the m2 file. If you want to really make the auto-completion command set scale for Maven commands, checkout how it's done in GlassFish by Harsha. He has a commands.txt file that is read by the bash_completion.d script for GlassFish. The same thing could be setup for Maven commands.
Yay for saving the fingers from some typing!
Posted at 03:27PM May 28, 2007 by jason in Software |
Updated CAPTCHA for AppFuse
jCaptcha has just released their 1.0-RC4 release, and pushed it to the central Maven repository at ibiblio! Since this greatly simplifies the configuration of jCaptcha for AppFuse, I've updated my guide.
At the same time, AppFuse has moved to development of 2.0-M5, and made some final updates to 2.0-M4. This guide has been updated to work with the final revisions of M4, out of the box.
Get the updated zip with the feature-patch: appfuse-captcha-2.0-M4.zip
This document provides instructions on adding CAPTCHA support to an AppFuse project. It is based on AppFuse 2.0-M4.
Addition of CAPTCHA is as simple as unzipping the appfuse-captcha-2.0-M4.zip file into your "myproject" directory, and editing one pom.xml file.
Versions Used
AppFuse-CAPTCHA 2.0-M4
AppFuse 2.0-M4
jCaptcha 1.0-RC4
Maven 2.0.5
Resources
Questions about this guide can be sent to Jason Thrasher jason-AT-coachthrasher.com. General AppFuse support is available at the http://appfuse.org/ website. Support for jCaptcha can be found at the http://jcaptcha.sourceforge.net/ website.
Assumptions
This integration guide is based on the AppFuse QuickStart guide, using a Struts 2 Modular project. It's assumed that you will create an AppFuse project called "myproject" with some package "com.mycompany". It's also assumed that you've followed the AppFuse QuickStart guide and are running MySQL already.
This will work for an AppFuse Struts 2 Modular project archetype. Other archetypes aren't supported, but the included files should be easily adaptable based on your requirements. It's assumed that you've just created a new project using Maven, and haven't edited or modified any of the base files. (If you've already started developing your Struts 2 Modular project, check everything into a source control management system to better visualize changes with this feature.)
It's a good idea to check all of your files into source control before unzipping appfuse-captcha-2.0-M4.zip into your project so you can see what files changed, and how they changed. A list of files modified and added can be found below.
Conventions
Change these mnemonics based on your needs:
DEV_HOME = your base development directory, where all of your projects live
com.mycompany = your package name
myproject = your project name
Adding CAPTCHA Support
Create a modular Struts2 based AppFuse project using:
cd $DEV_HOME
mvn archetype:create \
-DarchetypeGroupId=org.appfuse \
-DarchetypeArtifactId=appfuse-modular-struts \
-DremoteRepositories=http://static.appfuse.org/repository \
-DarchetypeVersion=2.0-m4 \
-DgroupId=com.mycompany \
-DartifactId=myproject
Test that your project builds using:
cd $DEV_HOME/myproject
mvn install
Unpack the AppFuse war into your new project, and test that the webapp runs:
cd $DEV_HOME/myproject/web
mvn war:inplace
mvn jetty:run-war
Open a web browser and use the Signup page to create a new user account. Everything should work at this point, use Ctrl-C to stop Jetty. If everything builds correctly, you can continue, otherwise, consult the http://www.appfuse.org website for how to fix it.
Clean things up before adding CAPTCHA support:
cd $DEV_HOME/myproject/web
mvn clean
Note: it is important to run the "maven clean" goal, otherwise the web app will use the old files in the /target directory without picking up the changes you are about to make.
Add a new dependency in the pom.xml file for jCaptcha. Edit the $DEV_HOME/myproject/web/pom.xml file, adding (at about line 200):
<dependency>
<groupId>com.octo.captcha</groupId>
<artifactId>jcaptcha-all</artifactId>
<version>1.0-RC4</version>
<scope>compile</scope>
</dependency>
Unpack this zip file's contents into your Struts 2 Modular base directory.
cd $DEV_HOME/myproject
unzip appfuse-captcha-2.0-M4.zip
Run Jetty again:
cd $DEV_HOME/myproject/web
mvn clean jetty:run-war
Open firefox and browse to the signup page again: http://127.0.0.1:8080/signup.html. You should be greeted with a CAPTCHA challenge. If so, congratulations, CAPTCHA has been added to your project!
Known Issues
The Canoo Webtest for the Signup page fails. Running the web integration-tests using Maven will fail because the Signup page is made inaccessable due to the addition of the CAPTCHA. If this a feature, or a bug? It's an excereise for the reader to fix this webtest by editing the $DEV_HOME/web/src/test/resources/web-tests.xml file. Maven will result in errors when these commands are run:
cd $DEV_HOME/myproject/web
mvn integration-test
# or simply:
mvn
Appendix
Here are the details of the changes that are made, excluding pom.xml modifications:
These files are modified:
M web/src/main/resources/ApplicationResources.properties
M web/src/main/resources/struts.xml
M web/src/main/webapp/WEB-INF/applicationContext-struts.xml
M web/src/main/webapp/WEB-INF/security.xml
M web/src/main/webapp/WEB-INF/web.xml
These files are added:
A web/src/main/java/org/appfuse/webapp/JCaptchaServiceProxyImpl.java
A web/src/main/java/org/appfuse/webapp/action/CaptchaAction.java
A web/src/main/java/org/appfuse/webapp/servlet/ImageCaptchaServlet.java
A web/src/main/resources/org/appfuse/webapp/action/CaptchaAction-validation.xml
A web/src/main/webapp/WEB-INF/applicationContext-captcha.xml
A web/src/main/webapp/WEB-INF/pages/captcha.jsp
Posted at 08:40PM Mar 30, 2007 by jason in Software |