Feb 28 2012

Less than Symbol in Latex

Category: .opensource,.tipsAmit Bahree @ 5:30 pm

If you want to show a simple less than symbol (i.e. <) in Latex, you are in for a surprise as you cannot use that character as is. If you are in math mode and writing this part of a formula then you might be still OK, but if you are in text mode then it is quite difficult.

Surprisingly, searching for this online also did not provide any obvious answers (perhaps I was searching for the wrong thing).

Anyways, I did figure it out in the end, and I needed to use the \textless directive for latex. I also found a few more symbols and have them listed below in case they are helpful for anyone else.

Symbol Latex Command
^ \textasciicircum
< \textless
> \textgreater
~ \textasciitilde
ª \textordfeminine
* \textasteriskcentered
º \textordmasculine
\ \textbackslash
\textparagraph
| \textbar
· \textperiodcentered
{ \textbraceleft
} \textbraceright
¿ \textquestiondown
\textquotedblleft
\textquotedblright
\textquoteleft
\textquoteright
\textbullet
© \textcopyright
\textdagger
\textdaggerdbl
® \textregistered
$ \textdollar
§ \textsection
. . . \textellipsis
£ \textsterling
\textemdash
\texttrademark
\textendash
_ \textunderscore
¡ \textexclamdown
  \textvisiblespace
Share

Tags: ,


May 22 2011

Hadoop in Azure

Category: .azure,.opensourceAmit Bahree @ 4:13 pm

My dear friend Mario has finally got around to blogging and one of his latest posts shows, it is possible to run Hadoop (which if you are not familiar with, can be thought of as an open source version of Google’s MapReduce) in Azure. You need to setup a typical configuration of nodes (Name Nodes, Tracker and Slaves).

Sure, there are a number of dependencies some you would expect, others not (e.g. Cygwin – cringe!; but hopefully that will go away with Hadoop 0.22). I wonder what overheard the Cygwin runtime has?

It would be interesting to know if someone is (or planning) to use this at work.

Share

Tags: ,


Mar 04 2011

Twitter Trends

Category: .code,.opensourceAmit Bahree @ 5:32 pm

I was excited to find that Twitter had a JSON (Javascript Object Notation) endpoint for the current trending topics and decided to write a simple consumer which can read this and then spit it out in a simple console. And JSON being so simple and more or less “universal” meant that there are multiple implementations for .NET. Of course if you got lots of bandwidth you can roll out your own parser.

I ended up using Json.NET, which in addition to being OpenSource is also one of the most robust utilities which makes working with JSON formatted data dead simple.

The code for the console app is quite straightforward. The static function ReadTrends() retrieves the JSON string from twitter which is then consumed and extracted. The only tricky part was using a constant key; the easiest way I could think of doing this was to replace the date-time stamp with a literal and then use that literal.

Of course this will fail if you the function ReadTrends() is called at (or just before midnight) on Dec 31st and the code returns to the main() function in the new year. I don’t think this is something I am going to put in production and am not going to be too worried about this behaviour.

At the time of writing this, the twitter trends (in JSON) are:

{“trends”:{“2011-03-04 17:18:01″:[{"name":"#coisasderetiro","events":null,"query":"#coisasderetiro","promoted_content":null},
{"name":"#tigerblood","events":null,"query":"#tigerblood","promoted_content":null},
{"name":"#blackpeoplemovies","events":null,"query":"#blackpeoplemovies","promoted_content":null},
{"name":"Frying Nemo","events":null,"query":"Frying Nemo","promoted_content":null},
{"name":"Acoustic Aftermath","events":null,"query":"Acoustic Aftermath","promoted_content":null},
{"name":"Blade Runner","events":null,"query":"Blade Runner","promoted_content":null},
{"name":"Fun Race","events":null,"query":"Fun Race","promoted_content":null},
{"name":"Bandra","events":null,"query":"Bandra","promoted_content":null},
{"name":"Mike Huckabee","events":null,"query":"Mike Huckabee","promoted_content":null},
{"name":"Arctic Monkeys","events":null,"query":"Arctic Monkeys","promoted_content":null}]},”as_of”:1299259081}

And here is the output in the console. I can see Charlie Sheen’s #tigerblood is still trending; and wonder what Artic Monkeys are upto – is there new album out or something?


