Friday, November 29, 2013

How to make MAC write on NTFS drive

By default Mac OS can only read NTFS, it cannot write to it.
Follow these steps to write on your NTFS disk(tested with MAC 10.8.5).
1. open Terminal
2. ls /Volumes/
    you can see all available Disks name.
3. Now I assume your external hard-disk name is "Mantosh Harddisk".
    diskutil info /Volumes/Mantosh Harddisk
     Now you must be seeing all the info related with your disk.
4. sudo vi /etc/fstab
    This is a system file, that's why you need to use sudo.
5. write the below line in this file.
    LABEL=Mantosh\040Harddisk none ntfs rw,auto,nobrowse 
    \040 is for space in hard-disk name.
    (if LABEL is not supported in your system, you can use UUID=NUMBER none ntfs rw,auto,nobrowse)
6. Quit Terminal and Now, just unmount and re-mount the disk.

Wait a minute, I don’t see my disk listed in the Finder window!
As of Mountain Lion, the “nobrowse” mount option is required for this to work. This means that the partition will not show up on your desktop. However, you can access it normally through Finder by doing the following:
  • Open Terminal and type “open /Volumes/THE_NAME_OF_YOUR_VOLUME” (without the quotes)
  • The Finder pops up automatically and you can see your disk listed there.

OR simply format your hard-disk to FAT file system.

Thursday, November 28, 2013

Solution: To change a local variable in Pdb

In the previous post, I had mentioned the problem. This is happening because the cache of the current frame gets  overridden by the contents of the real locals which undoes modifications made by the debugging user.

To have a solution for this issue, you need to make changes in your installed python package. Here are the steps.
Note: This change will be effective for Python 2.4 version(Tested with this version only)
1.  Login your mach as a root user.
2.  cd /usr/lib
3.  chmod 777 python2.4/pdb.py
4.  cp python2.4/pdb.py YOUR_BACKUP_LOC (Do not forget to have a backup of this file. We are going to make changes in this file)
5.  Make changes in /usr/lib/python2.4/pdb.py as said below.
6.  chmod 755  python2.4/pdb.py

Changeset for pdb.py.

--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -114,6 +118,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
 def setup(self, f, t):
        self.forget()
        self.stack, self.curindex = self.get_stack(f, t)
        self.curframe = self.stack[self.curindex][0]
+       # The f_locals dictionary is updated from the actual frame
+       # locals whenever the .f_locals accessor is called, so we
+       # cache it here to ensure that modifications are not overwritten.
+       self.curframe_locals = self.curframe.f_locals
        self.execRcLines()

@@ -202,7 +210,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
     def default(self, line):
         if line[:1] == '!': line = line[1:]
-        locals = self.curframe.f_locals
+       locals = self.curframe_locals
         globals = self.curframe.f_globals
         try:
             code = compile(line + '\n', '<stdin>', 'single')

@@ -360,7 +368,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
      def do_break(self, arg, temporary = 0):
                 .........
                 .........
                 try:
                     func = eval(arg,
                                 self.curframe.f_globals,
-                                self.curframe.f_locals)
+                               self.curframe_locals)
                 except:
                     func = arg
                 try:

@@ -681,7 +689,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
     def do_debug(self, arg):
         sys.settrace(None)
         globals = self.curframe.f_globals
-        locals = self.curframe.f_locals
+       locals = self.curframe_locals
         p = Pdb(self.completekey, self.stdin, self.stdout)
         p.prompt = "(%s) " % self.prompt.strip()
         print >>self.stdout, "ENTERING RECURSIVE DEBUGGER"

@@ -705,9 +713,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
    def do_args(self, arg):
-        f = self.curframe
-        co = f.f_code
-        dict = f.f_locals

+       co = self.curframe.f_code
+       dict = self.curframe_locals

         n = co.co_argcount
         if co.co_flags & 4: n = n+1
         if co.co_flags & 8: n = n+1

@@ -719,8 +726,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
     def do_retval(self, arg):
-        if '__return__' in self.curframe.f_locals:
-            print >>self.stdout, self.curframe.f_locals['__return__']

+       if '__return__' in self.curframe_locals:
+           print >>self.stdout, self.curframe_locals['__return__']

         else:
             print >>self.stdout, '*** Not yet returned!'
     do_rv = do_retval

@@ -728,7 +735,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
     def _getval(self, arg):
         try:
             return eval(arg, self.curframe.f_globals,
-                        self.curframe.f_locals)
+                       self.curframe_locals)
         except:
             t, v = sys.exc_info()[:2]
             if isinstance(t, str):

