Friday, July 10, 2015

application/x-www-form-urlencoded or multipart/form-data?

The MIME types application/x-www-form-urlencoded and multipart/form-data are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other.

Which is more suitable? http://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data

Tuesday, September 18, 2012

Remotely connecting to a unix machine in graphical mode


ssh user@host lets you to access a unix machine in command line mode.

But if you need to access its UI, you need to access the graphical mode. This can be achieved by using ssh with X forwarding. This is the command for that.

ssh -X user@host

This will set the DISPLAY variable automatically. The X programs you run will be automatically tunneled back through the ssh connection.

Thursday, March 29, 2012

command-line looping to stress jaggery run-tim

Got to know this is how command line looping is used:
while [ 1 ]
   do
      ls -al  ; sleep 60
   done
Applying this to stress command-line jaggery
while [ 1 ]
     do sh jaggery.sh /home/yumani/Documents/projects/jaggery/mine/array/array.jss; sleep 10;
done

Tuesday, January 3, 2012

Backup & restore DB2 database

Following will be helpful when you need to backup and restore a db2 database;  

To back-up;
Type following command in command editor.
backup db to <db_name> to <location>
i.e. backup db YUM to c:\db_dump 

When this command is successfully executed the following will appear in the response window; "Backup successful. The timestamp for this backup imageloca is: xxxxxxxxxxx" 


The dump will be available in the location you specified with the timestamp (stated above) being part of its name.
i.e. YUM.0.DB2.NODE0000.20120103141256.001  

To restore;
Type following command in command editor.
restore db taken at <time-stamp>
i.e. restore db YUM taken at 20120103141256



Wednesday, December 14, 2011

Copy and paste content from one file to another file in VI

Here are steps:

  1. Open the file you need to edit
  2. :sp /path/to/the/file/... and open the file that you need to copy from (this will split the window and open the other file in top section)
  3. Locate the lines you want to copy. If it 10 lines type 10yy
  4. Move to the other file using CTRL+ws
  5. Figure out where you need to paste the yanked lines type p
That's it :)


Tuesday, November 22, 2011

Syntax Highlighting & Word Counter

Syntax highlighting and word count are much needed tools when doing articles/tutorials to wso2.org.

Following are useful links.
syntax highlighting - http://alexgorbatchev.com/SyntaxHighlighter/manual/demo/highlight.html

Word counter - http://www.wordcounttool.com/









Sunday, November 20, 2011

s in sed

I was doing an article where I was copying code snippets from a my editor to the article's editor. When switched on to the HTMl view I noticed that there are <p></p> tags added in my source. I was to delete these away to make my code look neater. sed was my time savor.

sed s command is used like this; say I need to replace cool with crap, the command is;
sed -e 's/cool/crap/g'

So for my task, I copied the code snippet to a temp file and ran folliwing shell script to get my source code cleaned up. Nice and cool, love it :)
sed -e 's/<p>/ /g' temp.txt > temp1.txt
cp temp1.txt temp.txt
sed -e 's/<\/p>/ /g' temp.txt > temp1.txt

'/' is a delimiter in sed, so when you use a regular expression with '/' in it you will need to quote it using a backslash (\).

In above I've said to change <p>in temp.txt to a space and copy the updated code in temp1.txt. Then I copy the updated temp1 content to temp.txt and remove </p>s from it.

Day 03 Gala Dinner Highlight Video