#coisasderetiro
#tigerblood
#blackpeoplemovies
Frying Nemo
Acoustic Aftermath
Blade Runner
Fun Race
Bandra
Mike Huckabee
Arctic Monkeys
All done. Press any key to continue…

And finally here is the code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Net;
using System.IO;

namespace TwitterTrends
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //get the trends
                string temp = ReadTrends();

                //as the key is a datetime stamp (which is constantly moving), need something constant to interrogate.
                //simplest way is to find out the year and then take 19 characters from that which is the datetime stamp
                //replace that with a literal (DESIGEEK.COM in my case) and then use the literal. I don't think I will
                //be trending on Twitter; but if you are worried then you can use something like a GUID.
                //
                // For example at the time of writing this the datetime stamp was: "2011-03-02 14:20:00"
                string theDate = temp.Substring(temp.IndexOf(DateTime.Now.Year.ToString()), 19);
                temp = temp.Replace(theDate, "DESIGEEK.COM");

                //parse the string for the literal
                JObject trends = JObject.Parse(temp);
                var twitterTrends = from t in trends["trends"]["DESIGEEK.COM"]
                                    select t.Value<string>("name");

                //iterate through
                foreach (var item in twitterTrends)
                {
                    Console.WriteLine(item);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("Following error occured:\n" + ex.ToString());
            }
            Console.WriteLine("\nAll done. Press any key to continue...");
            Console.ReadKey();
        }

        private static string ReadTrends()
        {
            //talk to twitter
            WebRequest theRequest = HttpWebRequest.Create("http://search.twitter.com/trends/current.json");
            HttpWebResponse theResponse = (HttpWebResponse)theRequest.GetResponse();

            //extract the data
            Stream stream = theResponse.GetResponseStream();
            StreamReader reader = new StreamReader(stream);
            string temp = reader.ReadToEnd();

            //clean up
            reader.Close();
            stream.Close();
            theResponse.Close();

            return temp;
        }
    }
}
Share

Tags: ,


Jan 16 2011

Opensource ZigBee stack?

Category: .code,.geek,.mobile,.opensourceAmit Bahree @ 5:10 pm

I was planning on getting the Telegesis ETRX2USB and wanted to know if there are any open source (or shareware) open source ZigBee stacks that I can use with that?

I also wanted to know if there is any opensource (or not too expensive), network management or network analyser for a ZigBee network? Essentially I want to be able to programatically view network and node information on the ZigBee network (e.g. S/N ratio, signal strength, etc.) – something similar to Ember’s Insight Desktop which shows the details I am interested in. I could not find anything specific and would be interested in getting ideas.

Share

Tags: , , ,


Jan 04 2011

Interesting WordPress Plugins

Category: .misc,.opensourceAmit Bahree @ 9:33 pm

After upgrading to the latest WordPress (v3.0.4), I also decided to have a look at the various plugins I am running. As part of that I stumbled across Ultimate Collection of WordPress pluginswhich are very interesting. If you run WordPress (and if you don’t, why not :) ), I would highly recommend to check them out. I already was running some of these and not heard of others which are great.

Here are some of my favourite ones (in no particular order) and those with keen eyes would notice a few of these already.

  •  AddToAny: Share/Bookmark/Email Button – Help people share, bookmark, and email your posts & pages using any service, such as Facebook, Twitter, Google Buzz, Digg, etc.
  • Akismet – this is for comment spam control and is used by millions! Excellent!
  • WP FollowMe – allows you to add a twitter Follow me badge on your wordpress blog.
  • Google Analyticator – name says it all I think.
  • Google XML Sitemaps – same as above.
  • Lightbox 2 – Used to overlay images on the current page.
  • My Page Order – allows you to set the order of pages through a drag and drop interface.
  • Really Simple CAPTCHA – CAPTCHA module intended to be called from other plugins; really works too!
  • Search Everything – Adds search functionality and includes search highlight, search pages, excerpts, attachments, drafts, comments, tags and custom fields (metadata). It can also exclude specific pages and posts. It does not search password-protected content.
  • Shockingly Big IE6 Warning – doesn’t the name say it all?
  • Simple Tags – Excellent plugins, to manage your tags. Includes, suggested Tags, Mass edit tags, Autocompletion, Tag Cloud Widgets, Related Posts, Related Tags, etc
  • StatPress Reloaded – real time stats for the blog
  • SyntaxHighlighter Evolved – code to your site without having to modify the code at all; you cannot use the Visual editor with this.
  • TinyMCE Advanced – Enables advanced features and plugins for the visual editor
  • Twitter for WordPress – displays your last few tweets
  • WP-Cumulus – Flash based Tag Cloud for WordPress
  • WP-DBManager – Excellent plugin, that manages your WordPress including optimize database, repair database, backup database, restore database, etc. I use to exclusively for the automatic scheduling of backing up and optimizing of the database.
  • WP-SmugMug – I use SmugMug for my photos online; this plugin integrates the SmugMug galleries into the blog.

