Saturday, June 18, 2011

Recovering from Pathetic Presentation Disorder

I am constantly reminded of how important a presentation needs to be, in order to convey my message across. What I tend to forget, however, is that people tend to want to engage with ME, and not with my slides!

These quick 4 tips should be always in my mind...

1. Follow the 10/20/30 rule: Ten slides maximum, 20 minutes of content, and 30 point font. Design your presentation, knowing that people don't care how many salient points you convey per slide. They want to engage with YOU. The slides serve as supporting documents.

2. Tell a story. Why did you launch your company? What inspired or angered you or motivated you to leave your comfort zone? Share a customer situation that you helped improve--or better yet, share a mistake you once made and how it transformed you.

3. Lead the audience to action. Your job is to share a dream and inspire others. Summary pages are NOT calls to action. Incite your listeners to do something differently or to think in a new way.

4. Practice and enjoy talking to yourself. 

mysqldump and utf8 encoded databases...

I tried everything, but all my dumps where coming in with garbled characters. The solution ended up being:

>mysqldump -r database_full_backup.sql --default-character-set=latin1 --user=USERNAME --password=PASSWORD --opt DATABASE NAME


Note that the expected is -default-character-set=utf8, but this is a known bug I guess.

Risks, groups and other rambles…

I’ve continued my exploration on the research of managing tradeoffs between conflicting goals, and how to deal with catastrophic risks. The latest batch of papers that I’ve printed out, include a couple of 1950’s paper on economics and sociology. And they are amazing. How did I go from wireless networks to this again? :)

Perception of risk it seems, is a combination of objective risk and subjective factors. By objective, I mean historical analysis of the likelihood of events occurring. But in real life, humans are driven by subjective reasoning. Example? Better to think more sticks are snakes than to accidentally step on the one that bites you, even if the probability tends to zero for snakes in that particular region. So humans, it seems, instinctively weigh bad situations. Although an algorithm might calculate an optimal decision, humans will choose the most satisfactory option. The gist of it all is that, modeling (analytical modeling, that is) simplifies extremely complex parameters into simplified/unified equations. While it looks great on paper, in real scenarios, it will break. I’ve been forced to question even basic probability analysis and modeling… and fuzzy logic, and uncertainty-based multiple-criteria decision mechanisms have become my hobby for the last couple of weeks. Hopefully, at the end of this tunnel, I’ll have an amazing discovery, papers and PhD degree.

Mathematician G. H. Hardy once wrote “Good work is not done by ‘humble’ men. It is one of the first duties of a professor, for example, in any subject, to exaggerate a little both the importance of his subject and his own importance in it. A man who is always asking ‘Is what I do worthwhile?’ and ‘Am I the right person to do it?’ will always be ineffective himself and a discouragement to others. He must shut his eyes a little and think a little more of his subject and himself than they deserve. This is not too difficult: it is harder not to make his subject and himself ridiculous by shutting his eyes too tightly.” So I, too, believe that my research is the best you’ll ever see/read. :)

Which leads me to a non-related topic: groups are hot theses days. It makes sense for mobile app developers to appeal to user groups instead of individuals, for reasons of adoption and relevance. A group-based app is likely to attract at least one more user for every individual it attracts.. if you use it, you’ll pitch your idea to a friend, right? And if apps can attract users in batches, more revenue. Me, Peter and Vaibhav have been reading on some social networking papers to see how we can explore this… If we are able to better evaluate the social matrix within which any app operates, we would be able to allow for more relevant personalized recommendations and more successful advertising and marketing campaigns. Adding social game methods to this allows for a great win-win situation, since users win, due to the fact that the group provides continued usefulness for the apps in question. Another topic that has been raised in our brainstorms is that of affinity groups, or “networks within networks”, which would bring people with common interests together. This could be focused on professions (teaching, law, medicine), demographics (seniors, students, ethnic groups), geography (cities, states, countries), etc.

Thought of the day: Don’t be average. Be creative, be bold, experiment, and adjust your approach to the ever-changing realities of the world. Perseverance is key.

[OS X] Could not find install_name_tool, please check your installation…

I’ve been (re)setting up my android development environment and, as expected, things aren’t as straightforward on a mac as expected. The last step has been to setup the latest ndk and android-opencv. This required me to install and configure the latest android cmake. All was going fine until I hit the following snag while trying to test out everything…

talmai@~/android-cmake/samples/hello-cmake/androidbuild: cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN ..
-- Found SWIG: /opt/local/bin/swig (found version "2.0.1")
-- The C compiler identification is GNU
CMake Error at /opt/local/share/cmake-2.8/Modules/CMakeFindBinUtils.cmake:71 (MESSAGE):
Could not find install_name_tool, please check your installation.



Solution? Run ‘ccmake’ instead of ‘cmake’ and update your ‘install_name_tool’ entry to ‘/usr/bin/install_name_tool’ (or wherever it is in your system).

[OS X] opencv android woes…

So I’ve been trying to build the opencv library for android. First I tried using the experimental branch, which relies on the latest NDK r5b. However, after a couple of hours trying to get android-cmake to compile correctly, I realized my life is worth more than this… and now am using the customized android NDK r4 with enabled support of C++ exceptions, RTTI and Standard C++ Library (Crystax.net), and compiling opencv myself.

As a side-note, for some strange reasons, using NDK r5b my libraries (*.so) were on average 4x smaller than anything built using android-cmake. *AND* they worked, whereas the cmake’d ones would panic.


Anyhow…. I’ve checked out opencv from the svn, and came up on a strange error while compiling alloc.c (opencv_core module):

cc1plus: error: ~/opencv/android/../modules/index.rst/include: Not a directory


Solution? Check out your android-opencv.mk. One of the arguments is “$(OPENCV_ROOT)/modules/index.rst/include”. Remove that and you’re good to go…

What Does It Mean To Be An Entrepreneur?

