November 29, 2010

File Magic Numbers in Header to differentiate between files

Hi everyone,
I just came to know about the file magic numbers
http://en.wikipedia.org/wiki/Magic_number_%28programming%29

Its good that, we can identify the file by converting the file to ASCII even someone changes the file extension manually.

I personally tested this by creating one GIF file and saw the file ASCII values are starting with GIF89a.
Later I manually changed the file extension to JPEG and I verified the ASCII values surprised that still the file ASCII values aren't changed. Its GIF89a.

So, I understand one thing, that, if someone changes the file extension to some unknown type, we can easily find the original file extension by this method.

To see the file ASCII values, use hexdump tool.
http://www.richpasco.org/utilities/hexdump.html

See the screeshots
Demo_Image_GIF

See the output ever after changing file extn

Please send your comments and feedback to me

November 24, 2010

Copy Paste Pl/Sql developer queried table data and Auto Format the content

Paste and Auto-format Table records in Excel

While taking backup of the tables, we are doing the following steps.
1.       Executing the query
2.       Copying the content from pl/sql developer
3.       Opening excel and paste the copying content
4.       If we want multiple tables to take backup, we need select next sheet and paste the content
5.       If we need more than 3 sheets we are adding new sheets.
6.       Just copying content from the pl/sql developer doesn’t finish our work, am I right?
7.       We need to format the data too.

So, I just tried to create one auto-formatter which will paste the data and auto-format the data.

Please download the attachment and unzip the file.

After opening the excel file, do the following.

a) Please change the macro settings to "Disable all macros with notification"
     Note: To see how you can change the macro settings, please see the following link


b) Please click on the "User Friendly Formatter" button and follow the procedure.
c) It will open a new file and asks you to save the file.
d) Copy the content from pl/sql developer, when it displayed the following pop-up window.


e) The data will be auto formatted and then asks user for continuation by displaying the following window.

f) If user wants to continue, user can click “Yes” button, and the next sheet will be auto-selected.
g) Goto step (d)
h) When your clicks on “No” button, the file will be autosaved.


Please see the macro code and change according to your requirements.

Source Code:



Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function CloseClipboard Lib "user32" () As Long

Sub CreateNewWorkbook()
    Dim oWorkbook As Workbook
    Dim wbName, fileSaveName As String
    Dim sCount, decision, copied, sIndex As Integer
    Dim oSheet As Worksheet
    
    'On Error GoTo errHandler
    
    Set oWorkbook = Workbooks.Add
    
    Save_ActiveWorkbook
    
    sCount = ActiveWorkbook.Sheets.Count
    'MsgBox (sCount)
    
    If MsgBox("Please copy the content and then click on OK", vbOKOnly, "Decision") = vbOK Then
        CopyAndFormatData
    End If
    
    sIndex = 1
    
askUser:
    decision = MsgBox("Do you want to continue with the next sheet?", _
    vbYesNo, "Decision")
  
'If user wants to continue
    If decision = vbYes Then
    
        'Asking user to copy the data first
        copied = MsgBox("Please copy the content and then click on OK", vbOKCancel, "Decision")
        
        'If user copied data
        If copied = vbOK Then
        
            'Selecting next sheet
            If sIndex < 3 Then
                Sheets(sIndex + 1).Select
                sIndex = sIndex + 1
            'ElseIf sIndex = 3 Then
            '    Sheets(sIndex).Select
            'Adding additional sheet from sheet4
            ElseIf sIndex >= 3 Then
                    Set oSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count))
            End If
            
            'copying and formatting data
            CopyAndFormatData
            
        ElseIf copied = vbCancel Then
            'Confirm the user whether user want to quit and save file
            If MsgBox("Do you want to remain in the same sheet", vbOKOnly, "Save File") = vbOK Then
                Sheets(ActiveSheet.Index).Select
            End If
        End If
        GoTo askUser
    End If
    

savingFile:
    ActiveWorkbook.Save
    
End Sub

Sub CopyAndFormatData()

'If Range("A1").Font.Bold = True Then
    ActiveSheet.Range("A1").Select
    
    On Error Resume Next
    ActiveSheet.PasteSpecial Format:=Text, Link:=False, DisplayAsIcon:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
    If Range("A1").Value Is Null Then
        Range("A:A").Delete
    End If
    
    'select header row and make it as bold
    Cells(1, 1).EntireRow.Select
    Selection.Font.Bold = True
    
    'Autofit column width
    Range("A1").CurrentRegion.Select
    Selection.Columns.AutoFit
    
