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.

Featured Post

Java Introdcution

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