Thursday, February 16, 2017

Advanced Excel Functions

Using advanced Excel functions save time.


How to set up a function (where its code was obtained from elsewhere) in Excel

1. Copy the function code

2. Open the excel workbook

3. Open Visual Basic Editor (Alt+F11)

4. VBE: Insert > Module > Paste code into "Book1-Module1(Code)" window

Note the name of the function, i.e. If the 1st line is like this:

Function fnConvert2HTML(myCell As Range) As String

Then the name of the function is

fnConvert2HTML

5. Excel: choose a target cell and enter the formula with function and range of cells. In the example above, this would be:

=fnConvert2HTML(A1:B2)

where A1:B2 is the selected range of cells to apply the function to.


Useful Excel functions

This function converts formatted text (say in cell C1) to HTML (say in cell C2). So, in cell C2, enter this "=fnConvert2HTML(C1)", and voila.

Function fnConvert2HTML(myCell As Range) As String
    Dim bldTagOn, itlTagOn, ulnTagOn, colTagOn As Boolean
    Dim i, chrCount As Integer
    Dim chrCol, chrLastCol, htmlTxt, htmlEnd As String

    bldTagOn = False
    itlTagOn = False
    ulnTagOn = False
    colTagOn = False
    chrCol = "NONE"
    'htmlTxt = "<html>"
    htmlTxt = ""
    chrCount = myCell.Characters.Count

    For i = 1 To chrCount
    htmlEnd = ""
        With myCell.Characters(i, 1)
            If (.Font.Color) Then
                chrCol = fnGetCol(.Font.Color)
                If Not colTagOn Then
                    htmlTxt = htmlTxt & "<font color=#" & chrCol & ">"
                    colTagOn = True
                Else
                    If chrCol <> chrLastCol Then htmlTxt = htmlTxt & "</font><font color=#" & chrCol & ">"
                End If
            Else
                chrCol = "NONE"
                If colTagOn Then
                    htmlEnd = "</font>" & htmlEnd
                    'htmlTxt = htmlTxt & "</font>"
                    colTagOn = False
                End If
            End If
            chrLastCol = chrCol

            If .Font.Bold = True Then
                If Not bldTagOn Then
                    htmlTxt = htmlTxt & "<b>"
                    bldTagOn = True
                End If
            Else
                If bldTagOn Then
                    'htmlTxt = htmlTxt & "</b>"
                    htmlEnd = "</b>" & htmlEnd
                    bldTagOn = False
                End If
            End If

            If .Font.Italic = True Then
                If Not itlTagOn Then
                    htmlTxt = htmlTxt & "<i>"
                    itlTagOn = True
                End If
            Else
                If itlTagOn Then
                    'htmlTxt = htmlTxt & "</i>"
                    htmlEnd = "</i>" & htmlEnd
                    itlTagOn = False
                End If
            End If

            If .Font.Underline > 0 Then
                If Not ulnTagOn Then
                    htmlTxt = htmlTxt & "<u>"
                    ulnTagOn = True
                End If
            Else
                If ulnTagOn Then
                    'htmlTxt = htmlTxt & "</u>"
                    htmlEnd = "</u>" & htmlEnd
                    ulnTagOn = False
                End If
            End If

            If (Asc(.Text) = 10) Then
                htmlTxt = htmlTxt & htmlEnd & "<br>"
            Else
                htmlTxt = htmlTxt & htmlEnd & .Text
            End If

        End With
    Next

    If colTagOn Then
        htmlTxt = htmlTxt & "</font>"
        colTagOn = False
    End If
    If bldTagOn Then
        htmlTxt = htmlTxt & "</b>"
        bldTagOn = False
    End If
    If itlTagOn Then
        htmlTxt = htmlTxt & "</i>"
        itlTagOn = False
    End If
    If ulnTagOn Then
        htmlTxt = htmlTxt & "</u>"
        ulnTagOn = False
    End If
    'htmlTxt = htmlTxt & "</html>"
    fnConvert2HTML = htmlTxt
