<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6167393459950006179</id><updated>2026-07-17T22:50:33.639-07:00</updated><category term="android"/><category term="ubuntu"/><category term="GWT"/><category term="c++"/><category term="eclipse"/><category term="HTTP"/><category term="java"/><category term="mobile"/><category term="J2ME"/><category term="gtest"/><category term="mercurial"/><category term="multithreading"/><category term="unittest"/><category term="Linux"/><category term="POST"/><category term="bash"/><category term="boost"/><category term="emulator"/><category term="google"/><category term="modules"/><category term="protobuf"/><category term="source control"/><category term="sshfs"/><category term="testing"/><category term="tutorial"/><category term="9-patch"/><category term="AJAX"/><category term="Dynamic Faces"/><category term="JPA"/><category term="JSF"/><category term="Microsoft"/><category term="RMI"/><category term="RPC"/><category term="Rich Internet Application"/><category term="adk"/><category term="audio"/><category term="blogging"/><category term="branch"/><category term="conference notes"/><category term="cvs"/><category term="decorators"/><category term="development"/><category term="diff"/><category term="editor"/><category term="flock"/><category term="fstab"/><category term="git"/><category term="git tag"/><category term="hamcrest"/><category term="hg"/><category term="icons"/><category term="javaagent"/><category term="javascript"/><category term="jmock"/><category term="kvm"/><category term="mbed"/><category term="mongodb"/><category term="networking"/><category term="p2"/><category term="persistence"/><category term="python"/><category term="remote service"/><category term="rsync"/><category term="sdk"/><category term="sensor data"/><category term="service"/><category term="shellscript"/><category term="skype"/><category term="temperature"/><category term="threads"/><category term="tkdiff"/><category term="updates"/><category term="weaving"/><category term="zenity"/><title type='text'>Java Code Trips &amp;amp; Tips</title><subtitle type='html'>This blog was born as a means of annotating big and small discoveries in my use of Java, Ubuntu/Linux and Android that would be easy to access from anywhere, anytime. It does beat post-it&#39;s big time, and it also adds the benefit that others might, eventually, contribute with intelligent insights.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>58</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-264687783550409939</id><published>2014-12-03T23:22:00.000-08:00</published><updated>2014-12-03T23:22:35.045-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="conference notes"/><category scheme="http://www.blogger.com/atom/ns#" term="mongodb"/><title type='text'>MongoDays SF 2014</title><content type='html'>MongoDB 2.8 is about to exit from beta and 3.0 is round the corner (probably early 2015) with a lot of exciting new features.

My (raw and unedited) notes from some of the technical session are available &lt;a title=&quot;MongoDays SF 2014 notes&quot; href=&quot;https://www.evernote.com/shard/s15/sh/b6cd4660-8744-4487-94ac-54fa17fc775b/03ab1c5dd9a07998a25f928228158b86&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;, I will add more as I discover new things.</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/264687783550409939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2014/12/mongodays-sf-2014.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/264687783550409939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/264687783550409939'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2014/12/mongodays-sf-2014.html' title='MongoDays SF 2014'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-3952959077869080574</id><published>2013-01-06T01:38:00.002-08:00</published><updated>2013-01-06T01:48:45.249-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="decorators"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="tutorial"/><title type='text'>Python Decorators</title><content type='html'>&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;I&#39;ve now been working in Python for more than a year and we have been doing some pretty crazy stuff, especially around decorators and authorization/permissions implementations.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Admittedly, Python decorators are one of the bits of the language that can be best defined as &#39;magic&#39; and certainly remains puzzling for someone like me, used to Java strict and (I still believe, much safer) compile-time type-checking.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;Anyway, sparked by &lt;a href=&quot;http://www.brianholdefehr.com/decorators-and-functional-python&quot; target=&quot;_blank&quot;&gt;this very useful article on decorators&lt;/a&gt;, I have decided to further explore the topic of class decorators, that in the original article was just mentioned in passing, and found a few twists - the most surprising of which has certainly been finding out that the call sequence, and the type of objects being associated with type names depends on whether the decorator annotation is followed by a parameter list.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;It is worth noting that python Mocks use decorators pretty heavily, and it&#39;s easy to see why, once you browse the code below: it&#39;s heavily commented and should give enough of an idea of what goes on; it can be easily executed by just running&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;python fun_decorators.py&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
&quot;&quot;&quot;
@copyright: AlertAvert.com (c) 2013. All rights reserved.

Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Decorators
==========

Code to try out Python decorators.

Original idea from:
http://www.brianholdefehr.com/decorators-and-functional-python

@author: Marco Massenzio (m.massenzio@gmail.com)
         Created on [2013-01-05]
&quot;&quot;&quot;

