Thursday, June 30, 2011

Something to crow about: Gson Json code generator

Gee Whiz--this is a real time save. Gson is a google project to serialize and deserialize json data. Good enough. The problem is that to do this you really want to drop the deserialized output into a java object for further processing.

There are some generalized object containers out there, but these didn't really do what I was looking for. Guess what I wanted was something lite and easy--no go.

So, here's the whizbang part. This site takes your json, such as:

Saturday, June 18, 2011

Network monitoring

I'm on a bit of R and R right now. Have to burn through the vacation time somehow. Earlier, this year I made a point of pushing at least one new blog entry per week. Seems like I missed this week for the first time in a while.

So, perhaps, just to make me feel "whole", here's a link to an article I wrote for Dr. Dobbs a few years back which describes a framework for network monitoring. Basically a cascading set of filters and processors (pipeline), which threading support in each filter manager:

The SecureScout Wi-Fi Security & Monitoring Framework

Thursday, June 9, 2011

How to set up an email smtp client to work with smtp.gmail.com

There's a bunch of implementations out there that don't work (possibly outdated or just plain broken. So, that's why I'm publishing this today--so I have a handy reference when I need it again.

Anyways, this one DOES work using gmail as the smtp agent.

Enjoy.


String host = "smtp.gmail.com";
  int port = 587;
  String username = "your_gmail_login";
  String password = "your_password";
  String from = "support@belisarius2000.com";

  Properties props = new Properties();
  props.put("mail.smtp.starttls.enable", "true");
  props.put("mail.smtp.host", host);
  props.put("mail.smtp.user", username);
  props.put("mail.smtp.password", password);
  props.put("mail.smtp.port", "587");
  props.put("mail.smtp.auth", "true");


   Session session = Session.getInstance(props,new 
     GMailAuthenticator(username, password));

   Message message = new MimeMessage(session);
   message.setFrom(new InternetAddress
      ("support@belisarius2000.com"));
   message.setRecipients(Message.RecipientType.TO,
      InternetAddress.parse(email));
   message.setSubject("Hey there dude!");
   message.setText
      ("Here's the body of my email, blah blah blah");
 
   Transport transport = session.getTransport("smtp");
   transport.connect(host, port, username, password);
 
   Transport.send(message);


And this class too...

class GMailAuthenticator extends Authenticator {
  String user;
  String pw;
  public GMailAuthenticator (String username, String password)
  {
    super();
    this.user = username;
    this.pw = password;
  }
  public PasswordAuthentication getPasswordAuthentication()
  {
    return new PasswordAuthentication(user, pw);
  }
}

Wednesday, June 8, 2011

Steve Job's spaceship

Wow--just had a chance to watch the Cupertino city council presentation by Steve Jobs last night. Did he have them eating out of his hands or what? I had a couple of thoughts, obviously this guy really has a vision. And second these city council reps came off as a bunch of sycophants--what's the point of asking for an ipad for every resident of the Cupertino, or an Apple store for Cupertino. Kind of laughable.

But back to the spaceship. It seems like Apple is really on a roll here. It's a battle between the Big Three: Google, Apple and Facebook for new employees. So, this definitely ups the bidding. I wouldn't be surprised if in the basement there's booster rockets and cryogenic pods to blast off into space once this planet turns into a dustbowl (maybe from too many ipads?) a la Silent Running.



And the video

Thursday, June 2, 2011

A C++ Boost client for the Vyatta REST api

Here's a Vyatta REST client I modifed from a stock Boost https client example. In some tests a while back I found that using a remote command line client implemented in C++/c was significantly faster than using a scripted Perl implementation, which makes sense when latency isn't the overwhelming factor in the latency of the response. And as I alluded to, with claims of performance there are other important criteria that come into play, such as latency, jitter, response time on the server, etc. Needless to say I my queue (somewhere) a pending post to quantify this performance difference using different client implementations.

You can see from the help that the executable requires the target, url (i.e. command), and optionally password/username to run.

Usage: vyatta_boost   [options]
  -h  host name or ip
  -c  rest api command path
  -m  HTTP method (i.e. GET, DELETE, POST, PUT)
  -u  username
  -p  password

And running this command: