Formatting XML in GEdit

Tags

, , , , , ,

Have you ever got an XML that is in a messed up format and had a hard time in trying to figure out what is there? And felt that, what if there is a tool that you can use to format it…

If you are using GEdit as your editor, here is a solution for you:

  • Install python-lxml (Or look for lxml)
  • Create a new external tool configuration (Tools -> Manage External Tools…) and add a new command. Like : (Format XML)
  • This is the script you need to execute:

 #! /usr/bin/env python
 
import sys
import lxml.etree as etree
import traceback
 
result = ”
for line in sys.stdin:
  result += line
try:
  x = etree.fromstring(result)
  result = etree.tostring(x, pretty_print=True)
except:
  etype, evalue, etraceback = sys.exc_info()
  traceback.print_exception(etype, evalue, etraceback, file=sys.stderr)
print result

  • Set Input to Current document
  • Set Output to Replace current document

Once done, you will have a menu option under Tools -> External Tools -> Format XML. Once you click on it, you can enjoy understanding XML easily :) Obviously, being a software engineer, I reused the above given code from somewhere else :D

Unlocking levels in Candy Crush

Tags

, , , , , ,

How many of us are playing candy crush regularly? And, loose all the lives and have to wait for long time to regain all the lives?

Once we reach a certain level, to proceed to the next level, it asks us to play 3 quests and we can plan only one per day.. And as we are addicted, how can we wait for so long… huh??

Solution: This worked for me (Read from somewhere though)

1) In your mobile, close the candy crush app. (Not exit. Terminate the application)

2) Change the date/time on your mobile (Add 2:30 hrs to the current time if you ran out of lives and 1 day if you want to play the next quest. to unlock the next level.)

3) Start candy crush. Open the game. But, don’t start playing yet.

4) Exit candy crush. (As mentioned in step 1)

5) Revert your change to date/time on your mobile

6) Start enjoying candy crush.

If you didn’t exit candy crush app or change the time properly , you will be in a big trouble either to play candy crush or with the date/time on your mobile.. So follow the steps as mentioned.

Beware!! Candy crush is not a game. It is an ADDICTION :)

First week in the USA

Tags

, , ,

First week went fast… :)

The best thing was, (Believe Me!!), I didn’t have jet lag :)  I didn’t know how.  I started at night from my place.. On the first flight, slept well. Once I reached the place where I have the connecting flight, I roamed inside the airport for a while. Then came the flight to US. I didn’t sleep during that travel. Tried watching movies.. May be that was the reason for not having jet lag.. Reached USA that evening. One of my friend had prepared some good food for me.. Had it and slept. The next day, I was up and running :)

My observations so far.. People seem to be polite. They greet whenever they meet others. That is good. The roads are clean. People follow traffic rules strictly. I have heard honking in cars only when the car gets locked. Not on the roads. Being an Indian, Im missing honking :D One thing for sure is, Any Indian can drive in the USA.. But, I dont think any American can manage to drive in India :D Common India, lets do something about it :)

One more observations about the TV commercials: In the USA, I can find that the TV contains commercials for medicines, alcohols.. But, that is not that much in India. I like India in that perspective.

Another observation about the programs in TV: Around night, the programs seems to become a bit violent. Lots of horror stuff, killing stuff.. But that is not the case in India. Again, I like this in India.

Being Indian, Im used to do the conversions when I buy things. Hope I stop doing that soon :) (Yes.. Some things seems to be more expensive).

I’ll be staying here for a while.. So, I’ll try to write more :)

Alcoholism in movies

Tags

, ,

Drinking is not an Indian culture. I don’t say that nobody drinks.. But, people will have a guilty feeling when they do.

In olden movies, the actors will drink only when they are sad or bad (villains). If the good guy drinks, either he will die because of drinking or he will quit drinking.. That kind of made sense. But, nowadays, the hero or his friend drinks. Whether they are happy or sad doesn’t matter. As if it is part of daily life.. There are very very very very few movies that doesn’t have alcohol in it in the past 5-6 years.. This sends a wrong message to the next generation.

I read that, the government makes a lot of profit from wine shops. Somehow this makes me think whether the government is indirectly forcing the media industry to have atleast one scene where somebody drinks…

If the directors say that the story needs it, how did the (g)older movie directors made movies for ages without any drinking scenes.. Can anybody show/name me a movie where MGR had alcohol?? Didn’t those stories had the so called “situations”? If he wanted, do you think he couldn’t have included such scenes? Because, he wanted to send ONLY the RIGHT messages to people. And HE STOOD BY IT.

Don’t BS me saying that this is the culture now. Still, there are millions who are afraid to go home after taking drinks and don’t drink for that reason alone.

Showing “Drinking is injurious to health” at the beginning of the movie alone is not enough.. If you really mean it, why the *** do you need those scenes in your movies??

Film industry, Movies have a greater reach. It is a powerful media.. Do not misuse it and Please DO NOT SPOIL THE UPCOMING GENERATION.. By watching the movies, we can build an opinion about those olden days.. This is also like recording the culture in history.. DO NOT DEFAME OUR CULTURE…

Recursively list files (with space in their names)

Tags

, , , , , ,

Today, I had to do a long list of files inside a folder recursively. I tried using