ClearClipboard

End Sub

Sub ClearClipboard()
    OpenClipboard (0&)
    EmptyClipboard
    CloseClipboard
End Sub
Sub Save_ActiveWorkbook()
'Working in Excel 2000-2010
    Dim fname As Variant
    Dim NewWb As Workbook
    Dim FileFormatValue As Long

    'Check the Excel version
    If Val(Application.Version) < 9 Then Exit Sub
    If Val(Application.Version) < 12 Then

        'Only choice in the "Save as type" dropdown is Excel files(xls)
        'because the Excel version is 2000-2003
        fname = Application.GetSaveAsFilename(InitialFileName:="", _
        filefilter:="Excel Files (*.xls), *.xls", _
        Title:="Save As the Workbook as ")

        If fname <> False Then
            'Copy the ActiveSheet to new workbook
            ActiveSheet.Copy
            Set NewWb = ActiveWorkbook

            'We use the 2000-2003 format xlWorkbookNormal here to save as xls
            NewWb.SaveAs fname, FileFormat:=-4143, CreateBackup:=False
            NewWb.Close False
            Set NewWb = Nothing

        End If
    Else
        'Give the user the choice to save in 2000-2003 format or in one of the
        'new formats. Use the "Save as type" dropdown to make a choice,Default =
        'Excel Macro Enabled Workbook. You can add or remove formats to/from the list
        
        fname = Application.GetSaveAsFilename(InitialFileName:="", filefilter:= _
        " Excel Macro Free Workbook (*.xlsx), *.xlsx," & _
        " Excel Macro Enabled Workbook (*.xlsm), *.xlsm," & _
        " Excel 2000-2003 Workbook (*.xls), *.xls," & _
        " Excel Binary Workbook (*.xlsb), *.xlsb", _
        FilterIndex:=1, Title:="Save As the Workbook as ")

        'Find the correct FileFormat that match the choice in the "Save as type" list
        If fname <> False Then
            Select Case LCase(Right(fname, Len(fname) - InStrRev(fname, ".", , 1)))
            Case "xls": FileFormatValue = 56
            Case "xlsx": FileFormatValue = 51
            Case "xlsm": FileFormatValue = 52
            Case "xlsb": FileFormatValue = 50
            Case Else: FileFormatValue = 0
            End Select

            'Now we can create/Save the file with the xlFileFormat parameter
            'value that match the file extension
            If FileFormatValue = 0 Then
                MsgBox "Sorry, unknown file extension"
            Else
                'Copies the ActiveSheet to new workbook
                Set NewWb = ActiveWorkbook

                'Save the file in the format you choose in the "Save as type" dropdown
                NewWb.SaveAs fname, FileFormat:= _
                             FileFormatValue, CreateBackup:=False

            End If
        End If
    End If
End Sub


Note: Please send your feedback and comments

Fomat USB Pen drive in Linux

Hi everyone,
Lot of my friends asked me that how to format pendrive in Linux.
There are many methods to format pendrive.

Solution1: 
1) Open command prompt and enter into root or su mode.
   $ sudo -su ( In Ubuntu )
   $ su - ( In RedHat )
2) Identify to which device file the pendrive is mounted
    # dmesg | tail
3) Mostly it will be sda or sdb or sdc with some number.
4) Unmount the device file on which the pendrive mounted
   # umount /dev/sdb
   Note: Please change the sdb with your above identified device file
5) Now, we can format the pendrive
   # mkfs.vfat -n 'Label' -I /dev/sdb
   Note: vfat indicates FAT32 filesystem, ext3 indicates EXT3 filesystem.
   Please change the Label with your own Label.

Solution2: 
1) Open command prompt and enter into root or su mode
   $ sudo -su ( In Ubuntu )
   $ su - ( In RedHat )
2) Identify to which device file the pendrive is mounted
   # df
3) Mostly it will be sda or sdb or sdc with some number.
4) Unmount the device file on which the pendrive mounted
   # umount /dev/sdb
   Note: Please change the sdb with your above identified device file
5) Now, we can format the pendrive
   # /sbin/mkdosfs -F32 -I /dev/sdb 

Solution3:
We can format the pendrive using GUI tool also.

