Showing posts with label Format. Show all posts
Showing posts with label Format. Show all posts

August 27, 2020

Notepad ++(PlusPlus) Auto increment line numbering or symbol (bullet) to the text content using Column / Multi-Selection Editor

 Hi folks,

I was searching for automatically adding numbers for the content which is distributed in sequential lines

Sample Input

A

B

C

Multi-line Column Select

  • Press and hold Alt keyboard button and drag the mouse cursor from top-bottom (bottom-top) in the same column (say column 1)
  • Keyboard Shortcut: Press and hold Shift + Alt and Click DownArrow/UpArrow until the end of the column

Column / Multi-Selection Editor

  1. Click Edit Menu
  2. Select Column Editor (Alt + C)

Insert Number list

  1. Choose "Number to Insert" section
  2. Enter the values in "Initial Number", "Increased by" and "Repeat"
  3. Check "Leading Zeros", if required

Insert Text

  1. Choose "Text to Insert"
  2. Insert the desired text/symbol

Format Selection

  1. Choose the desired format
  2. Default to "Decimal"

Please find the below image for your reference

Sample Output of auto increment number

1A

2B

3C

Sample Output of prefixing hyphen (-) to list

- A
- B
- C

Hopy this blog gives to explore more of Notepad++ editor. Happy hacking.

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

October 24, 2019

Markdown file convert/export to html, png, jpeg, pdf with images

Hi folks,

Today I will share about, how we can include the images in markdown file and export to pdf, html, png and jpeg formats.

You can do this with 2 Visual Studio Code extensions

Pre-requisites

Visual Studio Code with following MarkDown Extensions
  1. To place images
  2. To convert the markdown to pdf, html, png and jpeg formats
Install the above 2 Visual Studio Code extensions.

Insert an image

Create images folder and keep all your images (Optional, but easy to maintain)
Syntax: ![](images/imagename.extension)
Usages: ![](images/abc.png)

By now, your image is part of your file.

Preview your file

Open Command Palette (View -> Command Palette OR Type F1 OR Ctrl+Shift+p)
Type "Markdown: Open Preview" OR Ctrl+Shift+v keyboard shotcut

Export Markdown

Open Command Palette (View -> Command Palette OR Type F1 OR Ctrl+Shift+p)
Type export and select below
  • markdown-pdf: Export (pdf)
  • markdown-pdf: Export (html)
  • markdown-pdf: Export (png)
  • markdown-pdf: Export (jpeg)
  • markdown-pdf: Export (all: pdf, html, png, jpeg)

Change Markdown conversion settings

  1. Select File > Preferences > UserSettings or Workspace Settings
  2. Find markdown-pdf settings in the Default Settings
  3. Copy markdown-pdf.* settings
  4. Paste to the settings.json, and change the value
Hope this blog is useful to insert images in your markdown file and export to supported formats.

Please send your valuable feedback and comments to psrdotcom@gmail.com

July 18, 2012

Text Formatting in *NIX to run Script files of Different Platforms

Hello all,

While writing shell scripting in Ubuntu, Windows and deploying it in *NIX based machine, we found some issue. That the file running perfectly on the Ubuntu (Linux), Windows machine. The same script was displaying errors like

'\r': command not found
^M: command not found
 
There was a formatting issue. You need to run the following command to resolve it.

DOS2UNIX

Installation:
sudo apt-get install tofrodos

Syntax: 
dos2unix filename

Example:
dos2unix script1.sh

To know more about this you can go through References.

References:
http://linuxcommand.org/man_pages/dos2unix1.html
http://www.thefreecountry.com/tofrodos/

If you have any further queries, please add your comments. You can also mail to psrdotcom@gmail.com

May 08, 2012

Micro SD Card, Unable to Format, Write Protected

Hi friends,

One more issue with some precaution. My friend formatted his micro-sd card and trying to copy the files from computer to sd card using card reader. The files aren't copying into the sd card. We tried to format the drive and it was showing an error in windows like "Windows was unable to format the drive".

We tried to format the drive on Linux, Mac also. Tried to use "dd" command to write random data in it. It was automatically disconnecting from PC/Mac. i.e. The drive is not accessible after sometime.

Then we have come to one conclusion that "Never, Ever format your sd card from the phone". It will not be accessible by the PC/Mac.

We tried to use the same SD Card in Samsung mobile also. It was detected and formatted from the Samsung phone too. It was formatted successfully. But when we were trying to copy some files to the sd card, It says "Drive location is accessible".

Lesson: "Don't format your micro-sd card from phone"

If anyone knows, how to solve this problem, please let me know.

Send your feedback to psrdotcom@gmail.com

December 16, 2010

Word 2007 Macro for auto-formatting the content in each line

Description:
Word macro for iterating entire document line by line and edit the content

Sometimes we may need to format the string with quotes and comma. I have been facing this for sometime. If the content is less, it will ok to go to the starting position of the string and type " or ' and go to the end of the string and type " or ' and appending , at the end of every line, etc.

