<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CEUNR3g-fSp7ImA9WhVTEEw.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623</id><updated>2012-02-23T21:21:36.655+05:30</updated><category term="apache" /><category term="regex" /><category term="stackoverflow" /><category term="Flex" /><category term="redmine" /><category term="flex builder" /><category term="MenuBar" /><category term="Icons" /><category term="gstreamer" /><title>Ghosh blog</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://amarghosh.blogspot.com/" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/amarghosh" /><feedburner:info uri="amarghosh" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DU4BR3Y5eCp7ImA9WhRVFEo.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-4936798684426496632</id><published>2012-01-13T23:35:00.000+05:30</published><updated>2012-01-13T23:35:56.820+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-13T23:35:56.820+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="stackoverflow" /><category scheme="http://www.blogger.com/atom/ns#" term="gstreamer" /><title>gstreamer appsrc in action</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Lately I have been exploring gstreamer to play AV from a transport stream demultiplexer that I am developing (mostly for fun, slightly for work). After some research (read googling for play video using gstreamer), I concluded that &lt;a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsrc.html"&gt;gstreamer-appsrc&lt;/a&gt; is the way to go. Since I had a hard time finding a working example in the Internet on using this plugin, I thought I would share my test application here. If you are new to gstreamer, keep in mind that I am only couple of days ahead of you and I might have overlooked or missed even basic things in this post; and if you in fact know gstreamer, feel free to mention any such omissions you notice here so that I can correct them.&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
Here is a quick intro to gstreamer for new comers. It is a media framework based on plugins - you can read &lt;a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/part-introduction.html"&gt;all about gstreamer here&lt;/a&gt;. That page says prior knowledge of glib and gobject is assumed; while proper knowledge of these two will help you progress faster, I didn't know either and I survived. The point is, you can (and you have to) learn those parallelly. In a nutshell, you work on a gstreamer &lt;i&gt;pipeline &lt;/i&gt;which is basically a series of plugins where each one takes its input from the previous plugin, does something with it and gives the output to the next one. The data is passed around in &lt;i&gt;buffers &lt;/i&gt;through the &lt;i&gt;source &lt;/i&gt;and &lt;i&gt;sink pads &lt;/i&gt;of the plugins. Usually at the left end of a pipeline there will be a pure source (like filesrc that reads data from a file and feeds the pipeline) and the last one would be a pure sink that plays the media. The typical steps in creating a gstreamer based player can be summarized as:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Create your elements and set their properties, signal handlers and callbacks&lt;/li&gt;
&lt;li&gt;Add them to a bin (pipeline is a bin)&lt;/li&gt;
&lt;li&gt;Get a reference to the bin's bus and add bus callback for messages - at the minimum, an application should handle error messages and end of stream messages so as to stop the main loop on error and &lt;i&gt;eos&lt;/i&gt;.&lt;/li&gt;
&lt;li&gt;Link their source and sink pads in the correct order&lt;/li&gt;
&lt;li&gt;Set the state of bin to playing and start the glib main loop.&lt;/li&gt;
&lt;/ol&gt;
You can find a &lt;a href="http://felipec.wordpress.com/2008/01/19/gstreamer-hello-world/"&gt;gstreamer helloworld application and its explanation here&lt;/a&gt;. It uses a playbin, a readymade pipeline that does most of the work for us. It is good enough as long as you are not producing any media. But if you are producing some media data in your application and you need to play it using gstreamer, you need a way to feed this data to the pipeline. That is where &lt;i&gt;appsrc &lt;/i&gt;comes into picture. The appsrc element allows applications to inject buffers into a pipeline.&lt;br /&gt;
&lt;br /&gt;
There is this &lt;a href="https://gist.github.com/725122/16ceee88aafae389bab207818e0661328921e1ab"&gt;gstreamer appsrc example code&lt;/a&gt; in github, but unfortunately it didn't work for me - and based on the comment in that page, I am not the only one. It uses udpsink to stream data over a network. Since I just wanted to play it on my desktop, I replaced it with an xvimagesink which is used by most of the desktop based gstreamer video examples. But that didn't make any difference either - whenever I run the code, it exits with the following error:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;ERROR from element mysource: Internal data flow error.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;Debugging info: gstbasesrc.c(2582): gst_base_src_loop (): /GstPipeline:pipeline0/GstAppSrc:mysource:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;streaming task paused, reason not-negotiated (-4)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As usual I resorted to &lt;a href="http://stackoverflow.com/questions/8746719/gstreamer-appsrc-test-application"&gt;StackOverflow for an answer&lt;/a&gt;, but apparently there aren't many gstreamer enthusiasts roaming in there. After earning my first &lt;a href="http://stackoverflow.com/badges/63/tumbleweed"&gt;tumbleweed badge&lt;/a&gt; for this question, I decided to do it myself. I started with this &lt;a href="http://www.offminor.de/gstreamer-avi.html"&gt;simple gstreamer AVI player&lt;/a&gt;. It uses the following pipeline:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;filesrc -&amp;gt; avidemux -&amp;gt; decodebin -&amp;gt; customfilter -&amp;gt; ffmpegcolorspace -&amp;gt; videoscale -&amp;gt; autovideosink &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This pipeline is sort of self explanatory. The &lt;i&gt;filesrc &lt;/i&gt;reads the avi file and passes the data to the demux where it gets split into audio and video. To keep things short, let us ignore audio. The video data is decoded in &lt;i&gt;decodebin &lt;/i&gt;and the raw data is processed further and displayed using the last three plugins (gotta admit that I don't know nittygritties of those three; there are detailed websites out there explaining them - help yourself). If you look at the code in that page, you can see that not all the elements are linked together at the beginning. This is because in some plugins the source (output) pads are created dynamically based on the input data. So you have to listen for appropriate signals like &lt;i&gt;pad-added&lt;/i&gt; on such elements and do the linking from the callbacks.&lt;br /&gt;
&lt;br /&gt;
Since we are dealing with mpeg video, we don't need &lt;i&gt;avidemux&lt;/i&gt;. And we can replace &lt;i&gt;videoscale &lt;/i&gt;and &lt;i&gt;autovideosink &lt;/i&gt;with an &lt;i&gt;xvimagesink &lt;/i&gt;for the sake of brevity. So it comes down to replacing &lt;i&gt;filesrc &lt;/i&gt;with an &lt;i&gt;appsrc &lt;/i&gt;and feeding the data to the decoder. Let us create the elements:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: c"&gt;/* Start by creating a new pipeline and the elements */
app-&amp;gt;pipeline = (GstPipeline*)gst_pipeline_new("mypipeline");