1) Open command prompt and enter into root or su mode
   $ sudo -su ( In Ubuntu )
   $ su - ( In RedHat )
2) Install GParted software
   # apt-get install gparted ( Ubuntu )
   For Redhat, Please download the GParted RPM from http://packages.sw.be/gparted/
   Then install the RPM Package
   # rpm -ivh gparted-version.rpm
   Note: Please change the version with your downloaded file version
3) Open the GParted tool
4) Select the drive
5) Choose Partition menu -> Format to -> any file system ( ex: fat32 )
   Note: Many filesystem options are available in Format to submenu.


Note: Please send your feedback and comments to me.

November 18, 2010

Opensource SWs which I have come across today ..

Some Useful Open Source Softwares:

Ninite Easy PC Setup tool:
We can select the softwares from the list and it will download and install those softwares without our intervention in the middle like pressing Next or Continue buttons.
Link: http://ninite.com/

Sumatra PDF Viewer:
Its a slim, free and open source PDF Viewer.
Link: http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html

Teracopy:
Easy to copy error out or corrupted files. We can pause and resume the file copying.
Link: http://www.codesector.com/teracopy.php

November 10, 2010

Linux tools useful for day to day life

Hi everyone,

I just read some of the linux tools description from linux journals. Just want to share those things.

  1. FFmpeg: Video converter to covert videos for YouTube. Our own videos will be converted in to YouTube suitable format.
  2. Mutt: Its a command line e-mail reading tool.
  3. Zsh: Create own shell with different colors and in output also we can put some colors to identify the output easily.
  4. SOX: Audio editor, We can add echo easily by using this editor and we can convert audio to various formats.
  5. Trickle: By using this tool, we can control the network traffic. In torrent downloaders and in browsers we can set the speed while downloading.
  6. Privoxy: Control the web access like blocking unwanted sites and blocking unwanted content.

References:
Linux Magazine
http://www.ffmpeg.org/
http://www.mutt.org/
http://en.wikipedia.org/wiki/Z_shell
http://www.zsh.org/
http://sox.sourceforge.net/
http://www.tuxradar.com/content/control-your-bandwidth-trickle
www.privoxy.org/

Send your feedback and comments
PSR.COM

Have you tried these Google Labs features? I liked these features.

Hi everyone,
I tried these Google labs features and its very useful for every e-mail user. Hope you will also like it.

There are features which will
  1. Insert images in mail
  2. Cancel the mail within 30 seconds, if you forgot attachment, signature, address, etc.
  3. Nested folders
  4. Choosing the correct name suggestion.
  5. Displaying the unread messages count in the title of the page. 
If you want to use or like anyone of the above you can continue reading the blog.
  • To see the Google labs, click on Settings, select Labs tab.
  • Select the Enable option button for the concerned lab feature.
  • Click on Save Changes at top or bottom of the page, to use these features.


Google Labs Features: 

1) Inserting Images:
    This feature provides you to select the pictures from the harddisk or from URL and display in the mail instead of attachment. Lot of my friends asked how to display an image in the mail. By using this feature you can do that.
2) Nested Labels
    Instead of having long list of labels for every simple things, you can group them and make nested labels.
3) Title Tweaks
    It will display the current label with unread message count. If you get any new mail, just by seeing the title in the taskbar, you can identify that you got an e-mail.

4) Got the Wrong Bob?
    This feature will you recommend the user with the similar name. When you are selecting some name, it will list the similar names to choose the correct one. 

5) Undo Send
    Sometimes we will be thinking something and click on send button. After just clicking, we will be thinking like, I shouldn't have click on send button. By using "Undo Send" feature, within 30 seconds we can cancel the sending mail. After finishing everything in the mail, you can send again.
Example: We want to send resume to someone, We will be concentrating on writing some good content and once we are happy with content, we will just press send button without attaching the resume. Just after clicking on send we will identify that, we forgot the attachment. At that point, we can cancel the sending mail and attach the resume and send. I think it happened with lot of you people. It happened with me too.

--------------------------------------
Please send your feedback and comments
PSR.COM

November 09, 2010

Dell Inspiron 1545 Wireless Problem Solution

Hi everyone,

Today one of my friend was faced an issue with the Dell Inspiron 1545 laptop.

The issue is Wireless in not enabled.

He is trying to activate the Wireless connectivity by pressing Function Key (Fn) + F2.