I would highly recommend the above and suggest you play with them. 

These plugins I have only recently installed and they seem interesting, but I have not used them enough to have the confidence to highly recommend them – yet.

  • WordPress Backup (by BTE) – Backup the upload directory (images), current theme directory, and plugins directory to a zip file. I have only recently installed this plugin, and not used it enough to say how useful it is at this point.
  • Automatic WordPress Backup – Automatically upload backups of important parts of your blog to Amazon S3. I am a huge S3 fan, and this seems very promising. Hopefully I can come back in a few days and weeks and blog about it.

Finally, when using plugins I would recommend the following:

  • Search and install from these via the “Plugins” menu which you see when log into your WordPress dashboard. Don’t download the code manually and then try and upload it to your site. That is a more painful process.
  • Try and have a test blog running – seperately from your main blog where you can test different permutations and configurations. In case something goes wrong, you won’t have your main blog go down. Of course needless to say, you should keep both your test and main blog on the same version.
  • It is not a good idea to install all of the plugin’s all at the same time as you never never which plugin can cause conflict with another. Well, you can install all the plugins at the same time, just activate them one at a time and test that your blog is still running as expected after you have activated each plugin.
  • Before you upgrade the version of WordPress – irrespective of how big or small the upgrade is always backup your database and files first. This would allow you to revert back to a “clean slate” in case something goes wrong.
Share

Tags: ,


Dec 29 2010

C++ Message queuing options?

Category: .architecture,.code,.opensourceAmit Bahree @ 12:04 am

I am thinking of implementing a queue in one of the projects I am working on right now (sorry cannot go into more details until it gets published – hopefully in a few months). Anywyas, this is in C++ which needs to run on Ubuntu and my queueing experience (with C++ or otherwise) is only with MSMQ which is brilliant, but does not help me here as that run only on Windows. I also cannot use something like STL Queue as this will need to run across a number of machines and trying to sync between them would a royal pain. In other words, this needs to be distributed and async “loose” messaging. :-)

I am already using MOOS, so one option is for me to continue to use that – however this is for another part of the application and it might be easier for me to use something else (still need to think it through a little more).

These are the requirements (these are must haves!). Also if it makes a difference I am using CDT for this project.

  • Needs to be able to run on Ubuntu 9.04 (and higher)
  • Needs to be Open Source (cannot be commercial)
  • Needs to be able to store messages “offline”
  • Needs to be able to run on TCP with minimal dependencies. It would be nice not to have a whole bunch of underlying dependencies.
  • Preferably be easy to use (as a consumer) – I don’t have much time to read through loads of documentation just to get my head around the underlying object model and how to use it.
  • C++ support (if it was not obvious until now)

I did a little research online and came across the following, and wanted to get some feedback:

  • ActiveMQ – seems like it has good C++ support via CMS (C++ Messaging Service).
  • Amazon SQS –  not sure how good the C++ support is. If there is no library per se that I can use, then writing things around REST APIs might be more painful. Also I suddenly have a dependency to be able to go to the public internet. Also it is not free (though there is a free 100K messages / month).
  • MQ4CPP – seems quite amateurish (kudos to the guy writing it though – seems like an interesting project to pick up when once has time).
  • RabbitMQ – I know some guys used this at work (though that was using it in .NET); nothing for C++, but there some C experimental code; overall does not inspire confidence (in the context of C++).
  • OpenAMQ – seems quite interesting and also has a C++ API based on its WireAPI.
  • Anything else??

At face value it seems like this is down to ActiveMQ and OpenAMQ. Just looking at the quick samples between the two ActiveMQ seems like more C++ friendly and easier to use compared to OpenAMQ. Of course this is just the first impression and I could be completely wrong – it is not like I have had a chance to play with this (yet anyways).

Does anyone have any experience and feedback on this matter? Feel free to comment on this post, or tweet me.

Share