Example:

Input:
abc
def
ghi

Output:
'abc',
'def',
'ghi'

What you need to do, Please follow the below steps.

1) Just download the macro code below and paste in word visual basic editor or create a macro with this code
2) Edit the code according to your convience either to use " or '
3) Save the code and run the macro
4) It will confirm with the user whether the user copied the data or not.
5) Wait for user to copy the content
6) Automatically format and copy the formatted content
7) Displays a message to user saying that "Data is formatted and copied. You can paste the content in required application"

Its very simple and useful. Try this.
Macro Code:
sub FormatData()
Dim lineCount, i As Integer
Dim oWB As Document
Dim decision As Variant


Set oWB = Documents.Add
oWB.Activate


decision = MsgBox("Please copy the content and then click on OK", vbOKCancel, "Decision")


Select Case decision
Case vbOK 'If user agrees proceed further by pasting the content
'Paste the content from clipboard which is copied
Selection.PasteSpecial DataType:=wdPasteText, Placement:=wdInLine
Case vbCancel 'If user clicks on cancel then exit
GoTo last
Case Else
GoTo last
End Select


'got the first line
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst


'Formatting the data


'Counting number of lines
lineCount = oWB.BuiltInDocumentProperties("Number of lines").Value


For i = 1 To lineCount
'Quoting the line
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="'"
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="'"


'Appending , till linecount-1 line
If i < lineCount Then
Selection.TypeText Text:=","
End If
'Moving to next line
Selection.MoveDown Unit:=wdLine, Count:=1
Next i


'copy the content in the document
ActiveDocument.Content.Copy


ActiveDocument.Close savechanges:=wdDoNotSaveChanges


'Informing user that he/she can paste the data where ever required
MsgBox ("Content is formatted and copied, Please paste the data in the required application")


last:


End Sub


'Help:
'go to the beginning
'Selection.HomeKey Unit:=wdStory


'go to the end
'Selection.EndKey Unit:=wdStory


'got the first line
'Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst


'go to the last line
'Selection.GoTo What:=wdGoToLine, Which:=wdGoToLast


'If you just want to select a line, you can also do something like this :
'Selection.HomeKey Unit:=wdLine
'Selection.EndKey Unit:=wdLine, Extend:=wdExtend


'Count number of words
'sNumberofwords = oWB.BuiltInDocumentProperties("Number of words").Value

For any further queries, please send mail to psrdotcom@gmail.com

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.

August 27, 2010

Formatting table automatically in excel using macro and/or Visualbasic Editor

How to use macros in MicroSoft Excel 2007?

Follow these steps
  1. We need to enable Developer Toolbar with the following steps
    • Click the Office Button
    • Click Excel Options
    • Click Popular, select "Show Developer tab in the Ribbon" Checkbox
    Note: For reference you can use this link http://office.microsoft.com/en-us/excel-help/show-the-developer-tab-or-run-in-developer-mode-HA010173052.aspx  
  2. Edit Macro settings in Excel by doing the following steps
    • On the Developer tab, in the Code group, click Macro Security
      Note: If the Developer tab is not displayed, do step 1
    • In the Macro Settings category, under Macro Settings, click the option Disable all macros with Notification 
    Note: For reference you can use this link http://office.microsoft.com/en-us/excel-help/change-macro-security-settings-in-excel-HP010096919.aspx 
  3. Save the excel workbook
  4. Select Developer Ribbon Tab and Click on Visual Basic
  5. Microsoft Visual Basic Editor will be opened
  6. Click on Insert menu and then click on Module
  7. Copy and paste the following code
  8. Enter your data as a table format
  9. Select Developer Ribbon Tab and Click on Macros
  10. Now you can see one macro with the name Table_xls_Format
  11. Click on Run
  12. See the data now. It will be in table format with proper header and data alignment
  13. You can change the macro code by clicking edit button in macro window.
Macro Code:

Sub Table_Xls_Format()
    

    'Selecting Header Row
    Dim header_row As Range
    Set header_row = Range("a1", Range("a1").End(xlToRight))
  
    header_row.Select
  
    'Heading Bold, Aqua Color
    header_row.Font.Bold = True
    header_row.HorizontalAlignment = xlCenter
    header_row.Font.ColorIndex = 42
    header_row.Font.Italic = False
    header_row.Font.Underline = False
  
    'Selecting data

    Dim total_data As Range
    Set total_data = Range("A1").CurrentRegion
  
    total_data.Select
    

    total_data.Font.Bold = False
    total_data.Font.Italic = False
    total_data.Font.Underline = False
  
    'Font:Couriernew , 10
    total_data.Font.Name = "Courier New"
    total_data.Font.Size = 10
  
    'Full Border
    total_data.Borders.LineStyle = 1
  
    'Autofit Column Width
    Selection.Columns.AutoFit
  
    'Autosave the workbook
    ActiveWorkbook.Saved = True

End Sub

Featured Post

Java Introdcution

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