/* Add bus callback */
bus = gst_pipeline_get_bus(app-&amp;gt;pipeline);
gst_bus_add_watch(bus, (GstBusFunc)bus_callback, app);
gst_object_unref(bus);

/* Add signal handlers on appsrc */
g_signal_connect(app-&amp;gt;src, "need-data", G_CALLBACK(start_feed), app);
g_signal_connect(app-&amp;gt;src, "enough-data", G_CALLBACK(stop_feed), app);


/* Create the elements */
app-&amp;gt;src = (GstAppSrc*)gst_element_factory_make("appsrc", "mysrc");
app-&amp;gt;decoder = gst_element_factory_make("decodebin", "mydecoder");
app-&amp;gt;ffmpeg = gst_element_factory_make("ffmpegcolorspace", "myffmpeg");
app-&amp;gt;xvimagesink = gst_element_factory_make("xvimagesink", "myvsink");

/* Add elements to the pipeline */
gst_bin_add_many(GST_BIN(app-&amp;gt;pipeline), (GstElement*)app-&amp;gt;src, app-&amp;gt;decoder, app-&amp;gt;ffmpeg, app-&amp;gt;xvimagesink, NULL);

/* Link them together - this should be done after adding to the bin */

if(!gst_element_link((GstElement*)app-&amp;gt;src, app-&amp;gt;decoder)){
    g_warning("failed to link src anbd decoder");
}

if(!gst_element_link(app-&amp;gt;ffmpeg, app-&amp;gt;xvimagesink)){
    g_warning("failed to link ffmpeg and xvsink");
}

/* Note that we haven't linked decoder to color-space element 
- that's done from pad-added signal callback. */
g_signal_connect(app-&amp;gt;decoder, "pad-added", G_CALLBACK(on_pad_added), app-&amp;gt;decoder);

&lt;/pre&gt;
&lt;br /&gt;
Applications can feed the data to appsrc plugin using two methods; by calling gst_app_src_push_buffer function or by emitting push-buffer signals. I used the first approach since I am not fluent with signals and it gave intermittent warning messages while running. We start by writing a read_data function that reads chunks of data from a global file pointer and creates a GstBuffer and pushes them to the appsrc.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: c"&gt;static gboolean read_data(gst_app_t *app)
{
    GstBuffer *buffer;
    guint8 *ptr;
    gint size;
    GstFlowReturn ret;

    ptr = g_malloc(BUFF_SIZE);
    g_assert(ptr);

    size = fread(ptr, 1, BUFF_SIZE, app-&amp;gt;file);
    
    if(size == 0){
        ret = gst_app_src_end_of_stream(app-&amp;gt;src);
        g_debug("eos returned %d at %d\n", ret, __LINE__);
        return FALSE;
    }

    buffer = gst_buffer_new();
    GST_BUFFER_MALLOCDATA(buffer) = ptr;
    GST_BUFFER_SIZE(buffer) = size;
    GST_BUFFER_DATA(buffer) = GST_BUFFER_MALLOCDATA(buffer);

    ret = gst_app_src_push_buffer(app-&amp;gt;src, buffer);

    if(ret != &amp;nbsp;GST_FLOW_OK){
        g_debug("push buffer returned %d for %d bytes \n", ret, size);
        return FALSE;
    }

    if(size != BUFF_SIZE){
        ret = gst_app_src_end_of_stream(app-&amp;gt;src);
        g_debug("eos returned %d at %d\n", ret, __LINE__);
        return FALSE;
    }

    return TRUE;
}
&lt;/pre&gt;
&lt;br /&gt;
The appsrc element emits mainly two signals namely &lt;i&gt;need-data&lt;/i&gt; and &lt;i&gt;enough-data&lt;/i&gt; to tell the application to start and stop feeding data. We need to listen to these callbacks. In the need-data callback, we add our read_data function as an idle handler to the main loop. The glib main loop will call this function from its main loop. When appsrc emits enough-data signal, we just remove this idle handler so that it is not called anymore. The boolean return value of read_data function is used by the main loop to decide whether to call it in the future - so we should return FALSE in case of any errors in pushing the data or we reach end of file.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: c"&gt;static void start_feed (GstElement * pipeline, guint size, gst_app_t *app)
{
    if (app-&amp;gt;sourceid == 0) {
        /* add idle handle to the main loop */
        app-&amp;gt;sourceid = g_idle_add ((GSourceFunc) read_data, app);
    }
}

