Friday, December 21, 2012

svn command line diff and patch

Creating a patch file

Creating a patch file is really easy. First, check out the most recent version of the code from Subversion using the ‘checkout’ command.
Make your changes.
Then, in the root the project run the following command. It will store the patch file in your home directory. Make sure to give it meaningful filename.
 
svn diff > ~/fix_ugly_bug.diff

The file has the .diff extention, which stands for differences. This extension is recognized by many text editors and enables ‘syntax highlighting’ automatically. (Give it a try with TextMate and you’ll know what I mean.)
You can send the diff-file to the author of the project by email, or you can create a ticket in Trac and add it as an attachment. The author will review the changes you made and possibly apply them to the source.

Applying a patch

You should never apply patches from any person other than your development team without first reading through the changes, apply them locally and test your application and then commit them. Patches can not only include bug fixes, but also alterations to create back doors or add other exploits to your code.
Always read through a patch before applying it!
When you are sure the patch will bring no harm to you, your application or your customers, go ahead an apply it to your working copy. Here, I assume that you downloaded the patch file we previously generated, and placed it in your home directory. In the root of your application now run:
 
patch -p0 -i ~/fix_ugly_bug.diff

This will apply all the changes in the patch to your source. The -p0 option makes sure that all files can be found correctly (this has to do with something called ‘zero directories’, I won’t get into that right now). The -i option tells ‘patch’ what to use as input, in this case the ‘fix_ugly_bug.diff’ file in your home directory.
With the code changes in place, run your tests and make sure everything works as expected. If it does, commit your changes and celebrate with a cup of coffee.

PS : More information can be found in this original post.

.screenrc short but sweet

hardstatus alwayslastline "%{-b ck}%?%-Lw%?%{bg}%n*%f %t%?(%u)%?%{wk}%?%+Lw%? %= %{r} %H %{g} %D %d/%m/%Y %0c "

Saturday, August 4, 2012

Gedit JSON, XML formatting plugin

Here’s how to add commands to Gedit to format JSON and XML documents.

  1. Ensure that you have an up-to-date version of Python.  It’s included with nearly every Linux distribution.
  2. Ensure that the External Tools plugin is installed
    1. Click Edit -> Preferences
    2. Select the Plugins tab
    3. Check the box next to External Tools
    4. Click Close
  3. Add the Format JSON command
    1. Click Tools -> Manage External Tools…
    2. Click New (bottom left, looks like a piece of paper with a plus sign)
    3. Enter a name (Format JSON)
    4. Paste this text into the text window on the right
 code :
         
#! /usr/bin/env python
 
import json
import sys
 
j = json.load(sys.stdin)
print json.dumps(j, sort_keys=True, indent=2)
 
  1. Set Input to Current document
  2. Set Output to Replace current document
  1. Add the Format XML command
    1. Install lxml (on Ubuntu, sudo apt-get install python-lxml)
      1. Python’s included XML modules either don’t support pretty printing or are buggy
    2. Create a new external tool configuration as above (Format XML)
    3. Paste this text into the text window on the right
#! /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

  1. Set Input to Current document
  2. Set Output to Replace current document

original score : www.connorgarvey.com/blog/?p=264

Tuesday, February 21, 2012

connecting iPad2 to secure (ad hoc) wifi network

1. Create a ad-hoc secure wifi in your OS with WEP 40/128 bit key (Hex or ASCII)
2. Toggle iPad wifi switch using WiFi settings
3. Now iPad wifi will show newly created Ad hoc network.
4. Connect to this network, It will prompt for password, now enter the password.
5. iPad2 will show successful connection.

Thursday, December 1, 2011

google office copy paste problem

firefox prevents the sites to copy or paste malicious contents, so this security feature also blocks normal functionality of google office. Below mentioned fix can be extended to add exceptions for another sites too. 

step 1 : open user.js file in mozilla profiles dir.
$> vim ~/.mozilla/firefox/<profile dir>/user.js

step 2 : append following lines in the file.

user_pref("capability.policy.policynames", "allowclipboard");
user_pref("capability.policy.allowclipboard.sites", "http://docs.google.com");
user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess"); 

step 3: save the file and restart the firefox. 

for more info click here 

Monday, October 3, 2011

SVN - merge the branch with trunk

1. create a new temporary folder, if not already exists.
    $> mkdir temp
2. go to temp folder.
    $> cd temp
3. check out trunk from SVN repository.
    $> svn co <SVN trunk URL >
4. go to specific project folder where you want to merge the branch code e.g. Test
    $> cd /home/<your home folder>/temp/trunk/Test
5. now start integrating the branch code
    $> svn merge --reintegrate svn://<svn server ip>/branches/Test

Thursday, August 11, 2011

shell scripting - IFS newline [\n] not working

When you try to set IFS as a newline character, It just interprets "\n" as "n". After trying for while I found out that, It works fine if IFS is set as IFS=$'\n' .

cheers !!!!