Musings of a Software Inventor, or, THE LACK THEREOF

TLT

META INFORMATION: This is the technical blog and wiki of Brock Wilcox (awwaiid). Entries focus on my current projects, interests, and sometimes life events. If you'd like you can check out the list of All Entries or the RSS Feed. I also have a LiveJournal syndication feed for LJ friends.


2010.02.07 Cultured Perl

Tags: Perl

You might have stumbled upon some IBM developerWorks articles titled "Cultured Perl" while googling for random things. I think it's awesome and that it isn't linked to enough. Just a few weeks ago the latest article came out, Cultured Perl: Storage management on Amazon S3, which is well written and up-to-date with the latest technologies.

Thank you, Cultured Perl!

0 Add Comment


2009.12.16 Better Creox Example

So I was right, I completely messed up the previous example and it wasn't electrified by Creox at all. But I've rectified this situation, and for your listening pleasure (pain?), here is a smaller snippet of just the guitar part of the song, before-and-after.

Original acoustic guitar (mp3 file)
Electrified by Creox (mp3 file)

0 Add Comment


2009.12.06 Music Play

I was playing with Creox the other day, which can make an acoustic guitar sound electric (amongst other things). I recorded a quick song... but it doesn't sound nearly as electric when I listen to it now as it did when I first recorded it (and now I wonder if I even had my Jack settings right for recording what I was hearing...). But it did end up with a fun crackly sound on the voice I think. Listen for yourself:

"Oh my baby" (mp3 file)

And it gave me an excuse to add an mp3 player plugin :)

0 Add Comment


2009.11.15 The Internets Make Programming Easy

In the class I'm taking (Intro to Data Mining) we get to implement a classifier. Alas... we must use either C++ or Java. I haven't programmed in either for quite a few years, and even with further pursuit I'm not allowed to use OCaml.

That's OK! Best to stretch my mind out a bit. I'm afraid I'm getting rusty at being multi-lingual in my old age anyway, so this is good exercise. First thing first, I have to read in the training data. But best start with the basic Hello World even before that. Google... I figure I'll start with the basics, and now I have:

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!" << endl;
  return 0;
}

I don't even remember doing that std namespace thing last time I programmed in C++. Oh well. It runs! So from there I just keep searching and adding...

... and just like magic I am now reading the file, parsing it, and counting the frequency of items. Ahh the hive mind! Here's the result... it's messy and unstructured but damn... it works!

// Compile: g++ -o demo main.cpp
#include <iostream>
#include <fstream>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <map>

using namespace std;

typedef map<string, int> ItemSet;

int main() {
  cout << "Hello World!" << endl;
  ifstream fin("data/train1.txt");
  // ifstream fin("data/small_train.txt");
  string s;
  vector< vector<string> > d;

  ItemSet itemset;

  while(getline(fin,s)) {
    vector<string> row;
    // cout << "Read from file: " << s << endl;
    boost::split(row, s, boost::is_space());
    d.push_back(row);
  }

  vector< vector<string> >::iterator d_iter;
  vector<string>::iterator row_iter;

  for(d_iter = d.begin(); d_iter != d.end(); d_iter++) {
    cout << "[ ";
    for(row_iter = d_iter->.begin(); row_iter != d_iter->end(); row_iter++) {
      cout << *row_iter << " ";
      itemset[*row_iter]++;
    }
    cout << "]" << endl;
  }

  cout << "Itemset:" << endl;

  ItemSet::iterator itemset_iter;
  for(itemset_iter = itemset.begin(); itemset_iter != itemset.end(); itemset_iter++) {
    cout << itemset_iter->first << " : " << itemset_iter->second << endl;
  }

  return 0;
}

I'll keep going like this for a bit, but then I'll start organizing into actual objects and such. There is a good chance that I'll switch data structures, or perhaps not even bother keeping all this in memory. Most likely I'm also violating some other C++ socio-political norms. Fun!

0 Add Comment


2009.08.25 Trace With State

I've got to get this idea written down so that I can go back to doing other things... it is too distracting as-is.

In a nutshell -- more or less Devel::Trace except that at each step you record all of the lexical (global?) state. Then you can not only see the full execution history of your program, but the value of every variable at every point.

Now of course from the idea comes all of these questions -- do we store all that or just some of it (just what changes). Do we only keep local lexical scope at each step since the rest can be reconstructed? How do we record this... do we summarize it somehow? And so on.

But ignoring all that... the next idea that comes to my mind is to toss this into CGI::Inspect as a module, so that you can use the GUI browse not just the current lexical state (there is already a plugin for that), but also the complete historical state as well.

I got the idea from the Omniscient Debugger, but I'd actually seen it before in its more highly evolved form in the OCaml Debugger. The OCaml Debugger doesn't have to actually save all that state though, since in a lovely functional language you can actually just reconstruct the previous state (I believe). Still.

(If you're still reading and want something even MORE insane, then your homework is to use Nothingmuch's delimited continuations in perl and make it so that you can actually resume any of the historical states).