static void stop_feed (GstElement * pipeline, gst_app_t *app)
{
    if (app-&amp;gt;sourceid != 0) {
        GST_DEBUG ("stop feeding");
        g_source_remove (app-&amp;gt;sourceid);
        app-&amp;gt;sourceid = 0;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
Now, start the pipeline, create a main loop and run it&lt;br /&gt;
&lt;pre class="brush: c"&gt;gst_element_set_state((GstElement*)app-&amp;gt;pipeline, GST_STATE_PLAYING);
app-&amp;gt;loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(app-&amp;gt;loop);

/* the previous call will return when we call quit from bus_callback - 
set the pipeline to null to do the cleanup */
gst_element_set_state((GstElement*)app-&amp;gt;pipeline, GST_STATE_NULL);
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
And that's it, we got appsrc working. The source should be compiled using appropriate cflags and libs - you can use package config for getting them.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;gcc -o testapp gst-testapp.c `pkg-config --cflags --libs &amp;nbsp;gstreamer-0.10 gstreamer-app-0.10`&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you get compiler or linker errors related to gstreamer, you probably don't have the necessary gstreamer development libraries installed. You can apt-get them using:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;sudo apt-get install libgstreamer0.10-dev&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;sudo apt-get install libgstreamer-plugins-base0.10-dev&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Here is the full source code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: c"&gt;/* 
  I don't know if it is syntax highlighter or blogger, but I can't seem to 
  put angle brackets around header file names properly.
*/
#include stdio.h
#include gst/gst.h
#include gst/app/gstappsrc.h

typedef struct {
 GstPipeline *pipeline;
 GstAppSrc *src;
 GstElement *sink;
 GstElement *decoder;
 GstElement *ffmpeg;
 GstElement *xvimagesink;
 GMainLoop *loop;
 guint sourceid;
 FILE *file;
}gst_app_t;

static gst_app_t gst_app;

#define BUFF_SIZE (1024)

static gboolean read_data(gst_app_t *app)
{
 GstBuffer *buffer;
 guint8 *ptr;
 gint size;
 GstFlowReturn ret;

 ptr = g_malloc(BUFF_SIZE);
 g_assert(ptr);

 size = fread(ptr, 1, BUFF_SIZE, app-&amp;gt;file);
 
 if(size == 0){
  ret = gst_app_src_end_of_stream(app-&amp;gt;src);
  g_debug("eos returned %d at %d\n", ret, __LINE__);
  return FALSE;
 }

 buffer = gst_buffer_new();
 GST_BUFFER_MALLOCDATA(buffer) = ptr;
 GST_BUFFER_SIZE(buffer) = size;
 GST_BUFFER_DATA(buffer) = GST_BUFFER_MALLOCDATA(buffer);

 ret = gst_app_src_push_buffer(app-&amp;gt;src, buffer);

 if(ret !=  GST_FLOW_OK){
  g_debug("push buffer returned %d for %d bytes \n", ret, size);
  return FALSE;
 }

 if(size != BUFF_SIZE){
  ret = gst_app_src_end_of_stream(app-&amp;gt;src);
  g_debug("eos returned %d at %d\n", ret, __LINE__);
  return FALSE;
 }

 return TRUE;
}

static void start_feed (GstElement * pipeline, guint size, gst_app_t *app)
{
 if (app-&amp;gt;sourceid == 0) {
  GST_DEBUG ("start feeding");
  app-&amp;gt;sourceid = g_idle_add ((GSourceFunc) read_data, app);
 }
}

static void stop_feed (GstElement * pipeline, gst_app_t *app)
{
 if (app-&amp;gt;sourceid != 0) {
  GST_DEBUG ("stop feeding");
  g_source_remove (app-&amp;gt;sourceid);
  app-&amp;gt;sourceid = 0;
 }
}

static void on_pad_added(GstElement *element, GstPad *pad)
{
 GstCaps *caps;
 GstStructure *str;
 gchar *name;
 GstPad *ffmpegsink;
 GstPadLinkReturn ret;

 g_debug("pad added");

 caps = gst_pad_get_caps(pad);
 str = gst_caps_get_structure(caps, 0);

 g_assert(str);

 name = (gchar*)gst_structure_get_name(str);

 g_debug("pad name %s", name);

 if(g_strrstr(name, "video")){

  ffmpegsink = gst_element_get_pad(gst_app.ffmpeg, "sink");
  g_assert(ffmpegsink);
  ret = gst_pad_link(pad, ffmpegsink);
  g_debug("pad_link returned %d\n", ret);
  gst_object_unref(ffmpegsink);
 }
 gst_caps_unref(caps);
}

static gboolean bus_callback(GstBus *bus, GstMessage *message, gpointer *ptr)
{
 gst_app_t *app = (gst_app_t*)ptr;

 switch(GST_MESSAGE_TYPE(message)){

 case GST_MESSAGE_ERROR:{
  gchar *debug;
  GError *err;

  gst_message_parse_error(message, &amp;amp;err, &amp;amp;debug);
  g_print("Error %s\n", err-&amp;gt;message);
  g_error_free(err);
  g_free(debug);
  g_main_loop_quit(app-&amp;gt;loop);
 }
 break;

 case GST_MESSAGE_WARNING:{
  gchar *debug;
  GError *err;
  gchar *name;

  gst_message_parse_warning(message, &amp;amp;err, &amp;amp;debug);
  g_print("Warning %s\nDebug %s\n", err-&amp;gt;message, debug);

  name = GST_MESSAGE_SRC_NAME(message);

  g_print("Name of src %s\n", name ? name : "nil");
  g_error_free(err);
  g_free(debug);
 }
 break;

 case GST_MESSAGE_EOS:
  g_print("End of stream\n");
  g_main_loop_quit(app-&amp;gt;loop);
  break;

 case GST_MESSAGE_STATE_CHANGED:
  break;

 default:
  g_print("got message %s\n", \
   gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
  break;
 }

 return TRUE;
}

int main(int argc, char *argv[])
{
 gst_app_t *app = &amp;amp;gst_app;
 GstBus *bus;
 GstStateChangeReturn state_ret;

 if(argc != 2){
  printf("File name not specified\n");
  return 1;
 }

 app-&amp;gt;file = fopen(argv[1], "r");

 g_assert(app-&amp;gt;file);

 gst_init(NULL, NULL);

 app-&amp;gt;pipeline = (GstPipeline*)gst_pipeline_new("mypipeline");
 bus = gst_pipeline_get_bus(app-&amp;gt;pipeline);
 gst_bus_add_watch(bus, (GstBusFunc)bus_callback, app);
 gst_object_unref(bus);

 app-&amp;gt;src = (GstAppSrc*)gst_element_factory_make("appsrc", "mysrc");
 app-&amp;gt;decoder = gst_element_factory_make("decodebin", "mydecoder");
 app-&amp;gt;ffmpeg = gst_element_factory_make("ffmpegcolorspace", "myffmpeg");
 app-&amp;gt;xvimagesink = gst_element_factory_make("xvimagesink", "myvsink");

 g_assert(app-&amp;gt;src);
 g_assert(app-&amp;gt;decoder);
 g_assert(app-&amp;gt;ffmpeg);
 g_assert(app-&amp;gt;xvimagesink);

 g_signal_connect(app-&amp;gt;src, "need-data", G_CALLBACK(start_feed), app);
 g_signal_connect(app-&amp;gt;src, "enough-data", G_CALLBACK(stop_feed), app);
 g_signal_connect(app-&amp;gt;decoder, "pad-added", 
  G_CALLBACK(on_pad_added), app-&amp;gt;decoder);

 gst_bin_add_many(GST_BIN(app-&amp;gt;pipeline), (GstElement*)app-&amp;gt;src, 
  app-&amp;gt;decoder, app-&amp;gt;ffmpeg, app-&amp;gt;xvimagesink, NULL);

 if(!gst_element_link((GstElement*)app-&amp;gt;src, app-&amp;gt;decoder)){
  g_warning("failed to link src anbd decoder");
 }

 if(!gst_element_link(app-&amp;gt;ffmpeg, app-&amp;gt;xvimagesink)){
  g_warning("failed to link ffmpeg and xvsink");
 }

 state_ret = gst_element_set_state((GstElement*)app-&amp;gt;pipeline, GST_STATE_PLAYING);
 g_warning("set state returned %d\n", state_ret);

 app-&amp;gt;loop = g_main_loop_new(NULL, FALSE);

 g_main_loop_run(app-&amp;gt;loop);

 state_ret = gst_element_set_state((GstElement*)app-&amp;gt;pipeline, GST_STATE_NULL);
 g_warning("set state null returned %d\n", state_ret);

 return 0;
}
&lt;/pre&gt;
&lt;br /&gt;
This just shows &lt;i&gt;appsrc&lt;/i&gt; in action - the real work is integrating it with your application. Remember that g_main_loop_run will return only when you call g_main_loop_quit - so you might want to call it from its own thread.&lt;br /&gt;
&lt;br /&gt;
If you find it helpful or wrong, please share your feedback.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-4936798684426496632?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=z1PX6-MV01c:LUs6KkbXSE4:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=z1PX6-MV01c:LUs6KkbXSE4:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=z1PX6-MV01c:LUs6KkbXSE4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=z1PX6-MV01c:LUs6KkbXSE4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/z1PX6-MV01c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/4936798684426496632/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2012/01/gstreamer-appsrc-in-action.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/4936798684426496632?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/4936798684426496632?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/z1PX6-MV01c/gstreamer-appsrc-in-action.html" title="gstreamer appsrc in action" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2012/01/gstreamer-appsrc-in-action.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUFRH87eCp7ImA9Wx5VE0U.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-7188021570370304338</id><published>2010-10-06T22:10:00.000+05:30</published><updated>2010-10-06T22:10:15.100+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-06T22:10:15.100+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="redmine" /><category scheme="http://www.blogger.com/atom/ns#" term="apache" /><title>Redmine, Apache and passenger</title><content type="html">&lt;p&gt;We've been running &lt;a href="http://www.redmine.org/"&gt;Redmine&lt;/a&gt; on Apache2 with &lt;a href="http://www.modrails.com/"&gt;mode-passenger&lt;/a&gt; for a while. Everything was running smooth until yesterday, when we installed PHP and PostgreSQL on the same server. Redmine started giving &lt;i&gt;Connection refused&lt;/i&gt; messages upon installing these. I promptly restarted Apache, to see the following error message:&lt;/p&gt;&lt;code&gt;Invalid command 'RailsEnv', perhaps misspelled or defined by a module not included in the server configuration&lt;/code&gt;&lt;br/&gt;
&lt;p&gt;Staring at Apache configuration files for half an hour didn't really help, as I hardly know anything about them. I resorted to Google as usual and it took a while to figure out the issue. Apparently, the passenger module somehow got disabled when PHP and PostgreSQL were installed. Thanks to &lt;a href="http://www.redmine.org/boards/2/topics/5254"&gt;this page in Redmine forums&lt;/a&gt;, I was able to fix it by enabling it back. Just in case anyone have the same issue, here's how to do it:&lt;/p&gt;
&lt;pre class="brush: bash"&gt;
# install passenger (if you don't have it already). I'm sure I already had 
# it installed, but the apt-get downloaded and installed it again. 
# I say do it anyway.

sudo apt-get install libapache2-mod-passenger

#enable passenger explicitly

sudo a2enmod passenger

#restart apache

sudo /etc/init.d/apache2 restart

# Check redmine: 
# Still not working....? I'm sorry, the problem is somewhere else :(
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-7188021570370304338?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=svErSXE2qRY:zzbYgzx9lr4:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=svErSXE2qRY:zzbYgzx9lr4:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=svErSXE2qRY:zzbYgzx9lr4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=svErSXE2qRY:zzbYgzx9lr4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/svErSXE2qRY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/7188021570370304338/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2010/10/redmine-apache-and-passenger.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/7188021570370304338?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/7188021570370304338?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/svErSXE2qRY/redmine-apache-and-passenger.html" title="Redmine, Apache and passenger" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2010/10/redmine-apache-and-passenger.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEHQnk_cSp7ImA9WxBRF0o.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-3024272295662720651</id><published>2010-01-06T17:07:00.003+05:30</published><updated>2010-01-06T17:20:33.749+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-06T17:20:33.749+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Icons" /><category scheme="http://www.blogger.com/atom/ns#" term="Flex" /><category scheme="http://www.blogger.com/atom/ns#" term="MenuBar" /><title>Icons in Flex MenuBar</title><content type="html">&lt;p&gt;I came across this strange behavior (I'm not sure if it qualifies to be called a bug, but it definitely is not a feature) in Flex while trying to add icons to the &lt;code&gt;MenuBar&lt;/code&gt; control.&lt;/p&gt;&lt;p&gt;The icons are displayed properly if both the &lt;code&gt;MenuBar&lt;/code&gt; and the icon-embed variables are declared in the main application class. But if they are nested inside another component, only the top level menu-items' icons are displayed - child menu items' icons are not displayed.&lt;/p&gt;&lt;p&gt;After some debugging I realized that only the top-level menu items are displayed using the &lt;code&gt;itemToIcon&lt;/code&gt; method of the &lt;code&gt;MenuBar&lt;/code&gt; class; child menu-items are displayed using the &lt;code&gt;itemToIcon&lt;/code&gt; method of the &lt;code&gt;Menu&lt;/code&gt; class. The problem here is that even though both of these methods use &lt;code&gt;document[data[iconField]]&lt;/code&gt; to grab the icon-embed class, the &lt;a href="http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html#document"&gt;&lt;code&gt;document&lt;/code&gt;&lt;/a&gt; properties of these two objects point to different items. The &lt;code&gt;document&lt;/code&gt; property of the &lt;code&gt;MenuBar&lt;/code&gt; points correctly to the enclosing component (&lt;code&gt;MyPanel&lt;/code&gt;). Whereas, for some reason that I don't understand, the &lt;code&gt;document&lt;/code&gt; property for nested &lt;code&gt;Menu&lt;/code&gt; points to the &lt;code&gt;MainApplication&lt;/code&gt; class.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;, while rendering icons of a &lt;code&gt;MenuBar&lt;/code&gt; within a component, flex searches the  component class for icons of top-level menu items, and the main-application class for icons of its nested menu items. The obvious workaround is to embed all icons to &lt;code&gt;public static const&lt;/code&gt; in some class and to keep appropriate references to them in both application and component classes. But that doesn't sound so pretty to me (even though that's what I am doing now). Does anyone know better?&lt;/p&gt;&lt;p&gt;Here is example code and screenshots to demonstrate the issue:&lt;/p&gt;&lt;pre class="brush: html"&gt;&amp;lt;!--The main Application class--&amp;gt;
&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
   creationComplete="create()" xmlns:local="*"&amp;gt;
   &amp;lt;mx:Label text="MenuBar in the Application works fine"/&amp;gt;
   &amp;lt;mx:MenuBar id="menuBar" top="10" left="10"
       dataProvider="{menuBarCollection}" labelField="@label"
       iconField="@icon" /&amp;gt;

   &amp;lt;local:MyPanel/&amp;gt;

   &amp;lt;mx:Script&amp;gt;
       &amp;lt;![CDATA[
           import mx.collections.XMLListCollection;

           [Bindable]
           protected var menuBarCollection:XMLListCollection;

           [Embed(source="assets/icon_one.png")]
           public var iconOne_App:Class;

           [Embed(source="assets/icon_two.png")]
           public var iconTwo_App:Class;

           private function create():void
           {
               menuBarCollection = new XMLListCollection(XMLList(
                   '&amp;lt;menuitem label="One" icon="iconOne_App"&amp;gt;' +
                       '&amp;lt;menuitem label="Two" icon="iconTwo_App"/&amp;gt;' +
                       '&amp;lt;menuitem label="Three" icon="iconTwo_App"/&amp;gt;' +
                   '&amp;lt;/menuitem&amp;gt;'
               ));
           }
       ]]&amp;gt;
   &amp;lt;/mx:Script&amp;gt;
&amp;lt;/mx:Application&amp;gt;
&lt;/pre&gt;
&lt;p style="text-align: center;"&gt;&lt;img src="http://lh4.ggpht.com/_dMvpiHJOOxw/S0RC_szZ8MI/AAAAAAAAA4w/qJ-E5EgRH70/menu1.jpg" alt="MenuBar in the Application" title="MenuBar directly in the Application" /&gt;&lt;/p&gt;&lt;pre class="brush: html"&gt;
&amp;lt;!--MyPanel.mxml--&amp;gt;
&amp;lt;mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" height="144"
   creationComplete="create();" horizontalAlign="center" verticalAlign="middle"&amp;gt;
   &amp;lt;mx:Text text="MenuBar inside a component doesn't display icons properly"/&amp;gt;
   &amp;lt;mx:MenuBar id="menuBar" top="10" left="10"
       dataProvider="{menuBarCollection}" labelField="@label"
       iconField="@icon" /&amp;gt;
   &amp;lt;mx:Script&amp;gt;
       &amp;lt;![CDATA[
           import mx.collections.XMLListCollection;

           [Bindable]
           protected var menuBarCollection:XMLListCollection;

           [Embed(source="assets/icon_one.png")]
           public var iconOne_Panel:Class;

           [Embed(source="assets/icon_two.png")]
           public var iconTwo_Panel:Class;

           private function create():void
           {
               menuBarCollection = new XMLListCollection(XMLList(
                   //top level item referring to component
                   //this icon is displayed
                   '&amp;lt;menuitem label="ParentIcon_panel" icon="iconOne_Panel"&amp;gt;' +

                       //nested item referring to component
                       //this icon is not displayed
                       '&amp;lt;menuitem label="ChildIcon_panel" icon="iconTwo_Panel"/&amp;gt;' +

                       //nested item referring to application
                       //this icon is displayed
                       '&amp;lt;menuitem label="ChildIcon-app" icon="iconTwo_App"/&amp;gt;' +
                   '&amp;lt;/menuitem&amp;gt;' +

                   //top level item referring to Application
                   //this icon is not displayed
                   '&amp;lt;menuitem label="ParentIcon_app" icon="iconOne_App"/&amp;gt;'
               ));
           }
       ]]&amp;gt;
   &amp;lt;/mx:Script&amp;gt;
&amp;lt;/mx:Panel&amp;gt;
&lt;/pre&gt;
&lt;p style="text-align: center;"&gt;&lt;img src="http://lh4.ggpht.com/_dMvpiHJOOxw/S0RC_iZtE2I/AAAAAAAAA40/3F7-6NUiHzg/menu2.jpg" alt="MenuBar inside a Component" title="MenuBar inside a Component" /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-3024272295662720651?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=IgRpWAuvfHI:sfPgufZrQj0:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=IgRpWAuvfHI:sfPgufZrQj0:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=IgRpWAuvfHI:sfPgufZrQj0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=IgRpWAuvfHI:sfPgufZrQj0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/IgRpWAuvfHI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/3024272295662720651/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2010/01/icons-in-flex-menubar.html#comment-form" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/3024272295662720651?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/3024272295662720651?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/IgRpWAuvfHI/icons-in-flex-menubar.html" title="Icons in Flex MenuBar" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_dMvpiHJOOxw/S0RC_szZ8MI/AAAAAAAAA4w/qJ-E5EgRH70/s72-c/menu1.jpg" height="72" width="72" /><thr:total>9</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2010/01/icons-in-flex-menubar.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMBQ38yfip7ImA9WxNbFUs.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-3022584467143127369</id><published>2009-11-18T22:10:00.006+05:30</published><updated>2009-11-18T22:44:12.196+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T22:44:12.196+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="flex builder" /><category scheme="http://www.blogger.com/atom/ns#" term="regex" /><category scheme="http://www.blogger.com/atom/ns#" term="Flex" /><title>Generating getters and setters in Flex Builder</title><content type="html">&lt;span style="font-weight:bold;"&gt;Fine print:&lt;/span&gt; &lt;span style="font-style:italic;"&gt;This post discusses not so thoroughly tested regexes that the author used to edit his source code (and to fulfill his newly found affection for exploring regular expressions). Author cannot be held responsible or abused for the damages that these regexes might incur to your code and/or job.&lt;/span&gt;

Eclipse has this cool feature that lets you generate getters and setters for the variables in your source code. Flex Builder 3, though based on Eclipse platform, doesn't have such an option. For those interested, here is a way to generate get and set methods for your &lt;code&gt;ActionScript&lt;/code&gt; &lt;code&gt;private/protected&lt;/code&gt; variables using the inbuilt Find/Replace and regular expressions. 

Though it assumes that you're using tabs for indenting the code (which is the default in FB), you can modify it for spaces easily. Open the Find/Replace window (&lt;code&gt;Ctrl-F&lt;/code&gt;) and add the following regular expression to the Find field.&lt;p&gt;&lt;pre style="background-color:#EEEEEE;margin-bottom:10px;overflow:auto;padding:5px;width:auto;"&gt;&lt;code style="white-space:nowrap;"&gt;^((\t)+)(?:private|protected)\s+var\s+_(\w+):(\w+)\s*;\s*(\n)&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;Now add the following pattern to the Replace field.
&lt;p&gt;&lt;pre style="background-color:#EEEEEE;margin-bottom:10px;overflow:auto;padding:5px;width:auto;"&gt;&lt;code style="white-space:nowrap;"&gt;$0$5$1public function set $3(value:$4):void$5$1{$5$1$2_$3 = value;$5$1}$5$5$1public function get $3():$4$5$1{$5$1$2return _$3;$5$1}$5$5&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;Don't forget to select the Regular expressions check box in the options box. The replace pattern doesn't accept any meta characters other than $, and hence we need to capture a tab and a new-line using the regex itself.

Now use the Find, (&lt;code&gt;Alt-N&lt;/code&gt;), Replace (&lt;code&gt;Alt-R&lt;/code&gt;) and Replace/Find (&lt;code&gt;Alt-D&lt;/code&gt;) to generate get and set methods for the required properties. If you want to generate get/set methods for all the &lt;code&gt;private/protected&lt;/code&gt; variables in your class - and you're really courageous, use Replace All (&lt;code&gt;Alt-A&lt;/code&gt;).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-3022584467143127369?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=7j9YO5kNdGE:kLVrZyxwHkY:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=7j9YO5kNdGE:kLVrZyxwHkY:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=7j9YO5kNdGE:kLVrZyxwHkY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=7j9YO5kNdGE:kLVrZyxwHkY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/7j9YO5kNdGE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/3022584467143127369/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2009/11/generating-getters-and-setters-in-flex.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/3022584467143127369?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/3022584467143127369?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/7j9YO5kNdGE/generating-getters-and-setters-in-flex.html" title="Generating getters and setters in Flex Builder" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><thr:total>4</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2009/11/generating-getters-and-setters-in-flex.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8CQ3g-fyp7ImA9WxNVFks.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-1049150265080888602</id><published>2009-10-27T21:45:00.003+05:30</published><updated>2009-10-27T21:57:42.657+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-27T21:57:42.657+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="stackoverflow" /><title>StackOverflow Reputation Tracker</title><content type="html">Did I say that I've gotten addicted to &lt;a href="http://stackoverflow.com/"&gt;StackOverflow&lt;/a&gt;? Here is a snippet of shell script to check your &lt;code&gt;StackOverflow&lt;/code&gt; reputation from the comfort of your Linux console. Replace the highlighted part with your user ID.

&lt;code style="font-family: courier new;"&gt;#!/bin/sh
json=$(curl -s http://stackoverflow.com/users/flair/{&lt;span style="font-weight:bold;"&gt;165297&lt;/span&gt;}.json)
echo $json | sed 's/.*"reputation":"\([0-9,]\{1,\}\)".*/\1/' | sed s/,//&lt;/code&gt;

Haven't tested this for other sites in the trilogy, but I believe this would work for all the three sites and also the meta. 

Now onto writing an AIR app that would track reps and alert about new questions with your favorite tags... :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-1049150265080888602?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=8j_j7ALmBI8:JvE7V_gamDA:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=8j_j7ALmBI8:JvE7V_gamDA:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=8j_j7ALmBI8:JvE7V_gamDA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=8j_j7ALmBI8:JvE7V_gamDA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/8j_j7ALmBI8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/1049150265080888602/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2009/10/stackoverflow-reputation-tracker.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/1049150265080888602?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/1049150265080888602?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/8j_j7ALmBI8/stackoverflow-reputation-tracker.html" title="StackOverflow Reputation Tracker" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2009/10/stackoverflow-reputation-tracker.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYMR3o7fSp7ImA9WxVbF0s.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-8639846802637021654</id><published>2009-04-03T16:59:00.010+05:30</published><updated>2009-04-03T19:29:46.405+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-03T19:29:46.405+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Flex" /><title>VerifyError 1102</title><content type="html">&lt;span style="color: rgb(255, 0, 0);"&gt;VerifyError: Error #1102: Illegal default value for type *&lt;/span&gt;

If you ever get this rather unusual run-time error, here's what to do.

If you are using default values for arguments in a method's declaration part, make sure that the types match well. For instance, I wanted to explicitly call an event handler from the code and hence used null as the default value for the event parameter - only I typed it &lt;span style="font-style: italic;"&gt;false&lt;/span&gt; instead of &lt;span style="font-style: italic;"&gt;null&lt;/span&gt; (yeah, its Friday evening here). I don't know why the compiler thinks its okay to assign false (or a String or AnyThing) to an Event variable.

&lt;code&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 127, 0);"&gt;function&lt;/span&gt; init(&lt;span style="text-decoration: underline;"&gt;e:Event = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;&lt;/span&gt;):&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;/code&gt;

So check your code for something silly like this, fix it and you are good to go.

This run-time error is strange because &lt;a href="http://livedocs.adobe.com/flex/3/langref/VerifyError.html" title="VerifyError (Flex 3.3)"&gt;livedocs&lt;/a&gt; says that "The VerifyError class represents an error that occurs when a malformed or corrupted SWF file is encountered". So you conclude that the SWF is having its issues on the Friday evening and rebuild the project to fix it. But no matter what you do to fix the "corrupted" SWF, you will get the same error again and again.

Also, Flex doesn't show the corresponding MXML/AS file name or the line of code that caused this error, which it normally does with errors. It in fact traces the call stack, but that's not quite useful. One would normally expect the bug to be in the top most method of the call stack or in a method called from that. But here it seems that the top most method in the stack trace is the method that accesses &lt;span style="font-weight: bold;"&gt;any&lt;/span&gt; method/property from the buggy class for the first time in application. Adobe's &lt;a href="http://livedocs.adobe.com/flex/3/langref/runtimeErrors.html#1102"&gt;documentation&lt;/a&gt; on Flex run-time errors says that "ActionScript in the SWF is invalid. If you believe that the file has not been corrupted, please report the problem to Adobe." - not really helpful either.

But fortunately this is not even a run-time error - or this wouldn't have been one, had the compiler done its job well. And it turns out that the error message - Illegal default value for type * - is in fact correct.

Compiler will detect wrong assignments in the case of basic types. For instance, if it was &lt;code&gt;function(t:String = 3)&lt;/code&gt; you will get a compiler error &lt;code&gt;1184: Incompatible default value of type int where String is expected&lt;/code&gt; along with file name and the exact line of code that went wrong. But if its anything other than basic types, compiler just ignores it and you get this scary "malformed SWF".

Hope this helps someone.


&lt;div style="text-align: right;"&gt;&lt;code&gt;Links added with &lt;a href="http://www.cdacbangalore.in/%7Eamarghosh/LinkIt/"&gt;LinkIt&lt;/a&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-8639846802637021654?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=Dd4npmrwDYc:phIBAKnegY0:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=Dd4npmrwDYc:phIBAKnegY0:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=Dd4npmrwDYc:phIBAKnegY0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=Dd4npmrwDYc:phIBAKnegY0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/Dd4npmrwDYc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/8639846802637021654/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2009/04/verifyerror-1102.html#comment-form" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/8639846802637021654?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/8639846802637021654?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/Dd4npmrwDYc/verifyerror-1102.html" title="VerifyError 1102" /><author><name>Amarghosh Vadakkoot</name><uri>https://profiles.google.com/116526996338948911809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-nfWfa4ZXznw/AAAAAAAAAAI/AAAAAAAABD8/49vcxRKbNek/s512-c/photo.jpg" /></author><thr:total>8</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2009/04/verifyerror-1102.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQHQn0yeSp7ImA9WxVbGUQ.&quot;"><id>tag:blogger.com,1999:blog-3933331672089603623.post-383527258056775068</id><published>2009-02-25T14:38:00.005+05:30</published><updated>2009-04-06T10:18:53.391+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-06T10:18:53.391+05:30</app:edited><title>Hello World</title><content type="html">This, ladies and gentlemen, would be my &lt;span style="font-style:italic;"&gt;attempted&lt;/span&gt; English blog. (I am &lt;span style="font-style:italic;"&gt;attempting&lt;/span&gt; one in Malayalam &lt;a href="http://vadakkoodan.blogspot.com/" title="അമരകോശം"&gt;here&lt;/a&gt;). Be warned that this is the first time I am writing anything completely by myself in English - other than exam papers and assignments, of course. Err, I can't really make that claim - quite a few of them were actually not &lt;span style="font-style:italic;"&gt;completely written by myself&lt;/span&gt; ;)

The first question that I had upon deciding to start this blog was what would I write about, and unfortunately that still remains unanswered. Normally new bloggers complain about not having anything to write about after few posts; but I'm doing that in my very first post itself - quite impressive, isn't it?

I guess I would start by jotting down some FYIs about Flash/Flex that I had to learn the hard way.



&lt;div style="text-align: right;"&gt;&lt;code&gt;Links added with &lt;a href="http://www.cdacbangalore.in/%7Eamarghosh/LinkIt/"&gt;LinkIt&lt;/a&gt;&lt;/code&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3933331672089603623-383527258056775068?l=amarghosh.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=LUoUXb8eUz8:6OI44lkTiW8:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?i=LUoUXb8eUz8:6OI44lkTiW8:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=LUoUXb8eUz8:6OI44lkTiW8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/amarghosh?a=LUoUXb8eUz8:6OI44lkTiW8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/amarghosh?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/amarghosh/~4/LUoUXb8eUz8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://amarghosh.blogspot.com/feeds/383527258056775068/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://amarghosh.blogspot.com/2009/02/hello-world.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/383527258056775068?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3933331672089603623/posts/default/383527258056775068?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/amarghosh/~3/LUoUXb8eUz8/hello-world.html" title="Hello World" /><author><name>Amarghosh</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://1.bp.blogspot.com/_axtFJ_P5nwo/SaUNf5syabI/AAAAAAAAAAY/jnFBkwi5Epw/S220/rubiks.png" /></author><thr:total>2</thr:total><feedburner:origLink>http://amarghosh.blogspot.com/2009/02/hello-world.html</feedburner:origLink></entry></feed>

