After a break

It has been long time since I blogged last. Well, partly because now a days one liner in social networking takes most of the bandwidth and mostly because my job role now demands lot of hours. It is kind of exciting to work where there is full freedom to decide what kind of software stack to use, how to design and finally code something that people actually use.  

This also means that in almost last 10 months I haven’t done anything with my photography or pending projects, which is shameful.

I hope to take some time out and finish long pending projects et.al. 

Droid/Tux/Web

A close friend of mine bought an android phone.However much of her excitement went down the drain when she was unable to connect to the internet using her ad hoc sharing of Ethernet.

if you are in a similar situation and use linux/fedora and wanted to connect to the internet, here is a small way of doing so. If you use windows 7+ however, you can use an application called connectify. :

Step 1.

$sudo yum install hostapd

Step 2.
Configure hostapd with few lines, there are many options feel free to explore

interface=wlan0
hw_mode=g
channel=6
ssid=Yourssidhere

macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=yourssidpasshere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Step 3.
Stop the hostapd service if it is running:

$sudo service hostapd stop

or

$sudo systemctl stop hostapd.service

Step 4.
Go to your network manager, wireless and turn on the hotspot.
Step 5.
Restart the hosapd service

$sudo service hostapd start

or

$sudo systemctl start hostapd.service

Done

There is a better way of doing this with bridge-utils, dnsmasq, and hostapd, I will blog about that later.

Migrating from Bzr to Git (Single branch)

We migrated the ChaloBEST Repository from bzr to git. While migration is not a rocket science any more and there are a lot of blogs and threads about this. This post is a simple step as how to and also as self note.

Step 1. Branch out your bzr repo.

<code> $ bzr branch "url to your bzr repo"</code>

Step 2.cd into your new branch and do the following

<code> $ git init </code>
<code> $ git remote add origin "url to git report" </code>
<code> $ bzr fast-export `something`|git fast-import</code>

Step 3. In case your original git repo is not empty, please do a

<code> $ git pull </code>

Step 4.  Now do a

<code>$ git reset --hard  HEAD</code>

Step 5. Now commit the changes using

<code> $git commit -m "some message"</code>

Step 6.  Push the changes

<code> $git push </code>

Here are some links that helps out with migrating both branches and master.

To the south, sir!

It has been sometime while playing with Django. One problem that I face mostly is making changes in the model and expect the change to reflect itself on the fly. Django, however does not like this idea and does not let you do so. In most case if you are making a model and want to create the DB schema you will do something like this:

python manage.py syncdb

This will create your model, however once created and then if you want to make changes in the schema, you are not going anywhere. So this is where we need to go south.
Django south generally works in this way:

python manage.py schemamigration <appname> --initial

Then you do a

python manage.py migrate <appname>

This is enough to create a migration directory and track changes to your model based in the appname you are using.
So now if you are making changes to the column, you will be using south. The next few lines will deal with screwing thing inside south as well as making you model change successful. One piece of caution though, this will/may delete your existing data, so be careful.
Let say, you end up with an error like this while migrating using south.

! These migrations are in the database but not on disk:
some migrations here
! I’m not trusting myself; either fix this yourself by fiddling
! with the south_migrationhistory table, or pass –delete-ghost-migrations
! to South to have it delete ALL of these records (this may not be good).

This happens because there is conflict in the original model and the model you are trying to implement.

The following steps will help:

Undo changes in the model.py intended to have the change and delete the migration folder in the folder, then run

python manage.py migrate <appname> --delete-ghost-migration

This step will delete all the migrations that has not trickled down properly.
If your app is already managed by south then run the next step, else if your app was previously managed by syncdb only, use this command first:

python manage.py convert_to_south <appname>

Coming back to our steps:


python manage.py schemamigration <appname> --init


python manage.py migrate <appname> --fake

The argument –fake will record the changes but will not write it to the DB.
Now redo the changes in the model.py

python manage.py schemamigration <appname> --auto

The argument –auto will keep track of the changes happening over the initial change/previous changes.

python manage.py migrate <appname>

And that’s it, you are done and your changes has flown to the DB.
Please read south documentation for more details, it can be found here.

Wildlife and Us