Tags: , ,


Nov 06 2010

MOOS

Category: .architecture,.opensourceAmit Bahree @ 9:17 pm

I don’t think many people have heard of MOOS (which stands of Mission Oriented Operating Suite); I have been working with it for the past few months as part of my dissertation. And I must admit, the more I play with it, the more impressed I am. It is quite simple and yet powerful.

Whilst MOOS’s roots are in robotics (MRG) and embedded systems, I wonder if I can extend it to use it some of the grid computing scenarios. Maybe implement a pMapReduce or pHadoop? Or perhaps a .NET implementation. Hmm, just need some time. If you need a robust, cross platform communication layer then check out MOOS.

Share

Tags: ,


Oct 30 2010

Impressed with Doxygen

Category: .code,.opensourceAmit Bahree @ 12:00 pm

I have recently started using Doxygen in anger and have been quite impressed with it. In addition to the documentation of code that you would expect, one of the most powerful and coolest features is the ability to create various types of diagrams showing various aspects of the application such as collaboration diagrams object and call graphs, etc.

The easiest way to configure your application  is to use Doxywizard. On Linux, if you do want the object and call graphs then you would need to choose to enable the DOT option. If you do that you will need to have Message Sequence Charts installed (typically found in /usr/bin/mscgen) and also Graphviz. DOT can typically be found in /usr/bin/dot.

If you are on Windows and use Visual Studio, then there are a few add-ins which will work – with VS.NET 2005, 2008 and 2010; more details here.

Below is a simple example of a collaboration diagram taken from VTK project. You can find more samples. When you do browse the code, click on the Classes link – that is where you can see the various diagrams.

Sample Collaboration Diagram

Share

Tags: ,


Oct 23 2010

Unlock button in Services is greyed out

Category: .opensourceAmit Bahree @ 11:49 am

If you are running Ubuntu and want to modify the services running on the OS using the GUI, the way to do this is via System → Administration → Services. This is all very good, but in my case on one machine the Unlock button on the Services window was greyed out. Sure, I could use the shell to modify this, but when this is something I use quite rarely I need to go and look up the exact command and it can get a pain. Plus, that is the whole point of running the GUI? ;-)

One easy way to solve this is to to modify the /etc/PolicyKit/PolicyKit.conf file and add the following in the end:

<return result="yes"/>

You might not have privileges to edit the file and might need to do it as root; you can use the following command for that:

sudo gedit /etc/PolicyKit/PolicyKit.conf

Here is the output from my file:

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->

<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"

"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">

<!-- See the manual page PolicyKit.conf(5) for file format -->

<config version="0.1">
    <match user="root">
        <return result="yes"/>
    </match>
    <define_admin_auth group="admin"/>
    <return result="yes"/>
</config>

One word of caution, this will by pass some of the built-in security and allow any logged on user to get access to the services. If you are the only one using your computer in an environment where someone else won’t be able to get their hands on it (e.g. at home and not at work or school or college) then you should be OK. But if you are not the sole user of the computer or will be in an environment where others can get their hands on it, then I won’t recommend you do this.

Share

Tags:


Apr 04 2010

Deleting folder on Linux

Category: .opensourceAmit Bahree @ 7:31 pm

If you are a newbie to Ubuntu like me (or any other Unix distro) and you tried deleting a folder which is not empty contains files or subdirectories then you get the annoying error “Directory not empty”.

To delete such a folder (from a terminal) use the rm -rf command. For example to delete a folder called amitbahree run the following:

rm -rf amitbahree/
Share

Tags:


Mar 09 2010

Ubuntu on a HTC Touch Pro 2

Category: .geek,.opensourceAmit Bahree @ 10:44 pm

Well this is the phone I have maybe some day I will try this – pretty geeky albeit useless. :)

Share

Tags: ,


Mar 07 2010

RDP from Ubuntu

Category: .opensourceAmit Bahree @ 11:27 pm

I did not know until today that there is something called gnome-rdp using which one can RDP to Windows machines from Ubuntu (or any other linux flavour I imagine). Installation is simple on Ubuntu, with it available in Synaptic Package Manager. To start it you can type in gnome-rdp in a console or go to Applications -> Internet -> Gnome-RDP. Once it has started, usage is quite simple – though you might want to change the remote desktop size and colours. Interestingly this also supports VNC and SSH.

Share

Tags:


Next Page »
Get Adobe Flash player