Showing posts with label jruby. Show all posts
Showing posts with label jruby. Show all posts

Tuesday, February 15, 2011

MagicRuby Roundup

Last week, I attended the MagicRuby conference in Orlando.  Aside from all the content in the talks, I learned three important things:
  1. Rubyists are always trying something new and interesting.
  2. Disney World is a great place to hold a conference.
  3. Orlando has a fun and enthusiastic Ruby community!
I saw a lot of great talks at this conference.  I'm attempting to condense 30+ pages of notes into only the most important information.  I'll tell you (a) where to find slides/video, (b) who I think should check out each talk, and (c) what I think the most important points are.

This doesn't include every talk, but it includes most of them.

----------

Cultivating Cucumber  (Slides)
Les Hill, Hashrocket

Who should check it out?
  • Developers interested in improving TDD and BDD practices.  
  • Developers unsure of whether to use Cucumber.
Short take:
  • Great summary of the features of cucumber:  Hooks, tags, steps, and more!
  • Good explanation of Cucmber's strengths (like the use of natural langage) and its weaknesses (like the need to maintain all those regexes)
  • Good discussion of best practices for organizing and refactoring cucumber suites.
  • I wish there was more discussion about the types of projects where cucumber is most useful.

----------

Geospacing Your Ruby (Slides)
Peter Jackson, Intridea

Who should check it out?
  • Developers of spatially-enabled apps
  • Developers working in government, urban planning or environmental modeling.
  • Database Administrators (for those of you in the enterprise)
  • Geography/map buffs.
Short take:
  • Great overview of spatial terms, geometry, map types, etc.
  • Great overview of existing database and front-end tools for spatially-enabled apps.
  • Good suggestions for interesting spatial data to model and useful ways of displaying it.

----------

Loving your Customers, Loving your Peers (No slides available)
Alan Johnson, Carsonified

Who should check it out?
  • Technical people who deal directly with customers
  • People who want to improve the reputation of the Ruby community
Short take:
  • A "feel good" presentation, rife with humorous anecdotes and pop culture references.
  • A good reality check for developers who are quickly dismissive of non-ruby technologies, Microsoft, etc.
  • Lots of great suggestions on how to treat customers better, how to empathize with customers, and how to enjoy your job more.

----------

Code is not Enough (No slides available)
Gregg Pollack / Caike Souza, EnvyLabs

Who should check it out?
  • Entrepreneurs
  • Freelancers
  • Software development shop owners
  • Employees of small companies
Short take:
  • Good commentary on many important engineering management concepts:  Setting expectations, delegating tasks, etc.
  • A good discussion on software development as a craft vs an art.
  • Good suggestions for developers, like "don't be afraid to ask for help" and advice on how to "get in the zone" while programming.
  • Great advice on creating a culture of learning at your organization (especially the "book club" suggestion)
  • Good insight into effective networking and "making friends rather than sales"
  • Asserted that developing a product for another company is more difficult than developing and launching your own product (I don't necessarily agree)

----------

Exceptional Ruby (Slides and More)
Avdi Grimm

Who should check it out?
  • Just about any Ruby developer.
Short take:
  • Good review of exception syntax and handling in Ruby.
  • Great discussion on when to use exceptions in the first place ("exceptions are for exceptional situations")
  • Review of many design techniques for handling and managing exceptions
  • Reviewed some common software design pitfalls related to exceptions.

----------

What happened to Desktop Development in Ruby? (blog post)
Andy Maleh, Obtiva

Who should check it out?
  • Developers interested in desktop applications
  • Developers interested in the current state of desktop application programming in Ruby.
Short take:
  • Great review of current desktop development frameworks:  shoes, wxWidgets, Limelight, Glimmer
  • Excelent insight into what's wrong and what's right with each framework.
  • Great perspective on what makes a well-designed desktop app framework.

----------

Keynote (No Slides Available)
Dave Thomas, Pickaxe Author

Who should check it out?
  • Dave Thomas fans
  • Project managers and developers looking to improve software development methodologies.
Short take:
  • Great review of what it really means to practice "agile" development.
  • Insightful  recursive algorithm for software development:  Where do we want to be?  Where are we now?  How do we improve our position? Repeat. 
  • Good use of a one-wheel balancing robot as a metaphor for prioritizing and executing incremental software changes.
  • Advocated the "ten second audit" for developers:  Why am I doing this?  Does it have to be done this way?  Does it have to be done at all?
  • Insightful, humorous commentary on overzealous cucumber evangelists and constantly-changing tools in the Ruby community. 

----------

Crank up your Apps with Torquebox (Slides and Video)
Jim Crossley, Red Hat

Who should check it out?
  • Enterprise developers who want to work with Ruby but must develop in a Java ecosystem
  • Developers challenged with building scalable, distributed web applications.
Short take:
  • Good overview of everything Torquebox:  Configuration, JBoss, messaging, queues, processors, services, scaling techniques, and more.
  • Good discussion of use-cases for Torquebox, its performance, and potential future changes.

----------

How I Lerned to Stop Worrying and Love the Cloud (Slides)
Wesley Beary, Engine Yard

Who should check it out?
  • Developers currently using or interested in cloud-based infrastructure.
  • Anyone overwhelmed by the choice of cloud providers.
Short take:
  • Great overview of Fog, a vendor-agnostic cloud interface that works with many popular providers, such as EC2 and Rackspace.
  • Discusses many good use-cases for Fog.
  • Helpful, tutorial-style explanation of how to use Fog to interface with a cloud provider.

----------

Documentation is Freaking Awesome (Slides and More)
Kyle Neath, Github

Who should check it out?
  • Open-source authors.
  • Any developer who might, at some point in the future, hand off their project to someone else.  :)
