Josh Adams is a developer and architect with over eleven years of professional experience building production-quality software and managing projects. Josh is isotope|eleven's lead architect, and is responsible for overseeing architectural decisions and translating customer requirements into working software. Josh graduated from the University of Alabama at Birmingham (UAB) with Bachelor of Science degrees in both Mathematics and Philosophy. He also occasionally provides Technical Review for Apress Publishing, specifically regarding Arduino microprocessors. When he's not working, Josh enjoys spending time with his family.
isitdownrightnow.com seems to be a step above 'downforeveryoneorjustme' in that it also searches twitter, other social networks for related commentary.
Got the LED Toggler Ruby script from last week exposing a toggle-able LED object over the network with drb under MRI on the Raspberry Pi.
Built an Android app.
Inside of that Android app I embedded a JRuby ScriptingContainer.
In that ScriptingContainer I evaluated some ruby.
In that ruby script I connected to the aforementioned drb object.
On button press in the Android app, I call the #toggle method of the drb object.
This all combines to have the effect of an android app to toggle an LED on the network. This is, of course, extremely awesome and extensible. See the video above for proof.
I'll also just put the relevant bits of code in the post here:
server.rb
require 'drb/drb'
require 'pi_piper'
# The URI for the server to connect to
URI="druby://192.168.1.76:8787"
class Toggler
attr_accessor :pin, :state
def initialize
@pin = PiPiper::Pin.new(pin: 15, direction: :out)
@state = false
end
def toggle
state ? pin.on : pin.off
@state = !state
puts 'toggled'
end
end
# The object that handles requests on the server
FRONT_OBJECT=Toggler.new
$SAFE = 1 # disable eval() and friends
DRb.start_service(URI, FRONT_OBJECT)
# Wait for the drb server thread to finish before exiting.
DRb.thread.join
MainActivity.java
package com.isotope11.ledclicker;
import java.util.ArrayList;
import java.util.List;
import org.apache.bsf.BSFException;
import org.jruby.embed.ScriptingContainer;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
protected final String TAG = MainActivity.class.toString();
protected ScriptingContainer mRubyContainer;
protected String mDrbResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.setProperty("jruby.bytecode.version", "1.5");
mRubyContainer = new ScriptingContainer();
List<String> loadPaths = new ArrayList<String>();
loadPaths.add("jruby.home/lib/ruby/shared");
loadPaths.add("jruby.home/lib/ruby/1.8");
mRubyContainer.setLoadPaths(loadPaths);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onLEDClickerClick(View view) {
RubyRunner rubyRunner = new RubyRunner();
rubyRunner.execute();
}
public void handleDrbResult() {
Toast.makeText(this, mDrbResult, Toast.LENGTH_LONG).show();
}
private class RubyRunner extends AsyncTask<Object, Void, String> {
@Override
protected String doInBackground(Object... arg0) {
String rubyDrbClient = "require 'drb/drb';SERVER_URI='druby://192.168.1.76:8787';DRb.start_service;toggler = DRbObject.new_with_uri(SERVER_URI);toggler.toggle";
String result = (String) mRubyContainer.runScriptlet(rubyDrbClient);
return result;
}
@Override
protected void onPostExecute(String result){
mDrbResult = result;
handleDrbResult();
}
}
}
Gistbox is 'the personal code library you've always wanted'. It looks really cool, but I couldn't get past it wanting to log in to github (just asked repeatedly). Still, putting it here because it looks so neat :)
signed_form avoids users passing in disallowed fields by really basic form parameter signing in the rendered html. Lots nicer and more sensible than rails 3's attr_accessible on models (what sense did that make?). Seems like just a really easy thing (though it does put the onus on the view designer for security, and seems easier to accidentally overlook on occasion)
More Gtk+ in the cloud. I've been following Alexander Larsson's work on the Broadway backend for GTK for years and it's getting seriously, seriously impressive.
E (programming language)) just a programming language for secure distributed computing. It's based on capabilities, which are a Big Deal if you want to build such a thing. I know @bascule is certainly pretty interested in capabilities.
mutations is a neat looking library for doing "UseCase" style stuff, where your controllers just run a "mutation" and return the result. If you see it and think it's neat, then you will. If you don't know what this sort of thing is for or you think it's lame, that's fine too :)
Adam pointed us to the Kerbal Space Program and people have gotten addicted since as I understand it.
datamappify is a Repository Pattern for ActiveRecord (and others)
CSS-Shack is a visual CSS designer for use in the browser.
If you're interested in Rails security, Bryan Helmkamp posted about Rails' insecure defaults. In the post, he mentioned http://rails-sqli.org, which highlights areas in which sql injection is possible in activerecord (and consequently you should take care not to send user input into).