@@ -797,7 +804,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
     def do_whatis(self, arg):
         try:
             value = eval(arg, self.curframe.f_globals,
-                            self.curframe.f_locals)
+                           self.curframe_locals)
         except:
             t, v = sys.exc_info()[:2]
             if type(t) == type(''):

Note: This is not exactly a changeSet. You need to manually modify the code. Red code is existing code and should be removed and Green code should be replaced in those places.

Wednesday, November 27, 2013

Changing a local variable in the Python debugger

I know that there is some issue with pdb debugger when you try to change a local variable.
But while trying to get any possible workaround, encountered this.
Have a look at it.



In the above case, local variable x has been changed in pdb mode. All I did was not to stop at any point after changing this variable.

Now look at this.


Here local variable has not been changed. Here after changing its value to "hello" all I did was to go stepwise. Even tried again to change it to "exper" but that also didn't work.

This has been a long-standing issue, dating back at least to this 2004 post on this topic.  There must be some temporary patch available for this.

Look for my new post. As soon as I find the fix, will post that here.

Indirect Data Forwarding Tunnel

>> Indirect data forwarding is needed only in case there is no user-plane available between Source eNB to Target eNB/Target-Rnc.

>> Indirect tunnel is created between
Source eNB - Source SGW - Target SGW - Target eNB.

>> Used for forwarding the buffered traffic from old-eNB, Here MME can select a new SGW to forward this traffic.
i.e Source eNB -- New SGW - Target SGW - Target eNB.
The New SGW being selected acts just a next-hop router.

Saturday, November 23, 2013

The Mother India

Just finished reading a book on Indira Gandhi. I always liked her and appreciated her as one of the finest and the courageous leader our country ever had. Almost all(not all) her decisions were justified by our country situation and necessity at that time. She has always been my role model since the time I got my little brain functioning.

Given the power and chance to rewrite history I would like to change just one instance i.e. rewrite the page of 31st Oct 1984, the day Indira took her last breath, the day she got assassinated. I am least bothered or feel upset losing any political leader whether it is Gandhi or anybody, but have an emotional and compassionate feeling for losing her. To me, losing her hurts like losing my own mother.

Perhaps she felt the steps of coming death. "If I die today, every drop of my blood will invigorate the nation"- this was the last speech she gave on 30th Oct ’84.

I observe this date as analogous to Muharram for us Indians. She died protecting the integrity of our nation. 31st Oct- Rashtriya Sankalp Diwas (National Integration Day) that we observe every year, this name conveys everything.

 

Rest in Peace Mother Indira. We will always miss you and your presence. You will live forever in our heart.

Tuesday, November 19, 2013

Changing your vnc password

Your VNC password is not the same as your UNIX password. Your VNC password must be set yourself. Your VNC password is encrypted within the passwd file in your .vnc directory. You can try to decrypt it (not recommended), or you can replace it (recommended).

Your VNC password and Unix logon password are two separate entities, so it's wise to choose a VNC password that is different than your Unix password. You can use the pwhelp command on Unix to generate a secure password for the VNC server.

To change the VNC password you must first delete the existing password file. From your home directory on Unix use the rm .vnc/passwd command to do this. Once you've accomplished that all you need to do is restart your Unix VNC session (use vncserver). The VNC server will recognize that you don't have a password set and prompt you for a new password. This enables you to keep an existing session active without having to restart the VNC server.

hostname% rm .vnc/passwd
remove .vnc/passwd? y
hostname% vncserver
You will require a password to access your desktops.

Password: ********
Verify: ******** 

Sunday, November 10, 2013

Calculating Networks, Hosts and Broadcast Addresses

134.77.168.143 / 27

134.77.168.143
255.255.255.224

Binary 
134     .   77   .   168  .   143
10000110.01001101.10101000.10001111
255    .    255    .   255   .   224
11111111.11111111.11111111.11100000

Like Bits = Network
10000110.01001101.10101000.100 00000  /27
134     .   77   .   168  .  128
Broadcast = All Bits on
10000110.01001101.1010100.100 11111  /27
134     .   77    .  168 .   159

First Usable = First Bit on
10000110.01001101.1010100.100 00001  /27
134     .   77   .   168  .  129
Last Usable
10000110.01001101.1010100.100 11110  /27
134     .   77   .   168 .     158

.128 64 32 16 8 4 2  1
.X     X  X  X X X X X