class DecoratorClass(object):

    def __init__(self, klass=None, **kwargs):
        &quot;&quot;&quot;This gets called every time the @DecoratorClass annotation
        is encountered.

        @param klass: the type of the class being decorated, it will be 
                passed in if no parameters are passed in the annotation
        @type klass: type
        @param kwargs: a dictionary containing any of the named 
                parameters passed in the decorator&#39;s declaration
        @type kwargs: dict
        &quot;&quot;&quot;

        # If the decorator is declared without parameters, 
        # the class type will be passed in
        self._name = &#39;default&#39;
        self._klass = None
        if klass:
            print &#39;No-args decorator for: &#39;, klass.__name__
            self._klass = klass
        else:
            print &#39;Args declared: &#39;, kwargs
            self._name = kwargs.get(&#39;name&#39;)

    def __call__(self, *args, **kwargs):
        &quot;&quot;&quot;This gets invoked every time a decorated class gets created, 
        with the actual arguments in what would appear to look like a 
        constructor call: they do not have to (and in fact, won&#39;t) match 
        the actual formal argument list of the
        constructor of the decorated class (which may not even get invoked).

        If the decorator is declared with one or more arguments 
        (see Different class below), then the first item in ``args`` will be the
        **type** of the class being decorated (which
        will not have been passed in to the __init__()).

        This gets invoked immediately after self#__init__() if the decorator is 
        declared with one or more arguments, or when the &quot;constructor&quot; is invoked.
        &quot;&quot;&quot;
        print &#39;Decorator __call__ invoked with: &#39;, args, kwargs
        if self._klass:
            print &#39;Decorated instance: &#39;, self._klass.__name__
            return self._klass(self._name)
        else:
            print &#39;Setting up klass&#39;
            self._klass = args[0]
            # Here we inject a &#39;class-level&#39; static method
            self._klass.get_name = self.get_name
        return self._klass

    def get_name(self):
        return self._name


@DecoratorClass
class Decorated(object):
    def __init__(self, name):
        print &#39;&gt;&gt;&gt;&gt;&gt; I am being decorated! &lt;&lt;&lt;&lt;&lt;&#39;
        self.name = name

    def call_me(self, *args):
        print &#39;I\&#39;m being called: &#39;, self.name
        print &#39;These are my args: &#39;, args

# Notice how here a &#39;type&#39; name (Decorated) has been completely 
# &#39;hijacked&#39; to point to a specific
# instance of a DecoratorClass object (this provides &#39;closure&#39;)

print &#39;what is Decorated here?&#39;, Decorated
# &gt;&gt; what is Decorated here? &lt;__main__.DecoratorClass object at 0x7f34b71308d0&gt;

@DecoratorClass(name=&#39;another&#39;)
class Different(object):
    def __init__(self):
        # Notice how here we are using a &#39;static&#39; method 
        # that has been injected by the decorator
        self.name = Different.get_name()

    def method(self, *args):
        &quot;&quot;&quot;This is the same implementation as Decorated#call_me(), 
        just to show how they behave differently
        &quot;&quot;&quot;
        print &#39;I\&#39;m being called: &#39;, self.name
        print &#39;These are my args: &#39;, args

    def __call__(self, *args, **kwargs):
        return &#39;Different called with: &#39;, args, kwargs

# Here, Different is whatever DecoratorClass#__call__()  returned: 
# this happens to be what one would expect it to be (a Different class 
# type) but that&#39;s only because the code makes it so

print &#39;what is Different here? &#39;, Different
# &gt;&gt; what is Different here?  &lt;class &#39;__main__.Different&#39;&gt;

print &#39;Calling Decorated class constructor&#39;
# Note how the params being passed here have no relation with the 
# constructor argument list and in fact, the name of the &#39;decorated&#39; 
# class is not even given here, but in the decorator

# Due to the &#39;magic&#39; of decorators, DecoratorClass#__call__() is
# instead invoked here,
# on the instance that was created at declaration
deco = Decorated(123, &quot;Hello&quot;, foo=&#39;foo&#39;, baz=&#39;baz&#39;)

# Again, now ``deco`` here happens to be what one would expect it to 
# be (an instance of the Decorated class) but solely because the code 
# makes it so - it could have been anything, really

deco.call_me(1, 2, 3, 1)
# &gt;&gt; I&#39;m being called:  default
# &gt;&gt; These are my args:  (1, 2, 3, 1)

print &#39;Creating now a Different class:&#39;
# Here the call does actually invoke the constructor (__init__()) 
# for the Different class, and the returned object is again what one 
# would expect it to be (an instance of Different):
diff = Different()

diff.method(&#39;quart&#39;, &#39;naught&#39;)
# &gt;&gt; I&#39;m being called:  another
# &gt;&gt; These are my args:  (&#39;quart&#39;, &#39;naught&#39;)

# Obviously, as the Different#__call__() method is defined, we can call it too:

print diff(1, 2, 3, value=&#39;val&#39;)
# &gt;&gt; (&#39;Different called with: &#39;, (1, 2, 3), {&#39;value&#39;: &#39;val&#39;})

# If we now create an entirely different instance of a Different object,
# it will still have the same &#39;static&#39; method injected by the decorator:
another_diff = Different()

print &#39;My name is:&#39;, another_diff.name
# &gt;&gt; My name is: another
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/3952959077869080574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2013/01/python-decorators.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/3952959077869080574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/3952959077869080574'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2013/01/python-decorators.html' title='Python Decorators'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-4498946437593641119</id><published>2012-12-02T18:39:00.002-08:00</published><updated>2014-01-18T19:28:19.071-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="branch"/><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="source control"/><title type='text'>Prune local tracking of stale remote branches</title><content type='html'>&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;If you suffer from OCD like myself, you&#39;ll likely be just as annoyed by the output of&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;git branch -a&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We-ve moved! Please read the rest of &lt;a href=&quot;http://codetrips.com/2012/12/03/prune-local-tracking-of-stale-remote-branches/&quot;&gt;this post&lt;/a&gt; on &lt;a href=&quot;http://codetrips.com/&quot;&gt;codetrips.com&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/4498946437593641119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2012/12/prune-local-tracking-of-stale-remote.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/4498946437593641119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/4498946437593641119'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2012/12/prune-local-tracking-of-stale-remote.html' title='Prune local tracking of stale remote branches'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-9189006646872158976</id><published>2012-08-28T23:34:00.000-07:00</published><updated>2012-08-28T23:35:54.305-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git tag"/><title type='text'>Tags in git</title><content type='html'>&lt;br /&gt;
&lt;h3&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Tag a release&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once one is happy with the code and the build, a given commit can be tagged with a proper release tag::&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt; &amp;nbsp; $ git checkout release&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; # Code changes, fixes, build, tests, etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; $ git commit -m&quot;Release candidate complete&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; # To view the latest commit hash:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; $ git log&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; commit 2e4a6e1a7cc3bf2298055937ab79f72fb58abf1f&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; Author: Marco Massenzio &lt;marco snaplogic.com=&quot;snaplogic.com&quot;&gt;&lt;/marco&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; Date: &amp;nbsp; Tue Aug 28 22:49:04 2012 -0700&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Release candidate complete&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; # Tag it with the appropriate release number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; git tag -m&quot;Rel. 0.6 RC3&quot; rel_0.6rc3 2e4a6e1a&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; # Push the commits to origin:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; $ git push origin release&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; # The tag will be kept local to the repository, must be pushed too:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; $ git push origin rel_0.6rc3:refs/tags/rel_0.6rc3&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When others pull from the remote &lt;i&gt;origin&lt;/i&gt;&amp;nbsp;repo, the tag will be pulled too.&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Github&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A nice feature of github is that it records the tags separately, and clicking on any of them will&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;cause a download of a &#39;clean&#39; working directory into a ZIP file or tarball, reflecting the state of&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;the project at the exact point when the tagged commit was pushed.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/9189006646872158976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2012/08/tags-in-git.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/9189006646872158976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/9189006646872158976'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2012/08/tags-in-git.html' title='Tags in git'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-7120705375231408584</id><published>2012-03-23T00:24:00.000-07:00</published><updated>2012-03-23T00:24:08.357-07:00</updated><title type='text'>Eclipse Juno has a new look!</title><content type='html'>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Just downloaded the latest milestone release (M6) of &lt;a href=&quot;http://download.eclipse.org/eclipse/downloads/&quot;&gt;Eclipse Juno&lt;/a&gt; (4.2) and I was quite amazed at finding out it has a brand new splashscreen, which, I must confess, quite rather like!&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHAKz_qiGEp7l3F10D8B18hE07aUF3gSZYFpU2TyFKhrS9mFouuSoPo1HPSxjXXqdaVe8utY471KEYcZTVZzlL9NY9eIrWso2c504v8n8fL__gMcFkFuGjHMGbxjOcqVsNz5jIrPUGZ2I/s1600/Screenshot-EclipseJuno.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;216&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHAKz_qiGEp7l3F10D8B18hE07aUF3gSZYFpU2TyFKhrS9mFouuSoPo1HPSxjXXqdaVe8utY471KEYcZTVZzlL9NY9eIrWso2c504v8n8fL__gMcFkFuGjHMGbxjOcqVsNz5jIrPUGZ2I/s320/Screenshot-EclipseJuno.png&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;And Juno brand new UI looks really really neat!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/7120705375231408584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2012/03/eclipse-juno-has-new-look.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7120705375231408584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7120705375231408584'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2012/03/eclipse-juno-has-new-look.html' title='Eclipse Juno has a new look!'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHAKz_qiGEp7l3F10D8B18hE07aUF3gSZYFpU2TyFKhrS9mFouuSoPo1HPSxjXXqdaVe8utY471KEYcZTVZzlL9NY9eIrWso2c504v8n8fL__gMcFkFuGjHMGbxjOcqVsNz5jIrPUGZ2I/s72-c/Screenshot-EclipseJuno.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-5154940359669817763</id><published>2012-01-18T09:35:00.000-08:00</published><updated>2014-01-18T19:32:45.788-08:00</updated><title type='text'>Adding a new sudoer in Ubuntu</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
This is something I have to do from time to time, but not frequently enough that I manage to memorize it - but trivial enough that it annoys me to have to look it up every time.&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
Here&#39;s to future memory:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;create a new user `bob`&lt;/span&gt;&lt;br /&gt;&lt;code style=&quot;color: #006000;&quot;&gt;sudo adduser bob&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;check that the `admin` group is the one for the &#39;sudoers&#39; on the machine&lt;/span&gt;&lt;br /&gt;&lt;code style=&quot;color: #006000;&quot;&gt;sudo cat /etc/sudoers&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;add Bob to the admin group&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;code style=&quot;color: #006000;&quot;&gt;sudo addgroup bob admin&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
done!&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;h4 style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #b76401; font-family: arial, sans-serif; font-size: 1.1em; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;We&#39;ve moved!&lt;br /&gt;Please read the rest of &lt;a href=&quot;http://codetrips.com/2012/01/18/adding-a-new-sudoer-in-ubuntu/&quot;&gt;this post&lt;/a&gt; on &lt;a href=&quot;http://codetrips.com/&quot;&gt;codetrips.com&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;div style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;
&lt;div style=&quot;color: black; font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/5154940359669817763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2012/01/adding-new-sudoer-in-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5154940359669817763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5154940359669817763'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2012/01/adding-new-sudoer-in-ubuntu.html' title='Adding a new sudoer in Ubuntu'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-6289623121423122752</id><published>2011-09-13T00:03:00.000-07:00</published><updated>2014-01-18T19:16:15.025-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="google"/><category scheme="http://www.blogger.com/atom/ns#" term="gtest"/><category scheme="http://www.blogger.com/atom/ns#" term="testing"/><title type='text'>CDT Indexer &amp; Google gtest framework</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;As I mentioned in a &lt;a href=&quot;http://codetrips.blogspot.com/2011/04/eclipse-cdt-and-google-gtest.html&quot;&gt;previous post&lt;/a&gt; of mine, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&lt;b&gt;Eclipse&#39;s CDT&lt;/b&gt;&lt;/span&gt; (C++ Development Tools) has a few issues when used with &lt;a href=&quot;http://code.google.com/p/googletest/&quot;&gt;Google C++ Unit Testing framework&lt;/a&gt;, but it generally works.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Where CDT really gets confused is around the &#39;exclusion&#39; of the unit tests for the non-test build configurations: as mentioned in my other post, one needs to add the G-Test&#39;s &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;include/ &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;directory to include search path (&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-I&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;This blog has now been moved to &lt;a href=&quot;http://codetrips.com/&quot;&gt;codetrips.com&lt;/a&gt;: read the rest of this post &lt;a href=&quot;http://codetrips.com/2011/09/13/cdt-indexer-google-gtest-framework/&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/6289623121423122752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/09/cdt-indexer-google-gtest-framework.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/6289623121423122752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/6289623121423122752'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/09/cdt-indexer-google-gtest-framework.html' title='CDT Indexer &amp; Google gtest framework'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total><georss:featurename>Sunnyvale, CA, USA</georss:featurename><georss:point>37.36883 -122.0363496</georss:point><georss:box>37.3183525 -122.1153136 37.4193075 -121.9573856</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-1588546160062678943</id><published>2011-09-06T23:42:00.000-07:00</published><updated>2011-09-07T00:52:05.703-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="adk"/><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="mbed"/><title type='text'>Android ADK and mbed.org</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://goo.gl/photos/IZY7DMhzQW&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRE4-Opm8kox18wNo2rfC0c-ZL33qyavrsedN_VrstcQX0wKs9TDyj6TokamZkBkabnhacmTglOlCuO445aty9rU91GZ92VJGBWMBlHmZ73UwdGJuzwD-AJluFySWFdoOZZJG-TmYb9qsK/s400/IMAG0219.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;The &#39;mbed kit&#39; just landed on my doorstep, sent courtesy of the good guys at ARM (Cambridge, UK).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;This gadget supports the Android ADK (&lt;a href=&quot;http://mbed.org/cookbook/mbed-with-Android-ADK&quot; style=&quot;color: #1155cc;&quot; target=&quot;_blank&quot;&gt;http://mbed.org/cookbook/mbed-&lt;wbr&gt;&lt;/wbr&gt;with-Android-ADK&lt;/a&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #222222;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt; which is fully documented &lt;a href=&quot;http://developer.android.com/guide/topics/usb/adk.html&quot;&gt;here&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;and, to have an idea of the geeky-fun that can be had with these gizmos, I suggest you check out &lt;a href=&quot;http://mbed.org/handbook/Tour&quot;&gt;this video&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;I fear that my weekends are likely gone for quite a while now....&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Just as an example of what is possible, the following snippet will make the LEDs flash, as well as connect to a terminal on the host PC to use as stdout; this is a very basic adaption of the &lt;a href=&quot;http://mbed.org/handbook/Creating-a-program&quot;&gt;HelloWorld.cpp app&lt;/a&gt;, and some &lt;a href=&quot;http://mbed.org/handbook/SerialPC&quot;&gt;tutorials&lt;/a&gt; from mbed.org: the point being that it took me less than 30min to get going!&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre&gt;// AlertAvert.com (c) 2011. All rights reserved
//
// The code below has been adapted from tutorials on
// mbed.org - credits should go to ARM Ltd.
//
// Author: M. Massenzio (m.massenzio@gmail.com)

#include &quot;mbed.h&quot;

// USB out to the host PC - from a terminal window access
// using: screen /dev/ttyACM0
Serial pc(USBTX, USBRX); // tx, rx

// Board LEDs
DigitalOut myled(LED1);
DigitalOut yourled(LED2);

bool on = true;
void quit() {
  on = false;
}

void toggle(DigitalOut d1, DigitalOut d2) {
  d1 = !d1;
  d2 = !d2;
}

int main() {
  pc.printf(&quot;Starting LED flashing...\r\n&quot;);
  Timeout to;
  myled = !(yourled = 1);
  to.attach(&amp;amp;quit, 5);
  while(on) {
    toggle(myled, yourled);
    wait(0.2);
  }
  myled = yourled = 0;
  pc.printf(&quot;Exiting now\r\n&quot;);
}&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;And this is what came out of it:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;object width=&quot;320&quot; height=&quot;266&quot; class=&quot;BLOGGER-youtube-video&quot; classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot; data-thumbnail-src=&quot;http://1.gvt0.com/vi/81lIG4EV_nU/0.jpg&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/81lIG4EV_nU&amp;fs=1&amp;source=uds&quot; /&gt;&lt;param name=&quot;bgcolor&quot; value=&quot;#FFFFFF&quot; /&gt;&lt;embed width=&quot;320&quot; height=&quot;266&quot;  src=&quot;http://www.youtube.com/v/81lIG4EV_nU&amp;fs=1&amp;source=uds&quot; type=&quot;application/x-shockwave-flash&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/1588546160062678943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/09/android-adk-and-mbedorg.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1588546160062678943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1588546160062678943'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/09/android-adk-and-mbedorg.html' title='Android ADK and mbed.org'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRE4-Opm8kox18wNo2rfC0c-ZL33qyavrsedN_VrstcQX0wKs9TDyj6TokamZkBkabnhacmTglOlCuO445aty9rU91GZ92VJGBWMBlHmZ73UwdGJuzwD-AJluFySWFdoOZZJG-TmYb9qsK/s72-c/IMAG0219.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-2478567391433149675</id><published>2011-08-22T00:12:00.000-07:00</published><updated>2011-08-22T00:15:59.396-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><title type='text'>Use a common Tag for all your activities&#39; logging</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2rSTBwzeyMTZupuStcNgaKnUfa2Hu9ANfxVnMz-wGeBuUbDBX_tQTgO8hUYf61yoRmpmOJIuoR02d0icES5yqxNNMmqe8fV96M3yN_V3m7_psjoLBuTRJ25MSAo833kVzxnBCG0g_ClE/s1600/Screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;106&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2rSTBwzeyMTZupuStcNgaKnUfa2Hu9ANfxVnMz-wGeBuUbDBX_tQTgO8hUYf61yoRmpmOJIuoR02d0icES5yqxNNMmqe8fV96M3yN_V3m7_psjoLBuTRJ25MSAo833kVzxnBCG0g_ClE/s200/Screenshot.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It is pretty common for any non-trivial Android app to be composed of several Activities which together interact with the user for the furtherance of whatever is the objective of the app itself.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It is also pretty common, especially during the development phase, to have a need to emit logs so that one can check certain events happen when they are supposed to, and invariants, for example, are satisfied.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The Android ADT (Eclipse plugin) has a very nice feature in the form of the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;&lt;b&gt;LogCat View&lt;/b&gt;&lt;/span&gt; that shows all the system logs, including those coming from your applications: as there may well be tens of apps running (and logging) at the same time (especially on a live device -- as to why you should use a device for your testing and debugging, you may want to &lt;a href=&quot;http://codetrips.blogspot.com/2011/01/run-android-tests-in-connected-device.html&quot;&gt;read this&lt;/a&gt;) the LogCat enables one to &#39;filter in&#39; a subset, based on a &#39;tag&#39;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The tag used by the LogCat is the value of the string used for the tag parameter in the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Log.x() &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;calls:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;Log.d(&quot;myApp.tag&quot;, &quot;All is going well&quot;);&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It is pretty obvious that, in any given Activity, we would want a constant to use as the tag:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;private static final String TAG = &quot;myApp.tag&quot;;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;but this has the drawback that we would have to either duplicate that same statment across all Activities (and, even worse, keep them all in sync if we decide, for whatever reason to change them) or resign ourselves to use different tags for different activities.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Alternatively, we could use a common &#39;Constants&#39; class to keep, amongst others, a constant Tag:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;public interface Constants {
  public static final String TAG = &quot;myApp.tag&quot;;
  // other constants...
}&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This is not very friendly, however, as every log statement (and there may well be hundreds in your code) would look something like:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;Log(Constants.TAG, &quot;All is going well&quot;);&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;it&#39;s only 10 extra characters, but multiply that for several hundrends, and you&#39;ve a veritable case of carpal tunnel syndrome on your hands (well, ok...).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A much better option is to use Android&#39;s mechanism to store common application strings, which also gives the additional benefit that it&#39;s dead easy to change the tag in one full swoop, should that ever be necessary: in one of the XML files in the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;res/values/ &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;directory, have a line of the form&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;&lt;item name=&quot;TAG&quot; type=&quot;string&quot;&gt;myApp.tag&lt;/item&gt;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and in your code, you can do something like:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;public class MyActivity extends Activity {
  public static String TAG; // note no &#39;final&#39; here

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TAG = getResources().getString(R.string.TAG);
    Log.d(TAG, &quot;Starting User Preferences activity...&quot;);
    // other initialization follows...
  }
}&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This can be done in each and every of your App&#39;s activities, and then you can easily create a new filtered view in LogCat so that you can see only your App&#39;s logs, from all the activities, also with the reassurance that, should ever want to change that, it&#39;s just a one minute edit of the XML file&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/2478567391433149675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/08/use-common-tag-for-all-your-activities.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/2478567391433149675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/2478567391433149675'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/08/use-common-tag-for-all-your-activities.html' title='Use a common Tag for all your activities&#39; logging'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2rSTBwzeyMTZupuStcNgaKnUfa2Hu9ANfxVnMz-wGeBuUbDBX_tQTgO8hUYf61yoRmpmOJIuoR02d0icES5yqxNNMmqe8fV96M3yN_V3m7_psjoLBuTRJ25MSAo833kVzxnBCG0g_ClE/s72-c/Screenshot.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-7766623964669418656</id><published>2011-08-13T18:15:00.000-07:00</published><updated>2013-05-19T21:14:38.903-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="HTTP"/><category scheme="http://www.blogger.com/atom/ns#" term="POST"/><category scheme="http://www.blogger.com/atom/ns#" term="protobuf"/><title type='text'>HTTP POST for Android (with a twist: Protocol Buffers)</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh64LIQyGDMsop2x_0iTlihK9naO24tOUyD19qdqg5V_SUQJyYpjKw-7CDYrUmCqR6oBL2EqTF8xhM42uIXZR0EHRR2zgBb3NqYGiOQn3nHp9g-7JkQ9h-LIH7HgxdegBWHWFwzUvokkDM/s1600/New+%2527settings%2527+button+nobg.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh64LIQyGDMsop2x_0iTlihK9naO24tOUyD19qdqg5V_SUQJyYpjKw-7CDYrUmCqR6oBL2EqTF8xhM42uIXZR0EHRR2zgBb3NqYGiOQn3nHp9g-7JkQ9h-LIH7HgxdegBWHWFwzUvokkDM/s200/New+%2527settings%2527+button+nobg.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;One of this blog&#39;s &lt;a href=&quot;http://codetrips.blogspot.com/2007/04/http-post-from-j2me-midlet.html&quot;&gt;most visited entries&lt;/a&gt; (ranking always around the Top 5 Google results for &quot;HTTP POST&quot; too) elaborated on how to send data across to a server from a J2ME Midlet.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I thought it was high time for bringing this into the new Century, and provide an update as to how to do this from an Android smartphone.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It turns out that (a) the code is relatively straightforward and (b) that there is not so much difference after all from writing the same code for a desktop client: credit for this ought to go to the Android Google team who have done such a superb job of adapting the J2SE API to the Android platform...&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;THIS BLOG HAS MOVED TO &lt;a href=&quot;http://codetrips.com/&quot;&gt;codetrips.com&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Please read &lt;a href=&quot;http://codetrips.com/2011/08/14/http-post-for-android-with-a-twist-protocol-buffers/&quot; target=&quot;_blank&quot;&gt;the rest of this post&lt;/a&gt; on codetrips.com&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/7766623964669418656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/08/http-post-for-android-with-twist.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7766623964669418656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7766623964669418656'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/08/http-post-for-android-with-twist.html' title='HTTP POST for Android (with a twist: Protocol Buffers)'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh64LIQyGDMsop2x_0iTlihK9naO24tOUyD19qdqg5V_SUQJyYpjKw-7CDYrUmCqR6oBL2EqTF8xhM42uIXZR0EHRR2zgBb3NqYGiOQn3nHp9g-7JkQ9h-LIH7HgxdegBWHWFwzUvokkDM/s72-c/New+%2527settings%2527+button+nobg.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-1359348416798891241</id><published>2011-08-09T23:26:00.000-07:00</published><updated>2011-08-09T23:28:00.645-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash"/><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>Automating Eclipse launch</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I&#39;ve recently taken up the &lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Eclipse&lt;/span&gt;&lt;/b&gt; team at Google (we integrate Google&#39;s internal build tools and distributed development environment with the Eclipse Platform) and we are constantly faced with the challenge of maintaining several distributions in a multi-user environment.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I thought I&#39;d use some of the goodness we&#39;ve come up with in my home environment too, so have put together a much-scaled-down version of our launch script, for my personal use - and thought I&#39;d share this more broadly, as I&#39;m sure other folks will find this useful too.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I generally have multiple installation and user configuration profiles, and even from the desktop launcher, I much prefer to use launch scripts than just pointing the shortcut to the binary executable.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here is my generic configuration script:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;#!/bin/bash
#
# Runs the stable version of Eclipse.
# By default, it will launch Indigo, installed in /opt/eclipse; different
# versions can be launched by invoking this script and setting the
# ECLIPSE_INSTALL and CONFIG variables to point to the correct places.
#
# The default configuration directory is set to &#39;/home/$USER/.eclipse/eclipse37&#39;
# but this can be changed exporting a different value for CONFIG.
# See /home/marco/bin/eclipse-helios for an example of how to do this.

##############################
# Globals (default value):
#
#   LD_LIBRARY_PATH           (/usr/local/lib:/usr/lib)
#     library search path for C++ dynamic libraries
#
#   ECLIPSE_INSTALL           ()
#     installation directory
#
#   CONFIG                    ()
#     user&#39;s configuration directory
#
#   MEM_ALLOC_POOL, PERM_SIZE (2,048MB, 256MB)
#     Memory allocation and PermGen size
#
#   JVM                       (/usr/local/java/bin/java)
#     Java VM executable (java)
#
# By setting any of the variables above after source`ing this script
# and before invoking launch_eclipse() the default value(s) can be changed
##############################
declare ECLIPSE_INSTALL
declare CONFIG
declare MEM_ALLOC_POOL
declare PERM_SIZE
declare JVM=&quot;/usr/local/java/bin/java&quot;

##############################
# Concatenates input paramters to LD_LIBRARY_PATH, if not already present
##############################
munge_library_path() {
  for dir in $@; do
    if [ -n &quot;${dir}&quot; ]; then
      local is_present=`echo $LD_LIBRARY_PATH | grep ${dir} | wc -l`
      if [ ${is_present} -eq 0 ]; then
        export LD_LIBRARY_PATH=${dir}:$LD_LIBRARY_PATH
      fi
    fi
  done
}

##############################
# Sets up global variables with default values if not already set
##############################
check_dirs() {
  # Installation directory
  if [ -z &quot;${ECLIPSE_INSTALL}&quot; ]; then
    echo &quot;You must set ECLIPSE_INSTALL to the Eclipse installation directory&quot;
    exit -1
  fi
  if [ ! -d ${ECLIPSE_INSTALL} ]; then
    echo &quot;Cannot find Eclipse installation directory (${ECLIPSE_INSTALL})&quot;
    exit -1
  fi

  # Configuration directory, user-specific
  if [ ! -d &quot;${CONFIG}&quot; ]; then
    mkdir -p ${CONFIG}
  fi
}


##############################
# The location of the JVM, currently the default (OpenJDK 6)
##############################
locate_jvm() {
  if [ ! -e &quot;${JVM}&quot; ]; then
    echo &quot;Could not locate a valid JVM at ${JVM}&quot;
    echo &quot;Trying to locate a valid java installation&quot;
    JVM=`which java`
    if [ -z &quot;${JVM}&quot; ]; then
      echo &quot;Could not find a valid JRE, giving up&quot;
      return -1
    fi
    echo &quot;Found a JRE at ${JVM}&quot;
  fi
}

##############################
# Runs a few checks, sets up the LD library path and then launches Eclipse
#
# Param:
#   clean   will set the &#39;-clean&#39; Eclipse option that will clear the plugins cache
##############################
launch_eclipse() {
  check_dirs
  locate_jvm
  munge_library_path /usr/local/lib /usr/lib

  if [ &quot;$1&quot; == &quot;clean&quot; ]; then
    CLEAN=&quot;-clean&quot;
  fi

  $ECLIPSE_INSTALL/eclipse $CLEAN -vm $JVM -configuration $CONFIG \
      -bundlepool $CONFIG/plugins \
      -vmargs -Xmx${MEM_ALLOC_POOL:-&quot;2048M&quot;} -XX:MaxPermSize=${PERM_SIZE:-&quot;256M&quot;}
}&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This is used in the actual shell script (called, unimaginatively, eclipse):&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;#!/bin/bash
#
# Runs the stable version of Eclipse.
# By default, it will launch Indigo, installed in /opt/eclipse; different
# versions can be launched by invoking this script and setting the
# ECLIPSE_INSTALL and CONFIG variables to point to the correct places.
#
# See eclipse_config.sh for more details

source /home/marco/bin/eclipse_config.sh

ECLIPSE_INSTALL=&quot;/opt/eclipse&quot;
CONFIG=&quot;/home/${USER}/.eclipse/eclipse37&quot;

launch_eclipse&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What is left is to just point a desktop (or menu) launcher to this script and replace the generic icon with the one in the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;eclipse/ &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;folder (&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;icon.xpm&lt;/span&gt;&lt;/i&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDo3VQz8RhBMEVuoznNVwBfY9kzqJXVyCU9Au_kBKzmcXjScQsQgbFUPN9oPj1l2p1B2SkupW_f9jw9cQIsVuVhenWoOffElc6Ed6ZyPO-ZpWjr-RUprbl5G7oLJ2DIDjNsBKBbIkcNY/s1600/Indigo+Properties.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;295&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDo3VQz8RhBMEVuoznNVwBfY9kzqJXVyCU9Au_kBKzmcXjScQsQgbFUPN9oPj1l2p1B2SkupW_f9jw9cQIsVuVhenWoOffElc6Ed6ZyPO-ZpWjr-RUprbl5G7oLJ2DIDjNsBKBbIkcNY/s320/Indigo+Properties.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;CREDITS&lt;/span&gt;&lt;/b&gt; -- I would very much like to gratefully acknowledge&amp;nbsp;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Machtelt Garrels&lt;/span&gt;&lt;/b&gt; and his much-consulted &quot;&lt;a href=&quot;http://tille.garrels.be/training/bash/index.html&quot;&gt;Bash Guide for Beginners&lt;/a&gt;;&quot; I never seem able to remember the bash conditional operators!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/1359348416798891241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/08/automating-eclipse-launch.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1359348416798891241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1359348416798891241'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/08/automating-eclipse-launch.html' title='Automating Eclipse launch'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDo3VQz8RhBMEVuoznNVwBfY9kzqJXVyCU9Au_kBKzmcXjScQsQgbFUPN9oPj1l2p1B2SkupW_f9jw9cQIsVuVhenWoOffElc6Ed6ZyPO-ZpWjr-RUprbl5G7oLJ2DIDjNsBKBbIkcNY/s72-c/Indigo+Properties.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-6305739246379852766</id><published>2011-07-06T22:50:00.000-07:00</published><updated>2011-07-06T22:50:00.129-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="p2"/><category scheme="http://www.blogger.com/atom/ns#" term="updates"/><title type='text'>Eclipse (Indigo) Update site</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;When executing a &quot;clean run&quot; of Eclipse (typically, after p2 has completely messed up your installation and you&#39;ve lost critical functionality / plugins -- the only reliable remedy I&#39;ve found thus far, is to wipe ~/.eclipse, and restart from scratch) the &#39;Available Update Sites&#39; is an empty list.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Googling the information proves every time a complete random shot in the dark, so I thought I&#39;d collect the info once and for all in a place I&#39;m likely to find again in the future.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;The wiki page (impossibly difficult to find in the maze that Eclipse documentation is):&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;http://wiki.eclipse.org/Eclipse_Project_Update_Sites&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Gives this link for...&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;The Eclipse Project Updates&lt;/b&gt; - http://download.eclipse.org/eclipse/updates/3.7&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Executing an update of the Eclipse Platform, adds another &#39;update site&#39; that provides a much&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;richer selection of available plugins:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;b&gt;Indigo&lt;/b&gt; - http://download.eclipse.org/releases/indigo&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Hope this helps someone else too!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/6305739246379852766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/07/eclipse-indigo-update-site.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/6305739246379852766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/6305739246379852766'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/07/eclipse-indigo-update-site.html' title='Eclipse (Indigo) Update site'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-2555470625064754794</id><published>2011-05-24T23:27:00.000-07:00</published><updated>2011-05-24T23:28:40.864-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kvm"/><category scheme="http://www.blogger.com/atom/ns#" term="networking"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>Ubuntu: Network Manager is evil</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;Warning&lt;/span&gt;&lt;/b&gt; - this post if filled with hatred, if you believe in forgiveness, you may want to look away now.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In my book, the only sin worse than uselessness, is actively causing damage and waste of time.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What punishment ought to be meted then, to something that, having proven to be useless, causes untold waste of time.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Yes, &lt;b&gt;NetworkManager&lt;/b&gt;, and &lt;i&gt;nm-applet&lt;/i&gt;: I&#39;m looking at you two.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Quite apart from never having quite understood what use one could have for either, I have found a number of situations in which NM has caused waste of time, only the last of which has been to&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt; prevent a KVM virtual machine I just created to connect to the network&lt;/span&gt;, despite all my efforts, searching on the Web, trying out countless variations on configurations and, yes, several reboots.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I have been following along the instructions given &lt;a href=&quot;https://help.ubuntu.com/community/KVM/Networking&quot;&gt;here&lt;/a&gt;, only to be unable to connect in UserMode, barely managing (via the Bridged interface) to connect to my host machine, and totally failing to obtain any connection to the outside world.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Enter&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;sudo apt-get purge network-manager network-manager-gnome&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and, hey, presto, all is good and well, and I can happily connect from my guest OS to the Internet.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;(see also &lt;a href=&quot;http://ubuntuforums.org/showthread.php?t=527365&quot;&gt;here&lt;/a&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Simply changed my &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/etc/network/interfaces&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; file to reflect my settings (YMMV, adjust to your LAN settings) and all works just fine:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto br0
iface br0 inet static
        address 192.168.1.10
        network 192.168.1.0
        netmask 255.255.255.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Just remember to restart the network after you have made the changes:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;sudo /etc/init.d/networking restart&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Die in pain, Network Manager, and may the world be a better place without you.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/2555470625064754794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/05/ubuntu-network-manager-is-evil.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/2555470625064754794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/2555470625064754794'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/05/ubuntu-network-manager-is-evil.html' title='Ubuntu: Network Manager is evil'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-386236372220267091</id><published>2011-05-22T00:26:00.000-07:00</published><updated>2011-05-22T00:29:53.893-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="boost"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="multithreading"/><title type='text'>Creating a C++ callback function from a class instance method</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
I have been playing around with the &lt;a href=&#39;http://boost.org&#39;&gt;Boost library&lt;/a&gt; and, in particular,  the &lt;a href=&#39;http://www.boost.org/doc/libs/1_46_1/doc/html/thread.html&#39;&gt;boost::thread&lt;/a&gt; multithreading library.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
There a thread is simply created by constructing an object of type &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;boost::thread&lt;/span&gt;, and passing in to the constructor a pointer to the function to be executed in the newly spawned thread.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
There is much more to it, and I encourage you to read the documentation, but that gave me an interesting opportunity to ponder the issue of how to create a thread by instead passing in a pointer to a class&#39;s method: the need typically arises when one does not want to use global variables (which need to be guarded against race conditions) or where parameters are necessary for the execution of the method and/or return values are expected.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
Granted, the boost::thread constructor allows you to pass in up to nine parameters, so that&#39;s rarely an issue, but I just wanted to find out a reasonably general way to achieve this; it turns out that this is far from trivial, and I thought I&#39;d share my findings.  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
For the impatient, this is the solution:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;template&amp;lt;typename T, typename V, typename R&gt;
class MakeCallback {

  // Member method in T(ype), takes parameter V(alue),
  // and returns an object of type R(esult)
  // Note the parentheses around (T::*): without them, 
  // the compiler gets confused.
  typedef R(T::*func)(const V&amp;);
  func f_;
  T&amp; t_;
  V value_;
  R* res_;
public:
  MakeCallback(T&amp; type, func f, const V&amp; value, R* res = NULL) :
      f_(f), t_(type), value_(value), res_(res) { }
  virtual ~MakeCallback() { }
  void operator()() {
    if (res_)
      // Note here the parenthesis around t_.*f_ 
      // They are necessary, or a compiler error will be generated
      *res_ = (t_.*f_)(value_);
  }

  // This allows the pointer to the result value to
  // be set after the object has been created
  void set_res(R* res) { res_ = res; }
};&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
and this is how one uses it:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;int main(int argc, char[}* argv) {
  A a(33);
  int res;
  // Generally, you don&#39;t need the &amp; operator to take a function&#39;s pointer.
  // But in this case it&#39;s mandatory, or the compiler will complain
  // about doSomething() not being static.
  // In any event, the use of &amp; makes your intent clearer (you are taking
  // the method&#39;s address,
  // not invoking it) and I encourage you to use it consistently, even where
  // this is not stricly necessary.
  MakeCallback&amp;lt&gt;A, int, int&gt; mc(a, &amp;A::doSomething, 22, &amp;res);
  boost::thread do_it(mc);
  do_it.join();
  std::cout &lt;&lt; &quot;And the result is : &quot; &lt;&lt; res &lt;&lt; std::endl;

  B b;
  boost::thread another(MakeCallback&amp;lt;A, std::string, B&gt;(a, &amp;A::doSomethingElse, &quot;22.13&quot;, &amp;b));
  another.join();
  std::cout &lt;&lt; &quot;..and B is &quot; &lt;&lt; b.get() &lt;&lt; std::endl;
}&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
  given the following declarations for A and B:
&lt;/span&gt;
&lt;pre&gt;class B {
  float x;
public:
  B(float s = 0.0) : x(s) {}
  float get() { return x; }
};

class A {
  int num_;
public:
  A(int num) : num_(num) { }

  int doSomething(const int&amp; k) {
    return num_ + k;
  }

  B doSomethingElse(const std::string&amp; s) {
    double b = ::atof(s.c_str()) + num_;
    return B(b);
  }
};&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;
  A couple of points that have caused me much head-scratching and I thought it worth passing on:
  &lt;ul&gt;&lt;li&gt;you &lt;strong&gt;must&lt;/strong&gt; use the &#39;&amp;amp;&#39; operator in front of &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;A::doSomething&lt;/span&gt;, or the compiler will complain about it not being a static function;&lt;/li&gt;
&lt;li&gt;note we are, in fact, calling an &lt;strong&gt;instance&lt;/strong&gt; method: in other words, we expect to have instance-specific values stored in the class (A in this case) that our method (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;doSomething()&lt;/span&gt;) will use&lt;/li&gt;
&lt;li&gt;note also the use of a pointer (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;R* res_&lt;/span&gt;) to store the return value: &lt;strong&gt;this is important&lt;/strong&gt;; without it, the return value of the method call (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;(t_.*f_)(value_)&lt;/span&gt;) will be lost!&lt;br /&gt;
&lt;br /&gt;
&lt;iframe src=&quot;http://rcm.amazon.com/e/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=codtriandtip-20&amp;o=1&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=ss_til&amp;asins=0321334876&quot; style=&quot;width:120px;height:240px;float:right;margin-left:10px;&quot; scrolling=&quot;no&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
This is because, in the call to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;boost::thread(mc)&lt;/span&gt; the compiler automatically created a copy of our object (using the compiler-generated copy constructor; see Scott Meyer&#39;s &quot;Effective C++&quot;, Item 5)&lt;/li&gt;
&lt;li&gt;Note also the calls to &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;thread::join()&lt;/span&gt; - without them, you&#39;d have a race on the returned values: possibly reading them, before the actual method (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;doSomething()&lt;/span&gt;) had any chance of updating it;&lt;br /&gt;
&lt;/ul&gt;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;   Just to be clear, this rather trivial implementation is not meant to be used in real code (if you need something along these lines, &lt;a href=&#39;http://www.boost.org/doc/libs/1_46_1/libs/bind/bind.html&#39;&gt;boost::bind&lt;/a&gt; is what you want) but it was an interesting exercise in how to deal with generics, functors and callbacks. &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/386236372220267091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/05/creating-c-callback-function-from-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/386236372220267091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/386236372220267091'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/05/creating-c-callback-function-from-class.html' title='Creating a C++ callback function from a class instance method'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-8057182091117944341</id><published>2011-05-08T11:36:00.000-07:00</published><updated>2011-05-08T11:40:46.735-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="audio"/><category scheme="http://www.blogger.com/atom/ns#" term="skype"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>Skype on Ubuntu 10.04 - mic doesn&#39;t work</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I got the following fix from &lt;a href=&quot;http://forum.skype.com/index.php?showtopic=468941&amp;amp;st=40&quot;&gt;here&lt;/a&gt;, but it does not tell the entire story:&lt;br /&gt;
(my setup: &lt;i&gt;Acer Aspire One AO751h&lt;/i&gt;, &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Ubuntu Lucid 10.04.2 LTS&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;author_info&quot; style=&quot;float: left; font-size: 0.9em; margin-bottom: 25px; margin-left: 0px; margin-right: 0px; margin-top: 15px; padding-bottom: 0px; padding-left: 20px; padding-right: 10px; padding-top: 0px; text-align: left; width: 150px;&quot;&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #7b7f81;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;ul class=&quot;user_details&quot; style=&quot;color: #7b7f81; font-size: 0.95em; list-style-image: initial; list-style-position: initial; list-style-type: none; margin-bottom: 1.357em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;title&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 4px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;ul class=&quot;user_controls clear&quot; style=&quot;clear: both; color: #2c2c2c; list-style-image: initial; list-style-position: initial; list-style-type: none; margin-bottom: 6px; margin-left: 0px; margin-right: 0px; margin-top: 6px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;post_body&quot; style=&quot;line-height: 14px; margin-bottom: 0px; margin-left: 170px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div class=&quot;post entry-content&quot; id=&quot;&quot; style=&quot;line-height: 21px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 3px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 15px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;I had the same problem on an Acer Timeline for a long time, but the balance trick works.&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;bbc_underline&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif; text-decoration: underline !important;&quot;&gt;&lt;strong class=&quot;bbc&quot; style=&quot;font-weight: bold !important;&quot;&gt;&lt;i&gt;Solution:&lt;/i&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;A better way than changing the output balance is to use alsamixer or pavucontrol and mute one of the input channels. In alsamixer: F4 to change to recording, left/right to move to microphone, and z or c to mute one channel. In pavucontrol go to the &quot;input devices&quot; tab, unlock the channels, and mute one of the channels.&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;It seems the normal volume control uses one balance slider for all inputs and outputs together.&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The reality is that two poorly designed (and worse implemented) pieces of software interact in a way to make it virtually impossible for the average user to figure out what&#39;s going on:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Pulse Audio -- it still amazes me how a simple problem (enable audio on a PC) could be made so complicated and unusable;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Skype for Linux -- a real disgrace that a company of the might and power of Skype could let us down so badly: I just wish they had the decency of release the software open source, so we could fix it ourselves!&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Be that as it may, in addition to the &#39;fix&#39; above,&lt;b&gt; you need to also disable the &quot;Allow Skype to adjust mixer levels&quot; in the Sound Options tab of Skype&lt;/b&gt; - otherwise you can see skype continually adjusting your microphone&#39;s gain down until it gets to the point of being unaudible.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Leaving it here for future reference: I don&#39;t expect Skype to fix this anytime soon!&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/8057182091117944341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/05/skype-on-ubuntu-1004-mic-doesnt-work.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/8057182091117944341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/8057182091117944341'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/05/skype-on-ubuntu-1004-mic-doesnt-work.html' title='Skype on Ubuntu 10.04 - mic doesn&#39;t work'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-1374232657552179531</id><published>2011-04-10T00:25:00.000-07:00</published><updated>2014-01-18T19:14:39.299-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="gtest"/><category scheme="http://www.blogger.com/atom/ns#" term="unittest"/><title type='text'>Eclipse CDT and Google GTest</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you have read my &lt;a href=&quot;http://codetrips.blogspot.com/2010/05/tabularasa-interworking.html&quot;&gt;previous post&lt;/a&gt; about adding the &lt;a href=&quot;http://code.google.com/p/googletest/&quot;&gt;gTest framework&lt;/a&gt; to your C++ project, you are very likely to have spent quite some time scratching your head trying to figure out how to make it play nicely with Eclipse&#39;s CDT, and its (let&#39;s face it) not terribly well-developed concept of &#39;Build Configurations&#39;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;THIS BLOG HAS MOVED TO&amp;nbsp;&lt;a href=&quot;http://codetrips.com/&quot;&gt;codetrips.com&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Please read&amp;nbsp;&lt;a href=&quot;http://codetrips.com/2011/04/10/eclipse-cdt-and-google-gtest/&quot; target=&quot;_blank&quot;&gt;the rest of this post&lt;/a&gt;&amp;nbsp;on codetrips.com&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/1374232657552179531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/04/eclipse-cdt-and-google-gtest.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1374232657552179531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1374232657552179531'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/04/eclipse-cdt-and-google-gtest.html' title='Eclipse CDT and Google GTest'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-7226063125073509656</id><published>2011-03-26T00:59:00.000-07:00</published><updated>2011-03-26T00:59:29.045-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mobile"/><title type='text'>Mobile templates</title><content type='html'>&lt;a href=&quot;http://chart.apis.google.com/chart?cht=qr&amp;amp;chs=120x120&amp;amp;chl=http%3A%2F%2Fcodetrips.blogspot.com%2F%3Fm%3D1&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;120&quot; src=&quot;http://chart.apis.google.com/chart?cht=qr&amp;amp;chs=120x120&amp;amp;chl=http%3A%2F%2Fcodetrips.blogspot.com%2F%3Fm%3D1&quot; width=&quot;120&quot; /&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Just enabled &quot;Mobile Templates&quot; for this blog: check it out on your iPad, Android, iPhone, or mobile device: it looks really cool on my HTC Evo!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/7226063125073509656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/03/mobile-templates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7226063125073509656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7226063125073509656'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/03/mobile-templates.html' title='Mobile templates'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-5330608398028325659</id><published>2011-01-17T23:58:00.000-08:00</published><updated>2011-01-17T23:58:35.688-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="emulator"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="unittest"/><title type='text'>Run Android tests in a connected device</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Not quite sure as to why it never occurred to me, but it is totally possible and legal to run unit tests inside a real device, connected to your dev box via a USB cable.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;An obvious advantage is that you are now running your tests in a more &quot;realistic&quot; environment; there are no drawbacks that I can think of (unless your device has some weird &#39;lockdown&#39; imposed by the manufacturer / cell provider); and...&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;that&#39;s when you realize just how much faster than an emulator that is.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So here&#39;s the day&#39;s top-tip: if you are in a hurry, and have a lot of unit test you want to run, get that USB cable out!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/5330608398028325659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/01/run-android-tests-in-connected-device.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5330608398028325659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5330608398028325659'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/01/run-android-tests-in-connected-device.html' title='Run Android tests in a connected device'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-7735811420018386141</id><published>2011-01-15T00:20:00.000-08:00</published><updated>2014-01-18T19:19:23.474-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="GWT"/><category scheme="http://www.blogger.com/atom/ns#" term="mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="modules"/><title type='text'>Using the same model classes in Android, GWT and JPA (Part II)</title><content type='html'>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In a &lt;a href=&quot;http://codetrips.blogspot.com/2010/11/using-same-model-classes-in-android-gwt.html&quot;&gt;recent post&lt;/a&gt;, I&#39;ve demonstrated how one can use the same domain-specific (Model) classes end-to-end, from the Mobile layer, to the GWT Front-End, up to server-side and Persistence layer (JPA).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This blog has now been moved to &lt;a href=&quot;http://codetrips.com/&quot;&gt;codetrips.com&lt;/a&gt;: please read the rest of this post &lt;a href=&quot;http://codetrips.com/2011/01/15/using-the-same-model-classes-in-android-gwt-and-jpa-part-ii/&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/7735811420018386141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2011/01/using-same-model-classes-in-android-gwt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7735811420018386141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7735811420018386141'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2011/01/using-same-model-classes-in-android-gwt.html' title='Using the same model classes in Android, GWT and JPA (Part II)'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-2500102923211265729</id><published>2010-12-23T17:03:00.000-08:00</published><updated>2011-09-03T22:36:30.183-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="9-patch"/><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="icons"/><title type='text'>Android Draw 9-patch seems broken too</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;As far as I can tell, the current release of the Android SDK (R08) ships without the Swing Desktop jar, and this causes &lt;a href=&quot;http://developer.android.com/guide/developing/tools/draw9patch.html&quot;&gt;draw9patch&lt;/a&gt; to fail.&lt;/div&gt;&lt;pre&gt;~$ draw9patch &amp;amp;
[2] 52452
~$ Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NoClassDefFoundError:
       org/jdesktop/swingworker/SwingWorker
 at com.android.draw9patch.Application$1.run(Application.java:48)
 at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
 at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

[2]+  Done                    draw9patch&lt;/pre&gt;&lt;br /&gt;
&lt;div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaFj-GpLy-72EaizlsiDhYfDN6DhC-umhxbF9oH2zVePcrygg6rsU5PPz9hHOlbDkDLj6ULuL9p0IeDnfbrY-7qLkC_0rV7mmQqz2hi38NZQuRGFeFJzJrc1gumwvtAfF5DrlqSixUC-w/s1600/d9p.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;205&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaFj-GpLy-72EaizlsiDhYfDN6DhC-umhxbF9oH2zVePcrygg6rsU5PPz9hHOlbDkDLj6ULuL9p0IeDnfbrY-7qLkC_0rV7mmQqz2hi38NZQuRGFeFJzJrc1gumwvtAfF5DrlqSixUC-w/s320/d9p.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;The &#39;fix&#39; is rather simple: just download the JAR for Swing Desktop from &lt;a href=&quot;http://download.java.net/javadesktop/swinglabs/releases/0.8/&quot;&gt;here&lt;/a&gt;, and drop the &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;swinglabs-0.8.0.jar&lt;/span&gt; file into the &lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;[sdk-install-dir]/tools/lib&lt;/span&gt; folder.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The Swing Desktop project can be found &lt;a href=&quot;https://javadesktop.dev.java.net/&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;b style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Update&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; -- Richard just left a comment here and pointed me to &lt;/span&gt;&lt;a href=&quot;http://android9patch.blogspot.com/&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;his site&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;Android 9 Patch&lt;/i&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;) who&#39;s got plenty of 9-patch icons that really look awesome, and I thought I&#39;d share the goodness (especially, given he&#39;s so kind as to share them at no charge).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Go check out &lt;a href=&quot;http://android9patch.blogspot.com/2011/09/android-9-patch-pack-15-glass-madness.html&quot;&gt;Patch 15&lt;/a&gt;, it&#39;s pretty impressive!&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/2500102923211265729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2010/12/android-draw-9-patch-seems-broken-too.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/2500102923211265729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/2500102923211265729'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2010/12/android-draw-9-patch-seems-broken-too.html' title='Android Draw 9-patch seems broken too'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaFj-GpLy-72EaizlsiDhYfDN6DhC-umhxbF9oH2zVePcrygg6rsU5PPz9hHOlbDkDLj6ULuL9p0IeDnfbrY-7qLkC_0rV7mmQqz2hi38NZQuRGFeFJzJrc1gumwvtAfF5DrlqSixUC-w/s72-c/d9p.png" height="72" width="72"/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-7859025295479868309</id><published>2010-12-23T13:35:00.000-08:00</published><updated>2010-12-23T13:35:46.499-08:00</updated><title type='text'>Carrier BIlling comes to Android!</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Some of you folks may have recently noticed a little remark at the bottom of an email from the Android Market folks:&lt;/span&gt;&lt;/div&gt;&lt;blockquote style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Finally, we wanted to bring to your attention that Android Market now offers a new form of payment for users on the AT&amp;amp;T network -- Direct Carrier Billing. This payment option lets Android users on the AT&amp;amp;T network purchase applications more easily.&lt;/span&gt;&lt;/i&gt;&lt;/blockquote&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;This is an awesome achievement on the part of the Google folks, which integrates payments made by users into their phone bills, if they are AT&amp;amp;T customers: in turn, this enables us (the developers) to receive our payments via fewer user clicks and in a more streamlined way, so as to smooth the path for the user to purchase our Apps.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;And all that, at virtually no additional complexity for us, which is, I&#39;d say, pretty awesome!&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;I would expect more integrations and more awesomeness in the next few months: stay tuned!&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/7859025295479868309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2010/12/carrier-billing-comes-to-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7859025295479868309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/7859025295479868309'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2010/12/carrier-billing-comes-to-android.html' title='Carrier BIlling comes to Android!'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-5156576634897446216</id><published>2010-12-08T23:32:00.001-08:00</published><updated>2010-12-10T14:41:18.886-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="emulator"/><category scheme="http://www.blogger.com/atom/ns#" term="sdk"/><title type='text'>Latest update for Android SDK breaks for Ubuntu Karmic</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If you have recently updated your Android SDK to R08 (Gingerbread, 2.3) on Linux and are using Ubuntu Karmic, chances are that &lt;a href=&quot;http://ubuntuforums.org/showthread.php?t=1640029&quot;&gt;you will not be able to run the emulator&lt;/a&gt;: It will simply die with the following error:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;,Courier,monospace;&quot;&gt;$ ./emulator&lt;br /&gt;
./emulator: /lib32/libc.so.6: version `GLIBC_2.11&#39; not found (required&amp;nbsp;by ./emulator)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;This is caused by an incompatibility with Karmic&#39;s installed GLIBC - the new SDK/Emulator works just fine on Lucid.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The Android team is working on a fix - in the meantime, a workaround is to download the &lt;i&gt;_r07&lt;/i&gt; of the tools from &lt;a href=&quot;http://dl.google.com/android/repository/tools_r07-linux.zip&quot;&gt;here&lt;/a&gt;, and replace &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;,Courier,monospace;&quot;&gt;emulator&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt; in the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;,Courier,monospace;&quot;&gt;tools/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt; folder under the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;,Courier,monospace;&quot;&gt;android_sdk&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt; installation folder.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;A bit hacky, but works.&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/5156576634897446216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2010/12/latest-update-for-android-sdk-breaks.html#comment-form' title='21 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5156576634897446216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5156576634897446216'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2010/12/latest-update-for-android-sdk-breaks.html' title='Latest update for Android SDK breaks for Ubuntu Karmic'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>21</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-8009225103390951215</id><published>2010-11-30T22:38:00.001-08:00</published><updated>2010-11-30T22:45:44.289-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="boost"/><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>Using Boost in Ubuntu with Eclipse</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Boost&lt;/span&gt;&lt;/b&gt; is an open source library of extremely useful and carefully designed C++ classes and methods ranging from graph algorithms, to regular expressions matching, to multi-threading.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Part of the Boost library was also integrated into the C++ standard as the TR1 set of libraries.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You can learn more about Boost &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;a href=&quot;http://boost.org/&quot;&gt;here&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Using it with Eclipse in Ubuntu is definitely possible, but not straightforward; so I decided to post this simple tip here, to help folk spare some of the grief.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The first step in using Boost in your code is to download the header (.hpp) files and (optionally) source code - the latest release is 1.45 and is available from Boost&#39;s website.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In theory, you could compile it, and build the libraries&#39; binaries yourself: by all means, go ahead and do it, but there is an easier way, if you can live with a slightly &#39;older&#39; version.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Ubuntu 9.10 (Karmic Koala) comes with Boost 1.34 pre-configured (I think, this is, at any rate, the version that I had on my system):&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;$ ls /usr/lib/libboost*
/usr/lib/libboost_date_time-gcc41-1_34_1.so.1.34.1
/usr/lib/libboost_date_time-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_date_time-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_date_time-gcc42-mt-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc41-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc42-mt-1_34_1.so.1.34.1
/usr/lib/libboost_iostreams-gcc41-1_34_1.so.1.34.1
/usr/lib/libboost_iostreams-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_iostreams-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_iostreams-gcc42-mt-1_34_1.so.1.34.1
/usr/lib/libboost_regex-gcc41-1_34_1.so.1.34.1
/usr/lib/libboost_regex-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_regex-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_regex-gcc42-mt-1_34_1.so.1.34.1
/usr/lib/libboost_signals-gcc41-1_34_1.so.1.34.1
/usr/lib/libboost_signals-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_signals-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_signals-gcc42-mt-1_34_1.so.1.34.1
/usr/lib/libboost_thread-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_thread-gcc42-mt-1_34_1.so.1.34.1&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;However, by using Synaptic, you can actually install the more recent&amp;nbsp;1.40.0&amp;nbsp;version:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Xd02zaayk68Fe2JVxnmuDIhFR4eh8swAyAS2cJZuavvlM-NhR7SEAwq5C_YrteEcDSUMiJQcNQp_rJFGJVooQfe6-2b6MTjKhxZGFiAorpJbGkotsGBc_5RQU_zW1EytadW6IOGYt-g/s1600/screenshot_001.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Xd02zaayk68Fe2JVxnmuDIhFR4eh8swAyAS2cJZuavvlM-NhR7SEAwq5C_YrteEcDSUMiJQcNQp_rJFGJVooQfe6-2b6MTjKhxZGFiAorpJbGkotsGBc_5RQU_zW1EytadW6IOGYt-g/s320/screenshot_001.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This will install a bunch of &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;libboost_*.so.1.40.0 &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;files into &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/usr/lib&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;: in order to match the libraries with the header files (and avoid introducing incomprehensible compilation errors at best, and subtle bugs at worst) you should download the matching &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;boost_1_40_0.tar.bz2 &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;from Boost &lt;a href=&quot;http://www.boost.org/users/history/&quot;&gt;download archives&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We would be almost there, were it not for the fact that the&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; white-space: pre;&quot;&gt;soname &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;does not really comply with the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-l&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; gcc linker option.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In gcc the &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-L&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; option specifies a &#39;search directory&#39; (this would not be needed, as /usr/lib is searched for libraries by default) and the -l specifies additional dynamic (.so) or static (.a) libraries: you specify the file to include during the link step by omitting the `lib` prefix and the .so or .a extension.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In other words, if your HelloBoost source uses code from Boost Regex (libboost_regex.so) you would specify it like thus:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;$ gcc -Wall hello_boost.cc -o HelloBoost -lboost_regex&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You can see where I&#39;m heading with all this: the last step will be to add symbolic links that do away with the soname suffixes of Boost libraries, and all will be well:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;$ ln -s /usr/lib/libboost_regex.so.1.40.0 /usr/lib/libboost_regex.so&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Given that there are in total 24 files for the whole of Boost 1.40, I&#39;ve done a bit of find &amp;amp; replace magic, and have come up with the following&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;shell file (the other advantage being that, when a later version becomes available for Ubuntu, I will not have to change any of my Eclipse projects setting, but just change the VERSION value in the script):&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;#!/bin/bash
#
# Simple script to enable Boost with simple -l gcc option
# Use: gcc -Wall hello_world.cc -o HelloWorld -lboost_regex
#
# Created by M. Massenzio, 2010-11-30

VERSION=1.40.0

for libname in libboost_date_time \
            libboost_filesystem \
            libboost_graph_parallel  \
            libboost_graph      \
            libboost_iostreams  \
            libboost_math_c99f  \
            libboost_math_c99l  \
            libboost_math_c99   \
            libboost_math_tr1f  \
            libboost_math_tr1l  \
            libboost_math_tr1   \
            libboost_mpi        \
            libboost_prg_exec_monitor \
            libboost_program_options  \
            libboost_python-py25      \
            libboost_python-py26      \
            libboost_regex            \
            libboost_serialization    \
            libboost_signals          \
            libboost_system           \
            libboost_thread           \
            libboost_unit_test_framework \
            libboost_wave \
            libboost_wserialization 
do
  ln -s /usr/lib/$libname.so.$VERSION /usr/local/lib/$libname.so
done
&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The last and final step is to tell Eclipse what to look for when building your binary: right-click on your project&#39;s folder (in the C++ Perspective, Project Explorer) then Properties &amp;gt; C/C++ Build &amp;gt; Settings, select GCC C++ Linker &amp;gt; Libraries and add the &#39;stripped&#39; library names in the option list:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlBWfr8GVhNS_YsyvF1lund9V6vP5X_gr358-biM3fKa8_yqW-FV3lbeI4NGwyXLacuEPmF0bFWk3nEz6Y3HUNKMh3yMsYKss4cVHsp5iObgAN5__jKP2fnL5F08NnFX0OHDkXVXiYyoo/s1600/screenshot_001.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;241&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlBWfr8GVhNS_YsyvF1lund9V6vP5X_gr358-biM3fKa8_yqW-FV3lbeI4NGwyXLacuEPmF0bFWk3nEz6Y3HUNKMh3yMsYKss4cVHsp5iObgAN5__jKP2fnL5F08NnFX0OHDkXVXiYyoo/s320/screenshot_001.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif; font-size: x-small;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Note for the curious&lt;/span&gt;: the additional libraries listed there are for Google C++ Unit testing framework, GUnit, available &lt;a href=&quot;http://code.google.com/p/googletest/&quot;&gt;here&lt;/a&gt; - you will have to build it, but that&#39;s pretty straightforward, resulting in the two libgtest.a and libgtest_main.a libraries - be careful to add those only to your &#39;Test&#39; configuration and exclude your unit tests from build in your Release/Debug configurations.&lt;/i&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/8009225103390951215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2010/12/using-boost-in-ubuntu-with-eclipse.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/8009225103390951215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/8009225103390951215'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2010/12/using-boost-in-ubuntu-with-eclipse.html' title='Using Boost in Ubuntu with Eclipse'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Xd02zaayk68Fe2JVxnmuDIhFR4eh8swAyAS2cJZuavvlM-NhR7SEAwq5C_YrteEcDSUMiJQcNQp_rJFGJVooQfe6-2b6MTjKhxZGFiAorpJbGkotsGBc_5RQU_zW1EytadW6IOGYt-g/s72-c/screenshot_001.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-5550377750007618276</id><published>2010-11-23T00:20:00.000-08:00</published><updated>2011-01-19T23:01:52.033-08:00</updated><title type='text'>Using the same model classes in Android, GWT and JPA</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;These days, it is rather common to have a mobile-enabled web service or application, where you essentially enable your users to access the service both via a browser-enable desktop application, as well as from their mobiles whilst on the go.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;It&#39;s usually the case that the main business logic, as well as the business Model, are shared between the browser components and your mobile app: however, it is not obvious how to re-use code (or even use the &lt;b&gt;same&lt;/b&gt;&amp;nbsp;source code) when you are essentially using two completely separate SDKs, and even different JREs!&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In fact, if you are using Google Web Toolkit on the&amp;nbsp;front-end, there&#39;s not even a JRE involved: as your classes will be compiled in&amp;nbsp;JavaScript.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This short video shows how you can actually use the very same source files in all three layers, so that when you make changes (fix bugs, add functionality) the improvements are immediately reflected everywhere - and even better, you avoid subtle bugs that may be caused by inadvertently the code going &quot;out-of-sync&quot; in one of the layer.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The example is based on my &lt;a href=&quot;http://sites.google.com/site/androidreceipts&quot;&gt;&lt;b&gt;Android Receipts&lt;/b&gt;&lt;/a&gt; application, which can also be freely downloaded in Android Market.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;object height=&quot;344&quot; width=&quot;425&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/6R9rkaotBHI?hl=en&amp;fs=1&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/6R9rkaotBHI?hl=en&amp;fs=1&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Please let me know what you think, and whether you are finding the videos useful - or you prefer the written word!&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #e06666;&quot;&gt;Update&lt;/span&gt;&lt;/b&gt; &amp;nbsp; &amp;nbsp;Someone commented on the low resolution of the video (480p) as making it difficult to follow: I understand, and, in fact, the original video was at a higher res (&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;720x576, 25 fps)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;: unfortunately, uploading to YouTube the resolution gets dropped during the transcoding.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Disappointing, I know, but hardly something I can do anything about.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I would suggest instead to see also &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;a href=&quot;http://codetrips.blogspot.com/2011/01/using-same-model-classes-in-android-gwt.html&quot;&gt;Part II&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; of this tutorial, which further elaborates on the topic, and provides some code samples.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/5550377750007618276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2010/11/using-same-model-classes-in-android-gwt.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5550377750007618276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/5550377750007618276'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2010/11/using-same-model-classes-in-android-gwt.html' title='Using the same model classes in Android, GWT and JPA'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6167393459950006179.post-1503185548662149709</id><published>2010-11-20T23:59:00.016-08:00</published><updated>2010-11-21T20:54:57.871-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="sensor data"/><category scheme="http://www.blogger.com/atom/ns#" term="temperature"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>Dump CPU temperature data to a file in Ubuntu</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;Update&lt;/span&gt;&lt;/b&gt;: I&#39;ve figured out that it makes a lot more sense to have a reading of the CPU load to correlate with the temperature reading, so I&#39;ve added that too using /usr/bin/uptime.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I have written a very simple Java utility to take readings from the CPU temperature sensors utility (/usr/bin/sensor) and dump it to a CSV file.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Although of fairly limited utility, I just wanted to see how to run a binary from Java and capture its output - and, let&#39;s face it, it is a rainy Saturday in Silicon Valley this afternoon and I&#39;d just installed &lt;a href=&quot;http://www.amazon.com/gp/product/B000JSFZPS/ref=oss_product&quot;&gt;this new CPU cooler&lt;/a&gt; and just felt like doing some fuzzying around.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;All the code, javadocs and a full working jar are available from &lt;a href=&quot;http://www.alertavert.com/home/downloads&quot;&gt;the usual place&lt;/a&gt;, just remember to create a &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;sensor.properties&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;file under a &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;.sensors&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; directory in your home dir.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000; font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;Configuring and Running the program&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The program itself can be run from the command line with:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;$ java -jar sensors_0.1alpha.jar&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and a simple properties file looks something like:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;# Configuration file for the sensor data storage utility
#
# Created by M. Massenzio, 2010-11-20

sensors.data.file=/home/marco/tempdata/sensors.data.csv
sensors.data.timestamp.format=hh:mm:ss
sensors.cores=2
sensors.interval.msec=60000

# Default is /usr/bin/sensors, change it here if your installation is different
sensors.command=/usr/local/bin/sensors
&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The data is appended at the end of the CSV file, so it&#39;s ok to leave the property unchanged between runs, or even have this run regularly from a cron job (you&#39;ll have to do a bit of shell magic to find out it PID and have another job kill it after a given time).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Obviously, an improvement to be to have an additional property configuration to have it terminate after a given amount of time (or a set number of readings).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you have ideas how to improve this (the obvious next step would be to add a simple JDBC adapter and dump the data on a MySQL database) and/or make changes to the code, please let me know!&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000; font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;The Code&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The source code itself is packaged inside the JAR, and consists of a single class, where everything happens, to an extent, just inside the main() method (although, there&#39;s a &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Runnable&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; thrown in to be run as a &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TimerTask&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;, so it&#39;s not as banal as it sounds!).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000; font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;Executing an external command&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Running a &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Process&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; from inside Java code, is a simple matter of executing:&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;String sensorProcessLocation = System.getProperty(&quot;sensors.command&quot;, 
    &quot;/usr/bin/sensors&quot;);
Process p = Runtime.getRuntime().exec(sensorProcessLocation);
LineNumberReader reader = new LineNumberReader(
    new InputStreamReader(p.getInputStream()));&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The last lines captures &lt;i&gt;the output&lt;/i&gt; from the process (I know, blatantly confusing) and you can then use to &#39;pipe&#39; its output into your code for processing. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;The RegEx to parse the output&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Although the output from sensors would be pretty easy to parse &#39;by hand&#39; I thought it much more elegant to use a Regular Expression, and also throw in the concept &#39;capturing groups&#39; to have an orderly output (although, it&#39;s a safe bet sensors will consistently output the temperature readings in &#39;sorted cores order&#39;):&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;REGEX = &quot;Core([01]).*\\+([0-9.]*).*&quot;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
will correctly parse output from the version of sensors installed on my distro (Ubuntu 9.10, Karmic Koala):&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;$ lsb_release -a
   No LSB modules are available.
   Distributor ID: Ubuntu
   Description: Ubuntu 9.10
   Release: 9.10
   Codename: karmic
 $ sensors
   k8temp-pci-00c3
   Adapter: PCI adapter
   Core0 Temp:  +42.0°C                                    
   Core1 Temp:  +39.0°C&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
This is the code that parses the output from sensors, and puts the correct reading in the respective core&#39;s array slot:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;Pattern p = Pattern.compile(System.getProperty(&quot;sensors.data.regex&quot;, 
             REGEX));
  Matcher m = p.matcher(reading);
  if (m.matches()) {
    int core = Integer.parseInt(m.group(1));
    if (core &amp;lt; coreTemps.length) {
       coreTemps[core] = Float.parseFloat(m.group(2));
     }
  }&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt; The rest of the code (available inside the Jar to download, alongside with the javadoc in the /apidocs folder) is pretty much simple housekeeping. &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetrips.blogspot.com/feeds/1503185548662149709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetrips.blogspot.com/2010/11/dump-cpu-temperature-data-to-file-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1503185548662149709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6167393459950006179/posts/default/1503185548662149709'/><link rel='alternate' type='text/html' href='http://codetrips.blogspot.com/2010/11/dump-cpu-temperature-data-to-file-in.html' title='Dump CPU temperature data to a file in Ubuntu'/><author><name>Marco Massenzio</name><uri>http://www.blogger.com/profile/07909737351121376431</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Z-dvdGmW6WVLNJHiwaQywHkCebIZxAssC1I7BWbhH9Amy5qxATaNvXBQAcPQhQhMWWe7_ZqPjP4WX3BmagZBNGWiAA5QDjCuM2QGG7IC_fSps8vLc7TzceWm-rFbJqg/s220/DSCF2220.JPG'/></author><thr:total>0</thr:total></entry></feed>