End Function

Function fnGetCol(strCol As String) As String
    Dim rVal, gVal, bVal As String
    strCol = Right("000000" & Hex(strCol), 6)
    bVal = Left(strCol, 2)
    gVal = Mid(strCol, 3, 2)
    rVal = Right(strCol, 2)
    fnGetCol = rVal & gVal & bVal
End Function


Credit http://stackoverflow.com/a/33796622

Tip: To remove rows containing a formula without causing the spreadsheet to hang, delete the cell containing the formula (in that row), then delete the row.

MORE RESOURCES

Nice resource
https://zapier.com/blog/excel-macros/

Macro code: Convert text in Active Cell to HTML (i.e. bold, underline, italics only)
https://www.experts-exchange.com/viewCodeSnippet.jsp?codeSnippetId=482042

Macro code: Converts complex text formats into HTML (need to purchase)
https://officetricks.com/convert-formatted-cell-excel-html-tag-vba/

How to crack passwords for Excel VBA Project (to view macro codes which have been pwd-protected)
http://stackoverflow.com/questions/1026483/is-there-a-way-to-crack-the-password-on-an-excel-vba-project

Sunday, February 12, 2017

GIMP

GIMP

Change background to transparent
1. Layer > Transparency > Color to Alpha
2. From: (Click the Color box), then use eyedropper to select the colour u wish to make transparent.

Transform image (or Ctrl+G)
1. Tools > Toolbox
2. Select "Cage Transform"
3. Click on points around your image to surround it and complete the perimeter.
4. Drag and release the points to transform the image within

Text with outline
Method 1
1. Right-click on your layer containing text, then select "Alpha to Selection"
2. Select > Grow > 10px
3. Layer > New Layer > BucketFill black into the selected grown area
4. Drag the grown layer beneath the text layer
Method2
1. Write the text in the desired, font, size, colour
2. Set primary colour to the desired outline colour
3. Select by Colour tool (Shift+O), then click on the text
4. Edit > Stroke Selection > Line width: 1px > Stroke


Draw
1. Select "rectangle select tool" or "ellipse select tool"
2. Drag as required on your image
3. Edit > Fill with FG colour (Ctrl+,)


Copy an image1 and paste to another image2
1. Select all image1, then copy (Ctrl+C)
2. Go to image2, then paste (Ctrl+V)
3. You will see a new layer called "Floating Selection (Pasted Layer)" > Right-click on it then select "To New Layer"

Resize a particular layer
1. Select that layer
2. Toolbox > ScaleTool