Short take:
  • Very straightforward, "common-sense" talk about why documentation will help your project.
  • Discussed many useful ways to improve documentation, covering everything from the README to RDoc to Yard to "Having an awesome web page."
----------

Please let me know if there are any errors, of if you can point me to any slides that are currently missing!

Tuesday, August 31, 2010

Turn your Android Phone Into a Remote Spy Camera with Ruby in 15 Minutes

Update 8/20/12: This project is over two years old at this point, and I am no longer working on it.  This was a proof of concept and, unfortunately, I am no longer able to provide support to readers with questions.

It's been a great year for Ruby on Android, but no one knows it.

Sinatra running on a Motorola Droid

You can start writing Ruby apps for Android devices TODAY.  You don't need to install any SDK, you don't need to install some giant Eclipse IDE, and you certainly don't need to write any Java.

Some of you may have heard of Ruboto, but Damon Kohler and the team at android-scripting have been quietly improving SL4A over the past year, adding tons of features and improving stability.
Scripting Layer for Android (SL4A, formerly known as Android Scripting Environment or ASE) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface that makes it easy to get things done...  Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported, and we're planning to add more.
There's even support for distributing  programs as APKs, so the implementation language and dependencies are totally transparent to users.

We'd love to run some simple Ruby scripts on Android, but what about running a complete, albeit simple, application?  Will it work?

Most Rubyists use Ruby to build web applications, so let's run with that.  Let's build a spy camera app, so I can figure out who's been stealing ink cartridges from our office.  The app should (a) show me a snapshot of what the camera currently sees and (b) update that snapshot on demand.

We need a simple, lightweight ruby framework to use. Sinatra is very easy to use and should even be able to run on older Android devices.

Similarly, we need a simple, lightweight, pure ruby web server.  WEBrick is pure ruby, part of the standard library, and fast enough to run on Android.  Works for me!

First, let's work from our development machine (i.e. laptop).  No need to touch the phone just yet.

Start a New Sinatra Project



But wait!  What about Sinatra itself?  We can't easily install rubygems on our Android phone, so we'll have to vendorize Sinatra and all dependencies and ship them with our application.  Since we'll be running JRuby on Android, we can't use any libraries that have native C extensions or are otherwise JRuby-incompatible.

Make Directories for Gems and Snapshots



Vendorize your Gems



Create the App

Create a file called spycamera.rb in the project directory.

First, let's set some constants for the important directories in our application. When running apps under SL4A, we need to be very explicit about directory paths.



Let's update our load path, so JRuby can find our vendorized gems.


Next, we'll load Sinatra.  We'll have to explicitly load rack first, to avoid uninitialized constant errors under SL4A.



Finally, we require the Android API interface, available under SL4A, and initialize an Android object.  This will allow us to make API calls, like one that tells the camera to take and store a picture.




Now, let's create a very simple HTML template.  The template should just display the latest snapshot, which we'll be saving to public/latest.png.  If I click on that snapshot, it should take a new snapshot and refresh the page.



Finally, create a tiny Sinatra app that takes a picture, saves it, and renders the template.



Install (Deploy) The App

Now you can finally use your phone!  Grab that Android device and install SL4A (r1 APK available here).  Run SL4A, go to the interpreters menu, and install JRuby.

Once JRuby is installed, it's time to deploy your application to the phone.

Connect your phone to your development machine via USB, and simply copy the contents of your app to SL4A's script directory on your phone.  There may be some sample ruby scripts left over from the SL4A install; you can delete them if you like.

Copying the project contents onto the deivice.

At this point, just run spycam.rb from SL4A and you're good to go!

Starting the Sinatra app from SL4A

Place your newly-activated spy camera somewhere, hide in your office/cube, start your web browser, and navigate to http://ip.address.of.phone:4567.  You can do this from inside your local network via wifi, or, carrier permitting, over 3G.

Happy spying!

Further Reading
Check out my open-source project, Broadcast, on Github.  It's a more refined, general-purpose embedded web app for Android.  It allows for further remote monitoring and control, such as location tracking, remote text-to-speech, and remote file management over HTTP.  


The source code for the spycam app is available on github here.


Check these out, too:

Tuesday, August 24, 2010

Broadcast Presentation at RIRUG

Slides are up from my August presentation at RIRUG. I'm really excited about this software; more posts to follow shortly!