find <folder> | xargs ls -l

This failed miserably when the folders/files inside the search location had space character in it. Searched for sometime and came across:

find <folder> -print0 | xargs -0 ls -l

Its kool..

-print0 prints null character as line delimiter and -0 (for xargs) takes null character as line delimiter and passes that input to ls.. Nice one :)

Security issue on linux??

Tags

, , , ,

Recently, I was playing around with creating users and groups on my machine and observed a weird behaviour.

Created a user first and made that user to be the owner of a folder.  And, deleted that user and created another user. Now, this new user became owner to the folder.

How could this happen?

I think the ownership is assigned to the User’s ID and not the name.

How is the ID determined?

It gets the highest ID of the existing users and adds one to it and assigns it to the new user. ie. Lets say I have users with IDs 1000, 1001 and when I delete the user with ID 1001, and create a new user, that user gets 1001 as ID. If 1000 is deleted instead of 1001, the new user will get an ID of 1002.

I tried this on Ubuntu and SuSE so far and observed this on both. I agree that the system admin has to take care of restricting access to users so that they will know what all folders the user has access to. So, when the user is deleted, the admin can take care of resetting/revoking permissions. But still, Im thinking, isn’t this is a serious security issue? Coz, this newly created user got rights to folder that was not intended. Shouldn’t the system itself should take care of allocating unique IDs to users??  Any thoughts from anybody?

Future of Software Developers

Recently, I attended a Java training. We have done all of the exercises in our college days itself. But, we used loooots of new stuff. We write abstractions over our code. They have some abstractions.. There are more abstractions over the previous ones.. For example: We have SQL/JDBC (Low level). We have hibernate and that is an abstraction over this. And JPA is another API that can provide an abstraction over hibernate..

On looking at things, I get a feeling that: After 5 years, there will be only two kinds of software developers. One who create abstractions, and the other, consumes abstractions. The consumer’s fate will be:

* After 5 years, No Java developer will know what is “new” operator

* After 5 years, Nobody will know how to write SQLs..

* After 5 years, Nobody will know how things actually work.. What happens behind the scenes…

* After 5 years, Companies will hire people with more memory power rather than their abilities.

And after 10 years, they’ll be just like some electricians who doesn’t know how things work. Only, knows how to assemble things.. If something goes wrong, the response will be, replace this with a working one…

After 20 years, people will not know what is going on.. how to debug issues.. why things are happening the way it is happening.. All these due to these levels of abstractions.. Finally, one fine day, they will say, Lets start writing our own SQLs and our own code…

Another UID???

I thought of making my blog to be more technical than social.. But, what Im am doing is in total contrast to my thoughts!! :(

Recently came to know that our Government is planning to provide an unique number for PF that will be called as Universal Account Number (UAN). This will be the new number that we can use for our PF accounts. Good Idea???

How many numbers are they going to give.. We already have Driving License, RC Book, Gas Connection, PAN, Phone Connection, Bank Accounts, Passport, blah blah blah… hundreds of things.. If I have to do a change of address, think about what all I have to do..

My question is, why don’t they use Aadhar in the first place? As a citizen, I should update my details in Aadhar and be done with it. And from then on, all the utilities should use the new detail. I don’t think this task will be a difficult task for the Government. May be initial investment is high. But, once things are set, it will be easier for government and citizens..

An Observer Pattern should be enough… (At last, could link something technical in this blog) ;)

My colleague used to say, “I am OK with taking a short term pain for a long term gain”. But, looks like our government is “OK with taking a long term pain for a short term gain”

Scary Marketting World!!!

A few days back, I was watching “Brain Games” on NGC.. The subject was about Persuasion. It was a re-telecast. The first time, I saw only towards the end.. May be last 5 mins or so… In that, they asked a fill in the blanks kind of question.. The question was: I am feeling thirsty. So, I need a glass of : (Options) Water, Milk and something else (that I don’t remember now)

When I watched for the first time, my answer was Water. Big Deal!! After that, the host said, We know the answer you would say is Milk. Because, WE PUT IT IN YOUR BRAIN and showed a few scenes (from the same episode) that related directly or indirectly to Milk.. I didn’t believe as my answer was Water. But, the second time, after watching the complete program, automatically “Milk” came to my mind.. I was so shocked when I realized that my answers are different in both the occasions.

And they said that, these kind of techniques are followed by the marketing people to attract us to buy their product. Those brands will have experts in these subjects. Also, I saw an ad recently that says something like: Every one person in some X number will get this disease. And YOU could be the one.. WHAT THE XXXXXX.. After watching that “Brain Games” episode, I feel that this can indirectly create an impact in our brain and that is not good.. May be, there should be a censor board or something that has some Brain experts who monitors such Ads and block them from showing.

From our side, we need to be very careful in taking decisions. I think some marketing people doesn’t give enough time to make our decisions. They will give a very attractive offer and say you have to decide with this time which may not be possible. We may not get enough time to think through the pros and cons of that offer. To avoid missing the offer, we’ll step further which obviously will benefit them.. We need to be careful in making such decisions.. We need to really really think before making such decisions.. I KNOW THIS IS VERY VERY VERY DIFFICULT. But, …

Follow

Get every new post delivered to your Inbox.