But that is not the correct key or combination to activate the wireless.

Solution:
Just press F2 button and try to reconnect to the wireless network.

Problem is solved. If any one facing the same issue, please solve it.

November 02, 2010

Voltas and LG Air Conditioners Power Consumptions sheet

When my friend asked me to give some information about the power consumptions of air conditioners. I just found some formulas to calculate the power consumption by an A/c.
Here is the sheet, which describes Voltas and LG A/c's statistics.
Voltas

Sl.No Model Ton Capacity Start Rating Cooling Capacity Power Capacity EER Price SEER BTU/hr Usage Hrs/month Electricity Bill
1 Classic 1 ton 2 3500 1306 2.68 20490 2.977777778 11942 300 7820.227612
2 1.5 ton 2 5200 1940 2.68 24490 2.977777778 17743 210 8133.311754
3 2 ton 2 6450 2500 2.58 27490 2.866666667 22008 150 7485.27907
4 Elite S 1 ton 2 3190 1251 2.55 21490 2.833333333 10885 300 7491.441176
5 1.5 ton 2 4850 1900 2.55 25490 2.833333333 16549 210 7972.724118
6 2 ton 2 6300 2470 2.55 27990 2.833333333 21496 150 7397.152941
7 Elite G 1 ton 2 3450 1327 2.6 21790 2.888888889 11772 300 7946.1
8 1.5 ton 2 5050 1942 2.6 25490 2.888888889 17231 210 8141.6475
9 PlusS 1 ton 3 3350 1196 2.8 22990 3.111111111 11431 300 7164.7875
10 1.5 ton 3 5100 1822 2.8 26990 3.111111111 17402 210 7635.1275
11 2 ton 3 6000 2143 2.8 30990 3.111111111 20473 150 6416.091964
12 Plus G 1 ton 4 3175 1076 2.95 23990 3.277777778 10834 300 6445.311864
13 1.5 ton 5 5200 1672 3.11 3.455555556 17743 210 7008.770257
14 2 ton 5 6450 2074 3.11 3.455555556 22008 150 6209.652733
15 Platina 1 ton 4 3500 1186 2.95 24990 3.277777778 11942 300 7104.477966
16 1.5 ton 4 5100 1729 2.95 24990 3.277777778 17402 210 7246.900678
17 2 ton 3 6000 2143 2.8 32990 3.111111111 20473 150 6416.091964
18 Gold 1 1 ton 5 3577 1150 3.11 25490 3.455555556 12205 300 6887.38746
19 1.5 ton 5 5150 1656 3.11 29990 3.455555556 17573 210 6941.617524
20 2 ton 3 6000 2143 2.8 33990 3.111111111 20473 150 6416.091964
21 Gold 1 ton 5 3510 1000 3.51 25990 3.9 11977 300 5988.5
22 1.5 ton 5 5100 1620 3.15 3.5 17402 210 6786.78
23 2 ton 4 6250 2120 2.95 34990 3.277777778 21326 150 6343.581356
24 Premium 1 ton 3 3450 1232 2.8 22490 3.111111111 11772 300 7378.521429
25 1.5 ton 3 5200 1857 2.8 26490 3.111111111 17743 210 7784.74125
26 2 ton 3 6000 2143 2.8 29490 3.111111111 20473 150 6416.091964

LG

Sl.No Model Ton Capacity Start Rating Cooling Capacity Power Capacity EER Price SEER BTU/hr Usage Hrs/month Electricity Bill
1 LSA18CGAFH1 1.5 ton 5040 1800 2.8 29990 3.111111111 17197 210 7545.18375
2 LSA24CGAFH1 2 ton 6300 2450 2.57 32790 2.855555556 21496 150 7339.587549
3 LSA5RW5LB1 1.5 ton 5450 1620 3.36 37990 3.733333333 18596 210 6799.1625
4 LSA5AW3VT6 1.5 ton 3 5275 1830 2.88 28590 3.2 17999 210 7677.698438
5 LSA5NF3F6 1.5 ton 3 5125 1830 2.88 28590 3.2 17487 210 7459.298438
6 LSA6AW2VT1 2 ton 2 6450 2480 2.6 31290 2.888888889 22008 150 7427.7
7 LSA6AW3VT1 2 ton 2 6300 2250 2.8 34590 3.111111111 21496 150 6736.692857

Please send me the feedback.

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com