It has been little over a year since I am associated with wildlife photography closely. However over the year I have learned about various species, their behaviors, habitats and how to photograph them. Even though I am still in learning phase of being a photographer, one thing I learned pretty closely is the risk we, humans pose to the wild.

Here are few stereotypes I have found during this course.

Wildlife Photographers:

First set of people are amazing photographers and they have these B-I-G big lenses, so that means they are able to shoot best of the photographs from quite a distance. However not always, in some cases photographers for the sake for getting the most exclusive photographs takes their gypsies or go very near to the animal or bird they are photographing . So close that even the tiger you are photographing gives an exclamation like “Dude!!!”

Loved the road runner and coyote show..eh! well there has been cases when a bird had to run like road runner while coyote with better acme products is chasing it. Even a sloth bear was that unfortunate.

Again for some other weird reason in order to take breathtaking photograph, photographers become infiltrators, I am sure if birds were to have a political party it would have called for some strikes and hunger strikes by now. Few examples includes, cutting a bird nest to half so as to have a better view inside the nest. I wonder how you will feel if some photographer cuts down your house to take better picture of your morning life cycle. Another one is to clear off the area around the nest for better photographs thereafter leaving it exposed to predators and other harms. Some even go to the extend of destroying the nest so that no other photographer can take the similar picture, hmm! now that sounds familiar..right!.

Here is one guy who went to the extend of writing a book with this tactics:
Life Cycle of birds( A pictorial representation) By Bhagat Singh.
These has been a huge uproar in popular social networking site regarding this.

Wannabe Steve Irwins(not to insult the great personality in any way, he is a legend):

Few months back a guy who can’t help comparing himself to some legendary conservationist. He went to the extend of catching a very rare and endangered mammal(a Namdapha Flying Squirrel) inside a national Park and then pose photograph with it, injuring it in the process, taking it out of the wild and leaving it in ‘Care’ of Humans. However when confronted by members of INW(India Nature Watch, If you are a member of INW you know what I am talking about), the reply he gave was more shocking and can be considered to be a serious threat, not to mention he violated several protocols of Wildlife Protection Act(1972).

This is not singular case, there has been different instances where people who are attached with wildlife groups and agencies cannot keep their excitement level to low.

The Weekender :

After a hectic week in closed glass box called offices, many will opt for some refreshment over the weekend. What can be more relaxing than a fantastic resort down the bed of river with Himalayas all around you. Weather is cool and soothing, this is a perfect recipe of a weekend getaway.
But here comes the problem. You decide to play music from your car stereo with 11 inch sub in the middle of the jungle. The resort manager tries to convince you the sound will attract elephants which will pose the threat to both the resort and you. But you will be like “Dude, I have paid for this, so this is my right”.
Please pray to your god that you came out alive that night.

The Gypsy Tourists:

You took your friends and family to a jungle and you wants to see tigers. Since you cannot see a tiger in first two safari’s, you are pissed off and you curse your gypsy driver and guide for the same. your money is getting wasted. you curse for their incompetence and then it happens.

A tiger comes out and all you can see is the tip of the tail. you want to see more. You started behaving like you own it. Shouts at your gypsy driver and eventually when the tiger is about to go away, your gypsy driver chases it so that you get a better glimpse of the majestic animal. If you are lucky enough you will get close enough to the tiger to pee in your pants. Ignorant of the fact that, this irresponsible behavior poses a threat to both you and the tiger.
Thankfully, the supreme court has banned all tourists from entering the core zone of the tiger reserves across the country. So “no tip of the tail” anymore.

The other set of gypsy tourists talks. How does this pose a threat!
You talk, then you get excited,and you talk so loudly that there comes a huge ‘sssshhhhhh’ from all other fellow tourists around you. Any tiger reserve and you will be welcomed with this situation. I have seen tourist talking loudly and sleeping tiger walking up with face “Go away, you morons!!”. Even though that looked cute then, I am sure situation would be different if tiger decides to take things in its own hand…err…paws.

The awww so cute ones:

How many times have you seen a cute little baby of a monkey and made the expression like awww! so cute. Well, apparently not all can stop just with that expression. They cannot control their emotions and put out a pack of biscuits and chips out from the window to feed these animals. The point you forgot is, those are for you and not for the bird or animals whom you feel is starving and hungry.
Birds and animals adapted themselves to those situation and now knows that you will come to feed them and there have been instances when they attacked because they didn’t get food from you. Familiar with the situation??

So does this means, you should not visit forests. answer is yes and no at the same time.

If you respects wildlife and the jungle mesmerize you every time you visit. You do good study on animals and their behavior. The color of the bird amazes you and you more than happy to spot a very rare bird even if you were not able to photograph it. You maintain all rules and regulation inside the forest and help keep it clean and is genuinely concerned about it. Please visit, the forests need people like you.

If you are “oh! I don’t care”, “It my money”,”Do you know who I am?” in other word a self obsessed person who just wants a weekend visit/Holidaying/relaxing and not willing to abide by the rules and regulations, please do not visit the forest and spoil it. Take your car and 11 inch sub and go for a long drive maybe.

While I agree that government should take more measures and forest department should do their work, but it always like we should be more responsible towards others.This way both you and nature live in harmony(A word long forgotten since childhood). The supreme court does not get a chance to put ban on visit to core areas of the tiger reserve. Is this too much to ask???

P.S : This topic might feel controversial. Feel free to ignore in case you don’t like it.
P.P.S: The post is just my expression as you may take it, so I have refrained from posting links to actual incidents. If you are a wildlife enthusiast based in India, you should have probable already faced the situation or read about it.

API parsing with Backbone.js

The next part of the self note series, this time I have to parse JSON using backbone.js.
So in order to parse an API that returns result in JSON you can do the following(not necessarily the best way but it works for me)

(function($) {
var API_BASE = 'your url here';

var parser = Backbone.Model.extend({});

var apiColl = Backbone.Collection.extend({
model: parser,
url: 'form your url here'

});
var apiView = Backbone.View.extend({
el: $('#collection'),
initialize: function() {
_.bindAll(this, "render");
this.collection.bind("all", this.count);

},
render: function() {
$(this.el).html(this.counter = this.collection.length);
return this;

}
}),
events = new apiColl(),
eventView = new apiView({

collection: events

});
events.fetch({
success: function() {
console.log(events.length);
}
});
})(jQuery);

and yes, my ultimate target will be to parse the API and integrate with some open maps.

Even though Backbone’s code is pretty well explained, the main help if stuck comes from stack overflow. So really appreciate the help that I got.

Ouch! My Bad

JavaScript is powerful and Backbone.js is a nice small utility that makes it even more powerful. I was playing with Backbone and Open layers thrown over a Django system.
However there is something weird that I faced and took a good amount of my time to figure out the problem.
This blog post is kind of self note so that I notice this the first place when I face such problem again.

What was I trying to do : Write a small backbone code to display Open layers(OSM) Map.
How was I trying to do :

(function($) {
var Map = Backbone.Model.extend({});

var MapView = Backbone.View.extend({

initialize: function() {
_.bindAll(this, 'initMap');
this.initMap();
},

initMap: function() {
// Initialize Basic Openlayers;
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
map = new OpenLayers.Map(this.el, {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
var layers = [];
layers[0] = new OpenLayers.Layer.OSM(); //some more layer will go here
map.addLayers(layers);
map.setCenter(center, 12);

}
});
var map_view = new MapView({ el: $("#mapCol") });
})(jQuery);

The problem faced here was I am trying to access the DOM element even before it is ready.
Result : A webpage which shows the HTML elements, shows some access to Openlayers but no map.

Solution : I modified my code to this

(function($) {
var Map = Backbone.Model.extend({});

var MapView = Backbone.View.extend({
el: '#mapCol',

initialize: function() {
_.bindAll(this, 'initMap');
this.initMap();

},

initMap: function() {
// Initialize Basic Openlayers;
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
//alert("you are here");
map = new OpenLayers.Map(this.el, {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});

var layers = [];
layers[0] = new OpenLayers.Layer.OSM(); //some more layer will go here
//$(this.el).html(map);
map.addLayers(layers);
map.setCenter(center, 12);

}
});
$(function() {
var map_view = new MapView();

});
})(jQuery);

Here mapCol is the div element where I want my Openlayers map to be displayed. For more details on Backbone and el, there is a beautiful blog post here.

P.S : There may be certain errors in the codes above. please feel free to correct me anytime.