In the simplest of terms, an entrepreneur is someone who sees what no one else sees, and takes action towards the implementation of their idea. To be an entrepreneur, therefore, one must be able to construct new ideas (and not just propose them) while adding and creating value. Motivated by a subjective concept of self-accomplishment and self-fulfilment, an entrepreneur is unable to stay put. As creative ideas flow into their minds, they take action. A successful entrepreneur, however, is able to organize such ideas, and is focused enough to implement them in a well planned and thought out flow. Natural leaders, they exert passion for what they do, and influence those around them. Most importantly, however, they (re)direct their efforts towards real market necessities, and are always worried in making their products/services better than existing competitors.

Nevertheless, not all entrepreneurs will become a business owner. Their real “success” metric is how positive of an impact they have on their domain/knowledge area. They love what they do, even if this means they embrace their current jobs. Entrepreneurial employees are well-versed professionals who share the passion of the business owners, and are capable of seeing their same vision. They work had at bringing that vision to life. Co-workers are admired by their talent and how they want to be part of something bigger than themselves, rather than a common egocentric view of being `all about them’. Ventures and businesses are ultimately, a team sport. A wise entrepreneur knows this, and genuinely want to be part of the team for the long haul, rather than being a “free agent” who wants to get out fast without adding value and meaning to their work.

Founders, obviously fit the definition of a entrepreneur: they see something no one else does. They take actions towards creating something big from nothing. They surround themselves with extremely talented performers. As Steve Blank once wrote, “This concept of creating something that few others see — and the reality distortion field necessary to recruit the team to build it — is at the heart of what startup founders do. It is a very different skill than science, engineering, or management.‘ Tenacious and agile, they are capable of improvising towards bringing order out of chaos. But most of all, they are resilient, and have a relentless focus on execution.

As once said, ”Both founders and entrepreneurial employees prefer to build something from the ground up rather than join an existing company. Like jazz musicians or improv actors, they prefer to operate in a chaotic environment with multiple unknowns. They sense the general direction they’re headed in, OK with uncertainty and surprises, using the tools at hand, along with their instinct to achieve their vision. These types of people are rare, unique and crazy. They’re artists.

There is, however, one thing that is unteachable and is not genetically passed on from entrepreneur to entrepreneur, and that is opportunity. While there exists a large number of entrepreneurs in the world, not all are rich, or well-known, or fulfilled. Some have had great ideas, but fell hard on unfavourable circumstances. And while not every entrepreneur has stopped because of this, having a opportunity certainly played a large role. They continue to be, however, “entrepreneurs”, and brand their flags with joy at all times.

I am an entrepreneur.. are you?

Your phone has more computing power than all of NASA in 1969. What extraordinary thing have you done today? #noexcuses

I’ve been pushing myself to finish my PhD before 2012. This has been due, in part, to some internal departmental factors inside the CS department at UC. But, I’ve been reading quite a few Economics and Mathematical System papers, and when modeling my life (from an Economics point of view), I’ve come to the conclusion that every year pursuing my PhD, is costing me quite a lot of money. Far from living my life based on money, but this makes quite an impact when you look at the numbers… One could argue that I am basing myself on the expectation of what I could be earning… but, either way, I’m using this as an extra incentive.

I’m taking on a very focused attitude on “no excuses” as well. I’ve been swimming at least 3x a week to get back in shape, coding away at work and for my simulations, and writing papers like there’s no tomorrow… If you lost your way and ended up here today, good for you. Take up the #noexcuses challenge with me and leave comments with your results!

How to dynamically populate a mx:Tree control in Flex

While I think that Flex gives me an unbelievable boost in quickly developing sweet UIs for my web projects, sometimes it just gets on my nerve. My latest problem has a very simple solution… too bad it took me over 20 minutes to get it to work. I found a couple of solutions online that recommended modifying your view/controller to output specially formatted XML. So for example, I’d have to modify my view to output something like:

<?xml version=”1.0″ encoding=”UTF-8″ ?>
<TREEDATA>
<NODE  LABEL=”Ricin”>
<NODE LABEL=”Plate Maps”/>
<NODE LABEL=”Detector Data”/>
<NODE LABEL=”Data Analysis”/>
</NODE>
</TREEDATA>

This, I refused to do. The fact that I am using Flex today, does not mean I’ll use it tomorrow. So I prefer to keep my view outputs following my standard XML format. So then I started playing with the XML data that arrives at the Flex frontend, and see how I could modify it to magically work with the mx:Tree. This, I expected, would be really quick, since I would just grab the XML, parse out what I wanted, and set it as to the dataProvider of the Tree. So my first version looked something like this:


var parsedData:ArrayCollection = new ArrayCollection();
var i:int;
for (i = 0; i < currentXml.PlateMap.length(); i++)
{
var treeXml:XML = <plateMap></plateMap>;
treeXml.label = String(currentXml.PlateMap[i].CompoundRequest.ScreenProjectName)
parseData.addItem(treeXml);
}
listing.dataProvider = parseData;
listing.dataProvider.refresh();



This didn’t work (although it has work for mx:List)… So after a lot of useless tests, I finally got it work…

var xmlPlateMap:ArrayCollection = new ArrayCollection();
var i:int;
for (i = 0; i < currentXml.PlateMap.length(); i++)
{
var xmlString:String =
“<node label=’” + String(currentXml.PlateMap[i].ScreenProjectName) + “‘>” +
“<node label=’Plate Maps’/>”+
“<node label=’Detector Data’/>”+
“<node label=’Data Analysis’/>”+
“</node>”;
xmlPlateMap.addItem(new XML(xmlString));
}
listing.dataProvider = xmlPlateMap;
listing.dataProvider.refresh()



Hope this helps someone else out… 

Removing Page Numbers from Latex document

This should be easier, right? But no, with such a powerful document preparation system and TeX typesetting program, authors have too much power in their hands (or document class/style file). A simple suggestion is to use \thispagestyle{empty} after \maketitle tag to overwrite the style file and remove the page numbers. However, some style files will over-power this approach and still print the page numbers on all pages (except the first one).

My suggestion? add \pagestyle{empty} tag and the page numbers from all the pages will be removed. So your final code will be:


\maketitle
\thispagestyle{empty}
\pagestyle{empty}

Innovation and habits...

Great read!

Thinking habits that stand out: (1) Mental time travel (2) Seeing the interconnected system (3) Frame-shifting (4) Disruptive mindset and (5) Influence.

- As Albert Einstein once said, “It’s not that I’m so smart, it’s just that I stay with problems longer.”

-  ”Outthinkers” seem to think in terms of a system, often a simplified one that keeps them focused on what is most important.

- Innovative thinkers shift their perspectives more often, drawing from a more diverse set of experiences, than the rest of us. They are able to handle more complexity and ambiguity because they recognize more patterns.

- “Outthinkers” think not just about what customers will want but also about what competitors will not pursue. Understanding both allows them to see the white space, the uncontested territory.  It is not enough to know your customer. You must grow equally acquainted with your competition and then focus on the few unique opportunities your competition will not defend or respond intelligently to.

- Innovators are nothing more than dreamers if they cannot convince others to live out their dreams. It is only when others believe in and act upon their dream that it becomes reality. They speak in the same language, use the same metaphors, appeal to the same values of the people they are seeking to win the support of.

How can God let bad things happen?

On September 13, Anne Graham Lotz, the daughter of the Reverend Billy Graham, appeared on on CBS’s Early Show. She was interviewed by Jane Clayson, and an interesting question was asked of her regarding terrorist plots and what-not…

Jane Clayson: I’ve heard people say, those who are religious, those who are not, if God is good, how could God let this happen? To that, you say?

Anne Graham Lotz: I say God is also angry when he sees something like this. I would say also for several years now Americans in a sense have shaken their fist at God and said, God, we want you out of our schools, our government, our business, we want you out of our marketplace. And God, who is a gentleman, has just quietly backed out of our national and political life, our public life. Removing his hand of blessing and protection. We need to turn to God first of all and say, God, we’re sorry we have treated you this way and we invite you now to come into our national life. We put our trust in you. We have our trust in God on our coins, we need to practice it.

It is interesting and rather logical to say that we cannot simultaneously reject God in our daily lives yet still expect His protection when disaster strikes. I remembered all of this during this last week, when our car slid off the highway into a couple of snow banks, then our furnace broke down, which led to our water freezing in our pipes and all the whole enchilada of an emotional roller coaster that came with all of this *excitement*.

At the end of all of this, me and Raquel reflected on how lucky we were, despite all things. No broken bones, no flooded house… nothing but a couple of worried nights and bruised muscles. Thank you God for taking such good care of us.

Altering telosb transmission range in TinyOS 2.0

It all started when I read this post, where it stated the obvious (to reduce the transmission range you have to reduce the transmission power). And although it provided some basic instructions, I thought I would just put up some more code for those who aren’t as savvy as most.
The first option in Tinyos 2, with a platform with the cc2420 (such as MicaZ and the Tmotes), is to statically set a flag in the makefile:

CFLAGS += "-DCC2420_DEF_RFPOWER=1"


An option, but not the one I was looking for. To set it dynamically for every packet, this is what we need to do. In your main configuration, wire in the CC2420PacketC:


implementation
{
components CC2420PacketC;

App.CC2420Packet -> CC2420PacketC;
}


In your main application:


module ClientAppP @safe()
{
uses interface CC2420Packet;
}



And finally, the call to CC2420Packet.setPower() passing in the power with values within the range of 0 to 31. (Although with my motes, it only worked from 1 up…)


ClientPacket* msg = (ClientPacket*)(call Packet.getPayload(&pkt, NULL));

...

call CC2420Packet.setPower(&pkt, 1);
if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(ClientPacket)) == SUCCESS)

Where the heck is “jni.h” on OSX?

I’ve been trying to get tinyos to run on my snow leopard machine (10.6.5) and got hit with a rather unexpected error message…


g++ -O2 -bundle "-I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" \
-o libtoscomm.jnilib NativeSerial_darwin.cpp
In file included from NativeSerial_darwin.cpp:521:
TOSComm_wrap.cxx:32:17: error: jni.h: No such file or directory



Thinking this must’ve been a mistake, I even rebuilt everything from scratch (thought it was a missing environment variable or something). But no, to my surprise “jni.h” is not bundled with OSX. At least not before you install the dev package.

g++ -O2 -bundle "-I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" \
"-I/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers" \
-o libtoscomm.jnilib NativeSerial_darwin.cpp



Good to go… 

Does peace and contentment have more to do with the pace of life or with the conditions in which I live?

I have been reading Dr. Wess Stafford’s book entitled Too Small to Ignore, and have had some interesting reflections. Wess Stafford is the President of Compassion International. The book is written to inspire every single one of us to care for the young ones of this world – the poverty stricken, disease carrying, hurt and uncared for children in this world. As one reads, however, one learns that there is much additional wisdom to soak up and apply to a variety of aspects of day-to-day life. What has struck me was one chapter regarding time, and while I am absolutely sure that I will need to get permission to post this online, I have not (yet), so read (and read quickly) as this might be pulled down as fast as I put it up. In the meantime, I will try to get permission.

The context: A small village in Nielle, Africa. The chief of the Senufo tribe has gathered everyone around the fire at night to tell them a very important thing, regarding a visit of Frenchmen to their village earlier in the day. This actually happened, by the way. The passage (with some highlights by yours truly, and some light snipping here and there) goes like this…

“I want to talk to the children tonight”, he (the chief) began, looking from child to child. “The day is coming when I will be gone. One of you will be chief then. It’s a time they call la venir – the coming, the future. There is much we do not and cannot know about that time. We are all curious about it, but it really cannot be known. The Frenchmen who came to Nielle today do not understand that. They asked me many question about the future – as if it could be known! When I told them we don’t known what will be in the future, they became very angry. And so did I. I am sorry you saw me like that. It is not how we should be. It bothered and saddened me to be angry.”

“They went away angry too, but I think they are often like that. Worrying about the future can do that to you.” He took another deep breath and then continued. “We are not like them. To them, time is everything. Did you see those silver circles on their wrists? Those things measure the day into very little pieces. I have seen such things on the walls in Abidjan, too. Frenchmen think that counting time is very important.” Then came a profound statement. “The smaller that men can measure the day, the more angry they seem to be,” he said with a shake of his head. “For the Senufo, the movement of the sun is as much measurement of the passage of time as we need. We know when to get up. We know when to work the fields and when to hunt. We know when to rest in the shade. We known when to go home. We know when to sleep. Children, it is enough!”

Time is like a river,” he continued. “It flows along like water, from the future to the present and into the past. But there is a bend in the river. We know the water is coming, but we can’t see it or know very much about it. All we know is that it is coming. The present is now – the days we live today. This is God’s gift to us. It is meant to be enjoyed and lived to the fullest. The present will flow by us, of course, and become the past. That is the way of a river, and that is the way of time. The Frenchmen cannot wait for the future to arrive. They crane their necks to see around the bend in the river. They cannot see it any better than we can, but they try and try. For some reason, it is very important for them to know what is coming toward them. They want to know it so badly that they have no respect for the river itself. They thrash their way out into the present in order to see more around the bend. They stand n the middle of the river, facing upstream,” he continued, “and though the river swirls dangerously around their knees and nearly topples them, they don’t care. To them, it seems that the present is only a vantage point to better see around the bend to the future. They miss so much of the joy of today all around them. They miss much of the present time, because all they care about is the unknowable, the future.

“Because they strain to see around the bend in the river, the present nearly knocks them down as it swirls around their knees. It slips behind them and keeps flowing. It becomes the past without their even noticing. The past, for them, is forgotten. The memories fade, and they make the same mistakes all over again. That is why their questions made no sense today. Children, we are not like them!”
An excitement seemed to quicken his countenance as he looked around the fire ring. “We also see the passage of time like a river, but we respect the river! We know (the bend) is coming, and although we don’t know all about it, God does. We can trust him with the future. The present is all we can fully know and experience, so we must. We must love each other. We must smell the hibiscus flowers. We must hear the singing of the weaverbirds and the grunts of the lions. We must taste with joy the honey and the peanut sauce on the rice. We must laugh and cry and live.” Suddenly he grew sober again, the twinkle gone from his eyes. We knew from his cadence that something very important was about to be said. “Children,” he continued, with tears glistening in his eyes, “do not forget the past! It is just as much a part of the river as the future and the present. I will be there one day… and someday, a long time from now, so will you. You must remember what you have seen and heard and learned. You must tell the stories of today to the younger ones, your sons and daughters, when it becomes yesterday, the past.”

Although the future is not known to us, it is known to God and only to God. He holds it in his hands. You don’t need to worry about it; it will come. God will take care of it. All we can see and feel is the present. All we can remember and honor is the past. It is enough, my children.” In the gathering darkness, there were nods of agreement all across the courtyard. We knew the chief had spoken wisdom that night.

How to cite MATLAB (bibtex / latex)

So I’ve been extensively using MATLAB recently and while writing a paper had to cite it. Simple thing, no? The whole problem is that MATLAB is a software (@electronic, right?), but it is a corporate publisher, with specified version. So one would expect an output like

[1] MATLAB version 7.10.0. Natick, Massachusetts: The MathWorks Inc., 2010.

Where
  • Title of software: MATLAB
  • Version of software: version 7.10.0
  • Place of publication: Natick, Massachusetts:
  • Publisher: The MathWorks Inc.,
  • Year of publication: 2010.
But however hard I tried, this wouldn’t get compiled into my pdf file. Final solution?


@book{MATLAB:2010,
year = {2010},
author = {MATLAB},
title = {version 7.10.0 (R2010a)},
publisher = {The MathWorks Inc.},
address = {Natick, Massachusetts}
}



Done. In a very similar manner, I also learned how to cite NS-2 

Open-source Cheminformatics (computational chemistry) libraries

I’ve needed to generate images (jpeg/png) of existing molecules/compounds and have been looking for available java-based chem. libraries to use. I finally decided to test out JOELib and CDK. First of all here is a sample of the respective outputs:

JOELib outputCDK output

Kind of obvious which one I will choose, but I thought it would be nice to post the code of how these two were setup. The notable reader will notice that in one I use the SDF file/format and in the other the SMILES. This is just how I coded this, but both work with either/or.

First the JOELib code:


Molecule mol2 = new BasicConformerMolecule();
ByteArrayInputStream inStream = new ByteArrayInputStream(BYTES FROM MY SDF FILE);
BasicReader in = new BasicReader(inStream, "SDF");
in.readNext(mol2);
in.close();

Mol2Image viewer = Mol2Image.instance();
BufferedImage img = viewer.mol2image(mol2);
ImageIO.write(img, "png", new File("molecule_joe.png"));

Now the CDK code:


int WIDTH = 200;
int HEIGHT = 200;

// the draw area and the image should be the same size
Rectangle drawArea = new Rectangle(WIDTH, HEIGHT);
Image image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);

SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule molecule = sp.parseSmiles(MY SMILES STRING);
StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule(molecule);
sdg.generateCoordinates();
molecule = sdg.getMolecule();

// generators make the image elements
List generators = new ArrayList();
generators.add(new BasicBondGenerator());
generators.add(new BasicAtomGenerator());

// the renderer needs to have a toolkit-specific font manager
Renderer renderer = new Renderer(generators, new AWTFontManager());

// the call to 'setup' only needs to be done on the first paint
renderer.setup(molecule, drawArea);

// paint the background
Graphics2D g2 = (Graphics2D)image.getGraphics();
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, WIDTH, HEIGHT);

// the paint method also needs a toolkit-specific renderer
renderer.paintMolecule(molecule, new AWTDrawVisitor(g2), drawArea, true);

ImageIO.write((RenderedImage)image, "PNG", new File("molecule_cdk.png"));

HTML URL Encoding Reference

This is yet another one of those posts ‘for me’, as I frequently find myself having to look this up. As everyone knows, URL encoding replaces unsafe ASCII characters with “%” followed by two hexadecimal digits corresponding to the character values in the ISO-8859-1 character-set. URLs cannot contain spaces. URL encoding normally replaces a space with a + sign.


URL Encoding Reference

ASCII Character URL-encoding
space %20
! %21
%22
# %23
$ %24
% %25
& %26
%27
( %28
) %29
* %2A
+ %2B
, %2C
- %2D
. %2E
/ %2F
0 %30
1 %31
2 %32
3 %33
4 %34
5 %35
6 %36
7 %37
8 %38
9 %39
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
@ %40
A %41
B %42
C %43
D %44
E %45
F %46
G %47
H %48
I %49
J %4A
K %4B
L %4C
M %4D
N %4E
O %4F
P %50
Q %51
R %52
S %53
T %54
U %55
V %56
W %57
X %58
Y %59
Z %5A
[ %5B
\ %5C
] %5D
^ %5E
_ %5F
` %60
a %61
b %62
c %63
d %64
e %65
f %66
g %67
h %68
i %69
j %6A
k %6B
l %6C
m %6D
n %6E
o %6F
p %70
q %71
r %72
s %73
t %74
u %75
v %76
w %77
x %78
y %79
z %7A
{ %7B
| %7C
} %7D
~ %7E
%7F
%80
%81
%82
ƒ %83
%84
%85
%86
%87
ˆ %88
%89
Š %8A
%8B
Π%8C
%8D
Ž %8E
%8F
%90
%91
%92
%93
%94
%95
%96
%97
˜ %98
%99
š %9A
%9B
œ %9C
%9D
ž %9E
Ÿ %9F
%A0
¡ %A1
¢ %A2
£ %A3
%A4
¥ %A5
| %A6
§ %A7
¨ %A8
© %A9
ª %AA
« %AB
¬ %AC
¯ %AD
® %AE
¯ %AF
° %B0
± %B1
² %B2
³ %B3
´ %B4
µ %B5
%B6
· %B7
¸ %B8
¹ %B9
º %BA
» %BB
¼ %BC
½ %BD
¾ %BE
¿ %BF
À %C0
Á %C1
 %C2