Move an image around
1. Select that layer
2. Toolbox > Move Tool > ensure u click on the image to drag it (clicking on transparent area won't work)

Adjust layer size (rather than adjust the entire canvas)
Layer > Layer boundary size > Center

Fill all same colours with another colour where images are not contiguous
1. Select > By Colour > click on specific colour
2. Double-click on "Bucket Fill"
- select "FG color fill" (ensure you've set FG with your desired destination colour)
- select "Fill whole selection"
3. Click on an area which was selected earlier, and the entire image should change to your destination colour


How to distress an image in Gimp
Note: Ur PC will work faster with smaller images, so we shrink them, distress them, then expand them later.

Prepare distress layer
1. Open > textured image (google "crumpled paper", "rough texture", etc)
2. Image > Mode > Grayscale
3. Colors > Curves > make S-curve until all colours remain black and white only > OK
4. File > Export > save as png/jpg

Apply distress layer to design layer
1. Open > design layer
2. Shrink image size so that PC works faster:
Image > Scale Image > width to under 1000px > Scale
3. File > Open as layer > select distress layer which was prepared earlier
4. With distress layer selected:
- Scale Tool or Rotate Tool or Move Tool > adjust to fit design layer > OK
- Fuzzy Select Tool > click white area on distress layer > delete (this deletes white area, leaving distress markings)
- Select > Invert (this selects distress markings)
- click on Design Layer > Delete (this deletes areas overlapped by distress markings on the Design Layer)
- Hide (click the "eye") the Distress Layer;
- Select > None

Restore design layer to original size
- Image > Scale Image > width to original width > Scale

Save Image
- Export > save as png

Adjust opacity of fonts (useful for creating transparent watermarks)
- Ctrl+L

Vectorise a regular image
http://imgur.com/gallery/xL0Ba

How to do drop shadows (text, image, etc)
1. Select the layer containing the text/image/etc
2. Filter > Light and Shadow > Drop Shadow

How to warp an object within an image with GIMP
1. Select "Cage Transform" (Shift+G). Tool Options will show "Create or adjust the cage" chosen.
2. Click around the object to make a complete circle. Allow some space around the object.
3. Once a complete circle is made, the Tool Options will show "Deform the cage to deform the image" chosen.
4. Drag the nodes to warp the object as desired. Doubleclick on the circle to introduce extra nodes if needed. PRESS ENTER TO CONFIRM THE TRANSFORMATION.
5. You'll see remaining artifacts of the original image. To remove the artifacts: Select Free Select Tool (or click "F"). Draw a shape around the object, clicking in the spaces BETWEEN the artifact and the warped object.
6. Enlarge the image to cover the artifacts: Use the Scale Tool (Shift+T). Ensure u cover all artifacts. Then click the "Scale" button to confirm. What's remaining will be the small areas directly adjacent to AND surrounding the warped object (let's call it "Remnants").
7. Anchor the layer that contains the warped object (ensure the layer (called "Floating Selection (Transformation) is selected, then click the "Anchor" button.
8. To get rid of the Remnants: ensure the topmost layer (containing the warped object) is selected. Rightclick, then select "Add Alpha channel".
9. Select Eraser Tool (Shift+E). Select a soft brush (e.g. Brush "2. Hardness 050"). Then go to the image and start erasing the Remnants (on the top layer) to reveal the original background (on the bottom layer).
Source https://www.youtube.com/watch?v=jL8TepHX0qE

How to create round watercolour splash
1. File > New > Advanced Options> Fill with (Transparency)
2. Airbrush Tool (press "A").
3. Select one of these from Tool Options, e.g.: "Sponge 01", "Splats 01", "Texture Hose 03"
4. Click for few seconds and move cursor around to achieve desired effect.

How to create vignette
1. Image at bottom. Insert new layer on top (vignette layer).
Note: Be prepared to redo steps 2-4 as many times as necessary to achieve desired vignette area
2. Use "Ellipse Select Tool" (E), draw border of vignette (if redoing, draw a smaller circle)
3. Feather the donut: Select > Invert (Ctrl+I), then: Select > Feather > 100px (if redoing, raise the px)
4. Insert vignette colour: Bucket tool > select vignette colour > click on vignette area (donut)
5. If vignette effect was unsatisfactory, UNDO steps 4,3,2 and redo.

How to convert a photo/vector to pixel art 
https://www.youtube.com/watch?v=f5cVMqk-OB0 https://www.youtube.com/watch?v=XUkH6UoyfZQ
1. Open photo in GIMP 
2. Reduce colors of photo: Colors > Posterize > select a low number (e.g. 4) to group colors into fewer colors > OK
3. Crop area of interest: "Free select tool" > trace a complete area around object of interest > delete inverse of selected area
4. Shrink image: Image > Scale image > change to smaller width & height (e.g. 50px x 60px, 100px x 169px) > Scale > Zoom (Ctrl+plus) to see image become pixelated. IMPORTANT: the smaller the new width & height, the bigger the pixels
5. Crop to selection (delete unwanted outer areas surrounding object of interest)
6. Reduce colors further: "Select by Color Tool" > (adjust THRESHOLD slider if necessary in Tool options) > click on a pixel (a group of pixels with similar shades will be selected) > select desired color > select "Paintbrush tool" and paint over all selected areas
7. Enlarge image and maintain crisp edges of pixels: Image > Scale image > change to larger width & heigh (e.g. 500px x 600px) > Quality(interpolation: NONE) > Scale
8. Export as png

Wednesday, February 8, 2017

Speech Analysis

Strategies to become a more persuasive and engaging speaker


  • Alliteration
    • repeating a phrase or group of words
    • adds lyricism to your language
    • makes your phrases more vivid and easier for audience to grasp
  • Amplification
    • arrange words or ideas in order of increasing force or importance
    • oftens uses a list, or repeating key terms while building to a climax
    • creates an emotional response in the audience
  • Analogy
    • compares 2 things using "like" or "as"
    • provides a simple explanation for a more complicated idea
    • delivers a vivid image to fully capture audience's imagination
    • a well-timed analogy adds depth to your speech as it helps audience understand your central points
  • Anamnesis
    • recollection of the past
    • can be used effectively to emphasize commonalities between speaker and audience
    • demonstrates a speaker's mastery of a subject
    • forms a part of a larger appeal to ethos, or the character and authority of the speaker
    • Example:
  • Anaphora
    • same word or phrase begins sentences or clauses that appear close to one another
    • adds emphasis to the repeated idea
    • creates a pleasing rhythmic effect
    • often used at beginnings and endings of speeches, making the speech more powerful and memorable
    • Example:
  • Antithesis
    • occurs when two ideas are placed in opposition to one another
    • uses a parallel structure to create contrast
    • Since ideas are easier to grasp when we understand their opposites, antithesis is a useful rhetorical device to convey arguments so they are approachable and easy to remember
    • Example:
  • Appeal to Ethos
    • What: an appeal to the speaker's authority and trustworthiness (ethos means character)
    • How: ethos can be established prior to a speech by a speaker's reputation, or established by demonstrating knowledge about a subject
    • Why: earns audience's trust and respect, and therefore results in an effective speech
    • Example:
  • Appeal to Pathos
    • an appeal to audience's emotion and imagination (pathos means experience or suffering)
    • aim is to help audience understand and share in the speaker's own viewpoint
    • works best when the speaker emphasize a shared value between speaker and audience and when paired with logical argument
  • Asyndeton
    • what: intentionally omit a conjunction e.g. "and" from a list, while maintaining the usual grammatical form of the sentence
    • results in the sentence that feels more immediate and dramatic
    • powerful tool to add emphasis at crucial points of a speech
  • Humor
    • keeps audience engage, appear more personable, make an unpopular idea acceptable
    • used inappropriately or too frequently -- is damaging to a speech
    • used sparingly and at right moments-- makes speeches significantly more memorable
    • Example:
  • Inclusive language
    • examples: "we", "our"
    • develop good rapport with audience 
    • shows speaker identifies with audience and has their interests in mind, making speaker appear more trustworthy to them
  • Metaphor
    • using a word or phrase to something to which it does not literally apply
    • can create strong emotional response in audience; or make a difficult idea or argument easier to grasp
  • Parallelism
    • occurs when the speaker uses a similar grammatical structure within a sentence or across multiple sentences (repeating a central element)
    • adds clarity to a speech, makes it easier for audience to grasp a central idea
    • can also add rhythm to a speech, making it more powerful and memorable
    • Example:
  • Repetition
    • important because audience can't pause or return to what you have said
    • state your ideas clearly and return to them often
    • can also be used to highlight specific words and ideas in particular parts of your speech
    • add rhythm to your language as it emphasizes a single idea
  • Rule of Three
    • common and powerful device
    • easy for an audience to grasp and remember items that appear in groups of three, often to dramatic effect
    • use RoT to make sure you focus on your most important points, and to avoid overwhelming the audience with superfluous information
    • Example:

Popular Posts