Code might eventually show up at http://thelackthereof.org/projects/perl/Devel-TraceState or perhaps Devel-TraceState.

0 Add Comment


2009.08.25 Now I Have A Real Blog

I was just exploring the latest and greatest Oddmuse modules, and see that someone made it easy to embed youtube/google videos. So now I feel like I have a real blog and I can post the random crap that everyone else does! To prove it, here is a totally awesome song my friends turned me on to:

0 Add Comment


2009.05.08 Pause My Music

Tags: perl, linux, music

Oh how I love linux... perl... scriptability. I have a fun little command line music player named Polly. It is pretty minimalist, really just starting whatever player I like with whatever preferences I like on a whole directory tree of files. One thing that is annoying is that I have to switch over to the terminal and it ^Z to pause and then do 'fg' to play.

So I finally decided to write a simple pause toggle script. I approached this in the most brute force way I could... I just take the list of all my media players and send a massive STOP (effectively ^Z) command to all to pause, and then a massive CONT (effectively 'fg') to all to continue. To determine if I want to pause or continue, I just look to see if I have any paused player processes.

my @commands = qw( ogg123 mpg123 mplayer vlc sidplay2 );
my $cmd = join '\|', @commands;

if(`ps a -o state,cmd | grep '$cmd' | grep ^T`) {
  map { `killall -SIGCONT $_ 2>/dev/null` } @commands;
} else {
  map { `killall -SIGSTOP $_ 2>/dev/null` } @commands;
}

0 Add Comment


2008.11.29 DNA Memory

Scott linked an article from new scientist, Memories may be stored on your DNA, which relates with what has been on my mind lately.

I was reading about some hardware evolution experiments while at the bookstore the other day. They were using a FPGA to create (evolve) a sine wave generator, if I recall correctly. The end result of the first run worked perfectly, but had some bizzare attributes -- it programmed a section of the gate array but didn't wire that section to the rest. When the unconnected section was turned off, the circut no longer worked. It also didn't work when the same design was put onto an identical FPGA. As far as the experimenters could tell, the evolved solution depended upon some subtle property of that specific FPGA chip.

In other words: GP solutions cheat like hell.

They will use absolutely any available subtle or side-effect aspects of environmental conditions to push themselves to the next rung on the fitness ladder. An important lesson that I've taken from GP is that artificial / automatic program generation mostly results in programs that make almost no sense from a human programmer perspective, at least partly because of all this cheating. The solutions produced by GP are mostly twisted convoluted things which mostly don't look like they work at all, let alone solve anything.

When a human abstracts things, it ends up taking a much more layered structure, with the meat of the problem usually ending up on the highest layer. Automatic techniques do not succumb to such niceties.

Speaking of human abstraction, I recently stumbled upon the Discordia page of Mark-Jason Dominus which makes a keen observation with fascinating attributes - "In a well-designed computer program, No two components are alike, or even similar." Conceptually, that is, all similar aspects of a program are abstracted. Good programs are themselves not like the beautiful fractals of recursion that lay in the mind of their creator or the algorithms that they represent. You could perhaps think of them as the compressed version -- the most informationally dense form of the logic, information theory might say.

Now take it full circle... from the biological inspired computation back to biology. Biological evolution cheats just like artificial evolution does. At first glance we see all this lovely DNA-level abstraction... but as they dig in they find all sorts of trickery that operates on all levels low and high. Like throwing in some assembly (or even better, some binary executable blobs) into the middle of my blog software. The re-use of DNA (or perhaps the coating on DNA was it?) as memory storage in the brain is completely typical.

If the designers were indeed intelligent and sought homework help, they sure didn't plan on doing any maintenance.

Comments on TLT - 2008.11.29 - DNA Memory

2 Comments.

Thanks for adding links!

-- awwaiid 2009-06-13 04:00 UTC


You're very welcome. I hope that clears it up for future readers.

-- Mortal 2009-06-13 22:08 UTC

2 Add Comment


2008.10.21 Slow Android Development

It's been over 4 hours since Android was released... but still no port to the Neo. Pft.

0 Add Comment


2008.07.24 OSCON Lighnting Talk

At the last minute I ended up giving a Lightning talk at OSCON 2008 (in the Perl track). I showed my Devel::REPL + Continuity debugging tool.

Here are my notes:

Lightning Talk OSCON 2008

Brock Wilcox
awwaiid@thelackthereof.org

See also:
* Continuity
* Continuity::REPL
* Devel::REPL
* Carp::REPL
* PadWalker

# .... These were then run in the REPL ....
# counter.pl at:
#   http://thelackthereof.org/projects/perl/Continuity-Monitor/eg/counter.pl

use PadWalker 'peek_my';
my $h = peek_my 23;
${ $h->{'$counter'} } = 77;

# Then...

sub new_prompt {
  my ($request) = @_;
  $request->print("Muahahaha!");
  return old_prompt(@_);
}

*old_prompt = *prompt;
*prompt = *new_prompt;

0 Add Comment

More...