à %C3
Ä %C4
Å %C5
Æ %C6
Ç %C7
È %C8
É %C9
Ê %CA
Ë %CB
Ì %CC
Í %CD
Î %CE
Ï %CF
Ð %D0
Ñ %D1
Ò %D2
Ó %D3
Ô %D4
Õ %D5
Ö %D6
%D7
Ø %D8
Ù %D9
Ú %DA
Û %DB
Ü %DC
Ý %DD
Þ %DE
ß %DF
à %E0
á %E1
â %E2
ã %E3
ä %E4
å %E5
æ %E6
ç %E7
è %E8
é %E9
ê %EA
ë %EB
ì %EC
í %ED
î %EE
ï %EF
ð %F0
ñ %F1
ò %F2
ó %F3
ô %F4
õ %F5
ö %F6
÷ %F7
ø %F8
ù %F9
ú %FA
û %FB
ü %FC
ý %FD
þ %FE
ÿ %FF

Flex doesn’t have a String.replaceAll()?

No, it does not. It does, however, have a pretty powerful regex parser, so instead of “myString.replaceAll(‘,’,’ ‘)” I can do a “myString.replace(/,/g, ” “)“. It is definitely a one-liner to use a global regex, but its not intuitively obvious.. and while coding a useless while loop, I looked over the API one more time and saw how easy it could be solved. :P

Greek Letters (UTF-8)

I’ve been coding using Flex at work, and most often than not, I need to look this up… To make the right character appear on the mxml widget, just add an ampersand (&) and a pound sign (#), followed by a 3-digit number, and ending with a semicolon (;).


Greek Letter  UTF-8           Details
Α   - &# 913; - Greek capital Alpha

α   - &# 945; - Greek lower case alpha

Β   - &# 914; - Greek capital Beta

β   - &# 946; - Greek lower case beta

Γ   - &# 915; - Greek capital Gamma

γ   - &# 947; - Greek lower case gamma

Δ   - &# 916; - Greek capital Delta

δ   - &# 948; - Greek lower case delta

Ε   - &# 917; - Greek capital Epsilon

ε   - &# 949; - Greek lower case epsilon

Ζ   - &# 918; - Greek capital Zeta

ζ   - &# 950; - Greek lower case zeta

Η   - &# 919; - Greek capital Eta

η   - &# 951; - Greek lower case eta

Θ   - &# 920; - Greek capital Theta

θ   - &# 952; - Greek lower case theta

Ι   - &# 921; - Greek capital Iota

ι   - &# 953; - Greek lower case iota

Κ   - &# 922; - Greek capital Kappa

κ   - &# 954; - Greek lower case kappa

Λ  - &# 923; - Greek capital Lamda

λ  - &# 955; - Greek lower case lamda

Μ  - &# 924; - Greek capital Mu

μ  - &# 956; - Greek lower case mu

Ν  - &# 925; - Greek capital Nu

ν  - &# 957; - Greek lower case nu

Ξ  - &# 926; - Greek capital Xi

ξ  - &# 958; - Greek lower case xi

Ο  - &# 927; - Greek capital Omicron

ο  - &# 959; - Greek lower case omicron

Π  - &# 928; - Greek capital Pi

π  - &# 960; - Greek lower case pi

Ρ  - &# 929; - Greek capital Rho

ρ  - &# 961; - Greek lower case rho

Σ  - &# 931; - Greek capital Sigma

σ  - &# 963; - Greek lower case sigma

ς  - &# 962; - Greek lower case final sigma

Τ  - &# 932; - Greek capital Tau

τ  - &# 964; - Greek lower case tau

Υ  - &# 933; - Greek capital Upsilon

υ  - &# 965; - Greek lower case upsilon

Φ  - &# 934; - Greek capital Phi

φ  - &# 966; - Greek lower case phi

Χ  - &# 935; - Greek capital Chi

χ  - &# 967; - Greek lower case chi

Ψ  - &# 936; - Greek capital Psi

ψ  - &# 968; - Greek lower case psi

Ω  - &# 937; - Greek capital Omega

ω   - &# 969; - Greek lower case omega

Android and WPA2-Enterprise

It seems that anytime I really need this, I forget how to set it up. These are the instructions for setting up Android inside a WPA2-Enterprise scenario:
  1. Click the Menu button and select ‘Settings’.
  2. Scroll to the top and select ‘Wireless & Networks’.
  3. Make sure the that ‘Wi-Fi’ selection is checked
  4. Select ‘Wi=Fi Settings’
  5. Under Wi-Fi networks you will see a list of available networks, in case of the University of Cincinnati, one can select  ‘Securewireless’ to configure. If you do not see it, proceed to manual configure below.
  6. In the pull down menu of ‘EAP Method’, select ‘PEAP’.
  7. In the pull down menu of ‘Phase 2 authentication’, select ‘MSCHAPV2′.
  8. Scroll past CA certificate and Client certificate
  9. In the ‘Identity’ field enter your login at UCIT (your 6+2 login)
  10. Skip the ‘Anonymous identity’ field.
  11. In the password field enter your wireless password. (If your cursor is stuck at ‘Identity’ click “next” on your keypad twice to get to Password).
  12. Select Connect. The account settings, including username/password are now saved and you will connect automatically when ‘Securewireless’ is in range.
For Manual configuration, you need to…
  1. Scroll to the bottom and select ‘Add Wi-Fi Network’
  2. In ‘Network SSID’ enter ‘Securewireless’
  3. Scroll down to ‘Security’ and select ‘802.1x Enterprise’
  4. Scroll down to ‘EAP Type’ and select ‘PEAP’
  5. Scroll down to ‘Phase 2 authentication’ and select ‘MSCHAPV2′.
  6. Scroll down and enter your login in the ‘Identity’ field, skip the ‘Anonymous Identity’ field, and enter your password in the ‘Wireless password’ field.
  7. Select save and you with connect. The account settings, including username/password are now saved and you will connect automatically when ‘Securewireless’ is in range.

Adjusting PopUp visual effects on Flex

Flex Modal Transparency
When you use the PopupManager in Flex by default it will include a blur effect, as well as place a transparent layer on top of the background. This looks very nice, but it was slightly too light for my taste. After what seems too long of a search, I finally found something. As expected, it can be configured using css.

For example, to remove the blur effect, one can:
global{
 modalTransparencyBlur: 0;
}

In my case, this is what I used for the “after” you see in the image above:
global{
 modalTransparency: 0.6;
 modalTransparencyBlur: 5;
 modalTransparencyColor: #000000;
 modalTransparencyDuration: 100;
}

Getting subversion svn+ssh:// to work with Eclipse (subclipse)

I’ve been moving all my code to a centralized version control system and had everything setup using CVS when I noticed that some of my NS-2 code started to break due to soft-link problems (CVS doesn’t support it). So I downloaded and install GIT (only to find out that it doesn’t natively handle it as well). So I ended up with SVN, however, I didn’t want to do it through WebDAV or as a new service… SVN however allows for SSH tunneling (i.e. with a subversion repository url of svn+ssh://talmai@talmai.com.br/myrepo) and I can use integrate it using the Subclipse subversion integration with Eclipse.

When I used JavaHL (JNI) I got the following error, “svn: Can’t create tunnel: The system cannot find the file specified“. After some googling, I discoved that I needed to configure eclipse to use the JavaSVN interface (In Eclipse, under Windows –> Preferences –> Team –> SVN –> SVN interface: make sure you have selected JavaSVN). The next error that popped-up was “svn: Handshake failed, received:“, and when I tried to connect using a shell (“svn list –verbose snv+ssh://talmai@talmai.com.br/myrepo“) I got “‘bash: svnserve: Command not found“. Obviously this was a path problem, but my PATH was correctly, so I ended up adding a link to svnserve on /usr/bin. Things magically worked from that point on. :)

Python Client/Server example

I’ve been TA’ing in a introductory class to CS, and I needed to code a simple client/server example. Thought this might help someone else in the future.

Random Quote Server and the respective Client.

No news of the DQE yet. Hopefully that will be my next update!


[UPDATE 01/11/2010: I've passed my DQE!]

Vista sucks sometimes... (Windows cannot detect ADB interface)

While playing with android development, whenever I connected my mytouch into the PC, it only detected storage. It didn’t matter if USB debugging was enabled: It just never detected nor loaded the adb driver. I tried to manually install the driver for adb, but, at best, it would show up with yellow question mark and error ‘device cannot be run (code 10)’. Much later I discovered that the problem was that the first time I plugged in my magic, I didn’t have Settings >> Applications >> Development >> enable USB debugging checked.

Here is the remedy:
1. Unplug your mobile
2. Find a great utility named USBDeview. Run it.
3. In the list you will see one or more “Android Phone”: for each of them, right click [uninstall selected]
4. Replug your phone.

Have Vista politely ask you to find where the driver is, and choose <Android SDK>\usb_driver\x86. If Vista does not ask, then first try to manually add the driver (Control Panel >> Add Hardware >> All Devices), and then redo everything from scratch.

Reading binary files from cin (C++/windows/VS)

As a TA assignment I needed to read binary files straight from cin using C++ on windows. Although at first this seems like an extremely easy task, it is a bit more complex than what I expected. Anyhow, eventually I got it to work. This code sample counts the number of characters in each line. Arguably, the concept of a “line” is thin, so it’s either 100 bytes or eof(). Makes sense? :)

#include "stdafx.h"
#include
#include
#include
#include  //_O_BINARY
#include  //_setmode
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {
 char temp[100];
 int readBufSize;
 int max = -1;
 int min = 1000;
 int total_number_bytes = 0;
 bool done = false;
 // see: http://tinyurl.com/clzq6m
 if (_setmode(_fileno(stdin), _O_BINARY) == -1)
  cout << "ERROR: cin to binary:" << strerror(errno);
 while (!done)
 {
  cin.read(temp, sizeof(temp));
  readBufSize = cin.gcount();
/*
  for (int i=0; i {
  cout.setf(ios::hex, ios::basefield);
  cout << (int) temp[i] << endl;
  cout.setf(ios::dec, ios::basefield);
  }
*/
  max = (readBufSize > max)?readBufSize:max;
  min = (readBufSize < min)?readBufSize:min;
  total_number_bytes += readBufSize;
  if(cin.fail() || cin.bad() || cin.eof()) {
  if (cin.eof()) done = true;
  cin.clear();
  }
 }
 cout << "MAX: " << max <<
                " MIN: " << min <<
  " TOTAL: " << total_number_bytes;
 return 0;
}
To run it it would do something like: prog.exe < file.jpg. Any suggestions or comments? Drop me a line.

Windows command console: F7 for history

End of quarter woes for me include grading a lot of homework resubmissions. Call me soft, but I think that school is made to help the students learn, so as long as there is time, I’ll accept resubmissions. Sadly, that means that on the last week students will resubmit almost all of their assignments. The only good news out of all of this is that I accidently found out that hitting F7 will get a complete list of commands that you executed. It’s similar to the linux command ‘history’, but it’s more visual as it brings up a popup! Use the arrow keys to highlight the command you want to run again or just hit the number key corresponding to the command that you want to execute.
F7 is also what I use to compile code in Visual Studio… :D

How complex are human gestures?

Ah, the joys of programming are back! For my ad-hoc and sensor networks class I will be trying to develop a wireless sensor-based application to interact with other devices. It’s a work-in-progress (and hopefully not a one-shot kinda’ deal) that is slowly taking shape. I’ve been using Crossbow’s TelosB sensors and an Arduino ADXL3xx accelerometer and just this week was able to get a functional prototype to read sensor data and transmit it to a nearby base-station. Next step is somekind of gesture recognition which I am trying to use fuzzy logic and while reading a book on this topic I found a paragraph that got me thinking:


Given the deeply entrenched tradition of scientific thinking which equates the understanding of a phenomenon with the ability to analyze it in quantitative terms, one is certain to strike a dissonant note by questioning the growing tendency to analyze the behavior of humanistic systems as if they were mechanistic systems governed by difference, differential, or integral equations. Essentially, our contention is that the conventional quantitative techniques of system analysis are intrinsically unsuited for dealing with humanistic systems or, for that matter, any system whose complexity is comparable to that of humanistic systems. The basis for this contention rests on what might be called the principle of incompatibility. Stated informally, the essence of this principle is that as the complexity of a system increases, our ability to make precise and yet significant statements about its behavior diminishes until a threshold is reached beyond which precision and significance (or relevance) become almost mutually exclusive characteristics. It is in this sense that precise quantitative analyses of the behavior of humanistic systems are not likely to have much relevance to the real-world societal, political, economic, and other types of problems which involve humans either as individuals or ingroups.” Zadeh [1973]

How complex are human gestures? A quick look-up on the subject yielded a good amount of existing techniques for this using – alas! – non-fuzzy methods, and they all (at least according to their authors) result in very high (94+%) success rates. I am *very* sure that this has been implemented before using fuzzy, but it will be great to see for myself how much better one solution is compared to the other. By next week I hope to have good news on this project of mine. :)

UPDATE: I’ve since implemented the fuzzy logic into the mote, however I have been (for the last 2 days) trying to debug it. It has given me a heck of a time! Finally, today I discovered the reason behind all errors: an uninitialized variable. UNBELIEVABLE! Quoting Franklin P. Jones “Experience is that marvelous thing that enables you to recognize a mistake when you make it again”.


UPDATE2: I finally implemented a gesture recognition using Crossbow’s TelosB sensors coupled with an Arduino ADXL3xx accelerometer. The accelerometer is placed on a glove, and given the X, Y and Z axis readings, the sensor identifies the position of the hand of the user. Additionally, I have incorporated the gesture recognition into a racing game called HoloRacer. As the user pretends to hold a steering wheel, the car goes left or right. The usage of another sensor as the throttle allows to speed up the car. Fuzzy logic was used to help express the uncertainty behind any kind of classification and linguistic values where utilized such as “very low” or “very high”, which helped facilitate the expression of rules and facts, contrary to variables in mathematics that usually take numerical values. The extreme values of each one of the axis are divided into 5 groups. Each group is given a linguistic value which are “low”, “medium-low”, “medium”, “medium-high”, and “high”. For each hand position hat we plan on classifying, we measure the average values and identify in which linguistic group it belongs. If anyone is interested, this is the report I handed in for the class project.

What did I learn from this? I will need to put in a little more effort before getting something really good, but the way it is is actually pretty remarkable. 

Latex tip: Incorrect Figure Numbering

This might help reduce the amount of frustration when dealing with latex. Whenever you use figures, always put \caption before the \label.

\begin{figure}[htp]
  \centering
  \includegraphics{importante_figure.eps}
  \caption{This is the caption}
  \label{fig:imp-fig}
\end{figure}

If you reverse \label and \caption, there will be referencing problems. For example, depending on the section/subsection of the document the figure reference could say Fig. 2.4.1 instead of Fig. 2.3 since it will pick up the section numbers wrong!

Caracteres ISO-8859-1 em OCTAL, HEX e HTML

Uma tabela simples para quem precisar (no caso, EU!)


US-Kbd    Octal  Hex    HTML           Details

Alt-"     \242   A2    ¢      ¢  cent sign

Alt-#     \243   A3    £     £  Pound sign (British)

Alt-%     \245   A5    ¥       ¥  Yen sign (Japanese)

Alt-<     \274   BC    ¼    ¼  fraction one-quarter

Alt-=     \275   BD    ½    ½  fraction one-half

Alt->     \276   BE    ¾    ¾  fraction three-quarters

Alt-!     \241   A1    ¡     ¡  upside-down exclamation mark

Alt-+     \253   AB    «     «  open chevron-style quotes

Alt-;     \273   BB    »     »  close chevron-style quotes

Alt-?     \277   BF    ¿    ¿  upside-down question mark

Alt-@     \300   C0    À    À  capital A, grave accent

Alt-A     \301   C1    Á    Á  capital A, acute accent

Alt-B     \302   C2    Â     Â  capital A, circumflex accent

Alt-C     \303   C3    Ã    Ã  capital A, tilde

Alt-D     \304   C4    Ä      Ä  capital A, umlaut mark

Alt-E     \305   C5    Å     Å  capital A, ring

Alt-F     \306   C6    Æ     Æ  capital AE diphthong

Alt-G     \307   C7    Ç    Ç  capital C, cedilla

Alt-H     \310   C8    È    È  capital E, grave accent

Alt-I     \311   C9    É    É  capital E, acute accent

Alt-J     \312   CA    Ê     Ê  capital E, circumflex accent

Alt-K     \313   CB    Ë      Ë  capital E, umlaut mark

Alt-L     \314   CC    Ì    Ì  capital I, grave accent

Alt-M     \315   CD    Í    Í  capital I, acute accent

Alt-N     \316   CE    Î     Î  capital I, circumflex accent

Alt-O     \317   CF    Ï      Ï  capital I, umlaut mark

Alt-P     \320   D0    Ð       Ð  capital Eth, Icelandic

Alt-Q     \321   D1    Ñ    Ñ  capital N, tilde

Alt-R     \322   D2    Ò    Ò  capital O, grave accent

Alt-S     \323   D3    Ó    Ó  capital O, acute accent

Alt-T     \324   D4    Ô     Ô  capital O, circumflex accent

Alt-U     \325   D5    Õ    Õ  capital O, tilde

Alt-V     \326   D6    Ö      Ö  capital O, umlaut mark

Alt-X     \330   D8    Ø    Ø  capital O, slash

Alt-Y     \331   D9    Ù    Ù  capital U, grave accent

Alt-Z     \332   DA    Ú    Ú  capital U, acute accent

Alt-[     \333   DB    Û     Û  capital U, circumflex accent

Alt-\     \334   DC    Ü      Ü  capital U, umlaut mark

Alt-]     \335   DD    Ý    Ý  capital Y, acute accent

Alt-^     \336   DE    Þ     Þ  capital THORN, Icelandic

Alt-_     \337   DF    ß     ß  sz ligature, German

Alt-`     \340   E0    à    à  small a, grave accent

Alt-a     \341   E1    á    á  small a, acute accent

Alt-b     \342   E2    â     â  small a, circumflex accent

Alt-c     \343   E3    ã    ã  small a, tilde

Alt-d     \344   E4    ä      ä  small a, umlaut mark

Alt-e     \345   E5    å     å  small a, ring

Alt-f     \346   E6    æ     æ  small ae diphthong

Alt-g     \347   E7    ç    ç  small c, cedilla

Alt-h     \350   E8    è    è  small e, grave accent

Alt-i     \351   E9    é    é  small e, acute accent

Alt-j     \352   EA    ê     ê  small e, circumflex accent

Alt-k     \353   EB    ë      ë  small e, umlaut mark

Alt-l     \354   EC    ì    ì  small i, grave accent

Alt-m     \355   ED    í    í  small i, acute accent

Alt-n     \356   EE    î     î  small i, circumflex accent

Alt-o     \357   EF    ï      ï  small i, umlaut mark

Alt-p     \360   F0    ð       ð  small eth, Icelandic

Alt-q     \361   F1    ñ    ñ  small n, tilde

Alt-r     \362   F2    ò    ò  small o, grave accent

Alt-s     \363   F3    ó    ó  small o, acute accent

Alt-t     \364   F4    ô     ô  small o, circumflex accent

Alt-u     \365   F5    õ    õ  small o, tilde

Alt-v     \366   F6    ö      ö  small o, umlaut mark

Alt-x     \370   F8    ø    ø  small o, slash

Alt-y     \371   F9    ù    ù  small u, grave accent

Alt-z     \372   FA    ú    ú  small u, acute accent

Alt-{     \373   FB    û     û  small u, circumflex accent

Alt-|     \374   FC    ü      ü  small u, umlaut mark

Alt-}     \375   FD    ý    ý  small y, acute accent

Alt-~     \376   FE    þ     þ  small thorn, Icelandic

          \377   FF    ÿ      ÿ  small y, umlaut mark

Busybox

O Busybox é a ferramenta usada em sistemas embarcados rodando linux que incorpora o código de vários programas (como o ls, mount, csh, etc) em apenas 1 executável. Em um projeto que estou trabalhando precisei re-compilar o busybox para ativar o código responsável pelo dhcpd (para pegar IP dinâmico).

Acontece que tive um problema quando estive compilando usando o cross-compiler GCC para ARM.


CC=/usr/local/arm/arm-linux/bin/gcc
 /usr/local/arm/arm-linux/bin/gcc -Wall -DDEBUG -c -o src/interface.o src/interface.c
 In file included from /usr/local/arm/arm-linux/lib/gcc-lib/../../arm-linux/sys-include/net/route.h:28,
 from src/defs.h:28,
 from src/interface.c:23:
 /usr/local/arm/arm-linux/lib/gcc-lib/../../arm-linux/sys-include/net/*dst.h*:30: *parse* *error* *before* “*atomic_t*”


Fiquei boas horas para resolver isso.. no fim o problema era na ordem dos includes…

O cross-compilador do GCC fica configurado para procurar primeiro em <blah>/sys-include *antes* de olhar em <blah>/include.

No Rules.mak precisei editar:


CFLAGS=$(INCS) -I/usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include -I$(srcdir) -D_GNU_SOURCE

DICA: Para descobrir o include file search path do GCC, quando for compilar adicione o flag -v (ex: adicione -v para o CFLAGS)

Nedit Woes

Vou descrever rapidamente o que precisei fazer para colocar tudo para funcionar sem problemas no meu GNU/Linux debian

1. Instalar o teTeX (e, é claro toda a penca de dependências: latex, pdflatex, xdvi, dvips e gv…. mas, eu não precisei destes outros não!).


apt-get install tetex-base tetex-extra tetex-doc (o tetex-extra é indispensável para algumas classes tipo geometry.sty, etc…)

2. Instalar o NEdit (preferência pessoal, é claro!)

3. Configurar alguns macros para facilitar a vida no NEdit… recomendo pelo menos 2 macros: um para executar o latex, e outro para executar o xdvi. No meu caso, eu fui além e criei um macro para compilar e já abrir o arquivo .ps gerado, com o gv. o meu arquivo .nedit/nedit.rc, se encontra disponível aqui. A sessão que interessa mesmo, é a nedit.macroCommands.

4. E finalmente, configurar o X11 para, qnd eu digitar a barra de espaço, colocar um espaço!!! (pasmem! de default, só qnd eu digitava shift+espaço! rsrs)

arquivo .Xdefaults:
nedit*text.Translations: #override \n\
Space : insert_string(” “)

Após incluir essa alteração no .Xdefault, é necessário atualizar o X11 através do comando:


xrdb .Xdefaults

É isso aí! Boa sorte para mim (com a minha dissertação) e para vc (caso queira seguir meus conselhos!).

:]