OWASP

HTTP Strict Transport Security(HSTS):

  • HSTS browser header tell browser to load a site only in secure(HTTPS) scheme.
  • It is based on Trust On First Request(TOFU) paradigm
  • 1st request:
    • HTTP Status: 301 with Location header.
    • Response will set header: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
  • 2nd request
    • HTTP Status: 307 Internal redirect with Location header.
    • Response will set header: Non-Authoritative-Reason: HSTS
  • Max-age:
    • declares the period for which insecure requests cannot be made.
    • period is in seconds.
    • 31536000 seconds is equal to 1 year.
    • Sliding expiration.
  • includeSubdomains
    • The scope of HSTS can be extended to all sub domains.
    • This is required for the preload attribute
  • Tools:
    • chrome://net-internals/#hsts : Use this page to manually set HSTS header in chrome.
    • https://hstspreload.org/ : You can preload HSTS so that it is baked in the browser itself by registering at this site. This eliminates TOFU weakness.

HTTP Public Key Pinning(HPKP):

  • Rouge certificate
  • Allows trusted certificates to be white listed
  • Response will set header:
    Public-Key-Pins: pin-sha256=[pin 1];pin-sha256=[pin 2] max-age=2592000; report-url=[url]; includeSubdomains

CSP Header

  • Click jacking

Content-Security-Policy:
script-src ‘self’ ‘unsafe-inline’ ‘unsafe-eval’[uris];style-src ‘self’ ‘unsafe-inline’[uris];img-src ‘self’[uris];font-src ‘self’[uris];report-url[uri]

Unix-Commands

  • pwd: Print Working Directory

  • clear: clear the screen

  • ls -ltr: list

  • diff: show difference between files

    1
    $diff httpd.conf httpd.conf.bkup
  • mkdir: make directory

-touch: update the timestamp. It creates the file if not already existing.

  • cd: change to home directory

  • cd\: change to root directory

  • df: find disk usage

    1
    $ df -h

ApacheWebServer

Apache on-line documentation:

How to strip comments from httpd.conf

1
$ cat httpd.conf | grep -v '^$\|^#' >> httpd-nocomments.conf

How to enable SSL

  • Good Youtube video explanation: https://www.youtube.com/watch?v=YR6-6XUC3sY&t=1672s#t=1126.767257
  • Install mod_ssl.so module
  • Your SSL configuration(/*/conf.d/ssl.conf) will need to contain, at minimum, the following directives.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    LoadModule ssl_module modules/mod_ssl.so
    Listen 443
    <VirtualHost *:443>
    ServerName www.example.com
    SSLEngine on
    SSLCertificateFile "/path/to/www.example.com.cert"
    SSLCertificateKeyFile "/path/to/www.example.com.key"
    </VirtualHost>

Git

  • Distributed Version Control(DVCS) e.g. Git, Mercurial(Hg), BitKeeper, Bazaar.
  • Linus Torvalds created Linux and Git.
  • Msysgit is good git version for Windows.
  • Every object in Git has unique SHA1 key

Porcelain Commands:

  • Add
  • Commit
  • Push
  • Fetch
  • Pull
  • Branch
  • Checkout
  • Merge
  • Rebase

Plumbing Commands:

  • Cat-file
  • Hash-object
  • Count-objects

Install git on Linux system:

  • Debian/Ubuntu distro: apt-get install git-core
  • Fedora distro: yum install git-core

Git version command:

1
2
$ git --version
git version 2.11.1.windows.1

Get help command:

1
$ git --help

Git areas(Mnemonic WIRES)

  • Working-Area
  • Index-Area
  • Repository-Area (Local m/c)
  • External-Repository-Area ( Remote m/c)
  • Stash-Area

Pointers:

  • HEAD: Pointer to a pointer. Points to current branch.
  • Master: Pointer to default local branch.
  • Origin: Pointer to default remote branch.
  • Stash: Pointer to stashed content.
  • BranchName: Pointer to branchName SHA1 hash.

.gitignore

1
/log/*.log

Git hash-object command:

1
2
$ echo "Apple Pie"|git hash-object --stdin
23991897e13e47ed0adb91a0082c31c82fe0cbe5

Git init command:

  • Initiates a Git repository
  • Adds a .Git folder.
  • You will only find one instance of .git directory per repository. It is not repeated in sub directories similar to SVN.
    1
    2
    $ git init
    Initialized empty Git repository in C:/Users/unshakeable/MyGit/.git/

Git hash-object Command with -w flag:

1
2
$ echo "Apple Pie"|git hash-object --stdin -w
23991897e13e47ed0adb91a0082c31c82fe0cbe5

GitHash

  • MyGit>.git>objects directory stores all Git objects
  • You can ignore info and pack directories

Git cat-file command with -t flag:

  • Use cat-file to check the value stored in Hash-map against the SHA1 key
  • “t flag” is used to display type.
    1
    2
    $ git cat-file 23991897e13e47ed0adb91a0082c31c82fe0cbe5 -t
    blob

Git cat-file command with -p flag:

  • “p flag” is used for pretty printing
    1
    2
    $ git cat-file 23991897e13e47ed0adb91a0082c31c82fe0cbe5 -p
    Apple Pie

Sample Folder/File structure:

  • Create “cookbook” directory with below structure:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    $ tree
    .
    |-- .git
    |-- menu.txt
    `-- recipes
    |-- README.txt
    `-- apple_pie.txt
    1 directory, 3 files

Git status command:

1
2
3
4
5
6
7
8
9
10
11
12
$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
menu.txt
recipes/
nothing added to commit but untracked files present (use "git add" to track)

Git log command:

1
2
3
4
$ git log
:q to quit log output, Ctrl+F, Ctrl+b
$ git log --oneline
$ git log --oneline | wc -l
  • Most commonly used:git god
    1
    $ git log --graph --oneline --decorate --all

Git shortlog command:

1
2
$ git shortlog
$ git shortlog -sne

Git add command:

  • used to stage a file i.e move from Working-Area to Index-Area.

  • Add all new files and modified files to staging area:

    1
    $ git add .
  • Add new file to staging area:

    1
    $ git add -u
  • Add all files to staging area:

    1
    $ git add -A
  • Add all html files to staging area:

    1
    $ git add *.html

Git rm –cached command:

  • Used to unstage a file i.e deletes the file from Index-Area region only.

    1
    2
    $ git rm --cached menu.txt
    rm 'menu.txt'
  • Deleting file from both Index-Area and Working-Area. Warning will be displayed

    1
    $ git rm <fileName>
  • Force delete file from both Index-Area and Working-Area

    1
    $ git rm f

Git clean

1
2
$ git clean -n
$ git clean -f

Git checkout command:

  • Used to move a file from Index-Area to Working-Area.
  • Changes in Working-Area will be overwritten.
    1
    $ git checkout -- menu.txt

Git Configuration:

Git configuration can be stored at 3 places. Git config is hierarchical in nature. Below is the order of hierarchy:

  • System-level configuration(Rarely used): git config –system [config file is stored at C:\Program Files\Git\etc\gitconfig]
  • User-level git configuration: git config –global [config file is stored at C:\Users\helloGuy.gitconfig]
  • Repository-level git configuration: git config [config file is stored at C:\Users\helloGuy\Code.git\config]

Common user-level git configuration:

  • Add user.name to global git config:

    1
    $ git config --global user.name "helloGuy"
  • Add user.email to global git config:

    1
    $ git config --global user.email "hello.world@gmail.com"
  • Add help.autocorrect to global git config:

    1
    $ git config --global help.autocorrect 1
  • Add color attributes to global git config:

    1
    2
    3
    $ git config --global color.ui auto
    $ git config --global color.status auto
    $ git config --global color.branch auto
  • Add core.autocrlf to global git config:

    1
    $ git config --global core.autocrlf true
  • Add branch.autosetuprebase to global git config:

    1
    $ git config --global branch.autosetuprebase always
  • Add default diff algorithm

    1
    2
    $ git config --global diff.algorithm histogram
    $ git config --global diff.algorithm patience
  • Add alias for commonly used commands:

    1
    $ git config --global alias.god "log --graph --oneline --decorate --all"
  • Configure Beyond Compare as diff-tool:

    1
    2
    $ git config --global diff.tool bc3
    $ git config --global difftool.bc3.path "c:/Program Files/Beyond Compare 4/bcomp.exe"
  • Configure Beyond Compare as merge-tool:

    1
    2
    $ git config --global merge.tool=bc3
    $ git config --global mergetool.bc3.path=c:/Program Files/Beyond Compare 4/bcomp.exe
  • Show all global git config:

    1
    2
    3
    4
    5
    6
    7
    $ git config --global --list
    user.name=helloGuy
    user.email=hello.world@gmail.com
    core.editor=notepad++
    core.autocrlf=true
    help.autocorrect=1
    color.ui=auto
  • Remove user.name from repository git config:

    1
    $ git config --unset user.name
  • Show all repository level git config: This will list all config properties from all 3 scopes.

    1
    $ git config --list

Git commit command:

  • What is a commit?
    • SHA1 to a tree
    • Author name
    • Commit date
    • Commit message
    • Parent: used for versioning
1
2
3
4
5
6
$ git commit -m "my first commit"
[master (root-commit) 2bde229] my first commit
3 files changed, 3 insertions(+)
create mode 100644 menu.txt
create mode 100644 recipes/README.txt
create mode 100644 recipes/apple_pie.txt

Git Object Modal
Git Object Modal

Git object model: Structure of the initial commit

1
2
3
4
5
6
7
8
9
$ git cat-file 2bde2295ed4b1d2eefaa0486cf098d8669621a50 -t
commit
$ git cat-file 2bde2295ed4b1d2eefaa0486cf098d8669621a50 -p
tree be4d5bfce489a2591e7fed5c672f9e52cd695a43
author Unshakeable <unshakeable@gmail.com> 1487695379 -0500
committer Unshakeable <unshakeable@gmail.com> 1487695379 -0500
my first commit

Git object model: Structure of subsequent commits(versioning)

  • From 2nd commit onwards, you have additional “parent” field, which points to previous commit.
1
2
3
4
5
6
7
8
9
10
$ git cat-file f2b32d8d5f262f035e0090c7b7d2161f2ff26f45 -t
commit
$ git cat-file f2b32d8d5f262f035e0090c7b7d2161f2ff26f45 -p
tree 4e100b23f2cf34b2931f8131aa8219a3419d6d60
parent 2bde2295ed4b1d2eefaa0486cf098d8669621a50
author Unshakeable <unshakeable@gmail.com> 1487704250 -0500
committer Unshakeable <unshakeable@gmail.com> 1487704250 -0500
my second commit

Git object model: Structure of tree

  • Tree object can point to files and other trees
    1
    2
    3
    4
    5
    6
    $ git cat-file be4d5bfce489a2591e7fed5c672f9e52cd695a43 -t
    tree
    $ git cat-file be4d5bfce489a2591e7fed5c672f9e52cd695a43 -p
    100644 blob 23991897e13e47ed0adb91a0082c31c82fe0cbe5 menu.txt
    040000 tree 3ee76fde69b730530f1682f1f51789e89cf30500 recipes

Git object model: Structure of blob

  • File name is not stored in blob, but in the tree pointing to it.
    1
    2
    3
    4
    5
    $ git cat-file 23991897e13e47ed0adb91a0082c31c82fe0cbe5 -t
    blob
    $ git cat-file 23991897e13e47ed0adb91a0082c31c82fe0cbe5 -p
    Apple Pie

Git count-objects command:

1
2
$ git count-objects
8 objects, 0 kilobytes

Git Tags:

  • Tags are like labels/references.
  • A tag is like a branch that doesn’t move.
  • Git has two type of Tags.
    • Regular or lightweight tags
    • Annotated tags

Annotated tags: comes with message

1
$ git tag -a myTag -m "I love tags"

Lightweight/Regular tag:

1
$ git tag myLightTag

Get list of Git tags:

1
2
3
$ git tag
myTag
myLightTag

Git object model: Structure of Tag

1
2
3
4
5
6
7
8
9
10
$ git cat-file myTag -t
tag
$ git cat-file myTag -p
object f2b32d8d5f262f035e0090c7b7d2161f2ff26f45
type commit
tag myTag
tagger Unshakeable <unshakeable@gmail.com> 1487705105 -0500
I love tags

Stash: is useful when we have uncommitted changes and need to switch branch.

$ git stash
$ git stash apply
$ git stash list
$ git stash clear
$ git stash pop
$ git stash drop

Git branch:

  • Git creates the default branch(master) on first commit.
  • Current branch will be marked with asterisk.
  • Branch is just a reference to a commit.

Command to list all branches:

1
2
3
$ git branch
$ git branch -r
* master

Structure of Master branch:

  • Git Master branch reference is stored in .git/refs/heads directory
    1
    2
    $ cat .git/refs/heads/master
    f2b32d8d5f262f035e0090c7b7d2161f2ff26f45

Command to create new branch:

1
2
3
4
5
6
7
8
9
10
11
$ git branch decRelease
$ git branch
decRelease
* master
$ cat .git/refs/heads/decRelease
f2b32d8d5f262f035e0090c7b7d2161f2ff26f45
$ cat .git/refs/heads/master
f2b32d8d5f262f035e0090c7b7d2161f2ff26f45
1
$ git branch --set -upstream master origin/master

Command to delete a branch

1
git branch -D <BranchName>
  • HEAD is just a reference to a branch.
  • So it is kind of pointer to a pointer.
1
2
$ cat .git/HEAD
ref: refs/heads/master

How to switch to other branch: checkout

As part of checkout following two actions happens:

  • HEAD reference moves to decRelease
  • Content of decRelease is downloaded to Working-Area and Index-Area.
    1
    2
    $ git checkout decRelease
    Switched to branch 'decRelease'

Git diff command:

  • Find difference between Working-Area and Index-Area:

    1
    $ git diff
  • Find difference between Index-Area and Repository-Area:

    1
    $ git diff --cached
  • Find difference between two commits:

    1
    $ git diff hash1..hash2
  • Find difference between current commit and previous commit:

    1
    $ git diff head~1..head
1
$ git diff head~3:Readme.txt..head:Readme.txt
1
$ git diff --histogram

Git reset command:

  • It moves the head to specified location and updated area contents based on flags.

  • Hard reset: Sets the HEAD to corresponding location and updates both Working-Area and Index-Area.

    1
    $ git reset --hard <branchName>
  • Mixed reset(default): Sets the HEAD to corresponding location and updates just the Index-Area.

    1
    $ git reset --mixed <branchName>
  • Soft reset: Just sets the HEAD to corresponding location. Does not update content of any area.

    1
    $ git reset --soft head~1

Gitk: git UI tool

1
$ gitk

Merge command:

  • You are on master branch and want to merge with decRelease branch

    1
    $ git merge decRelease
  • In case of merge conflict git will place markers in the corresponding file, which need to be removed manually in Working-Area.

  • Use ADD to stage your merged files
  • Use Commit to check-in the merged files. This is a special commit and it will have two PARENT tags in it.
  • For complex merge conflicts its better to configure and use merger tool e.g. WinMerge, tourtoiseMerge

Fast-forward:

  • Generally, after merge it make sense to do merge in other direction as well

Detached Head:

  • Use git checkout command with SHA1 to move head to a particular SHA1.
  • Use normal commit to create subsequent commit points and move HEAD.
  • At any point you can switch to master to move HEAD back to it and abandon new commits. As no pointer is pointing at newly created SHA1 references, they will be garbaged collected
  • If you want to preserve them just create a Branch

Git fsck command:

  • find dangling and unreachable commits
    1
    2
    $ git fsck --dangling --no-progress
    $ git fsck --unreachable --no-progress

Clone command:

  • Copy entire .git folder from remote.
  • Clone only copy the master branch to Working-Area.
  • This operation makes a entry in git config about the remote repository.
    1
    2
    3
    $ git clone https://github.com/unshakeable
    $ git clone https://github.com/unshakeable .
    $ git clone https://github.com/jquery/jquery.git

Display all branches after cloning:

1
$ git branch --all

Git Remote command:

1
2
3
4
5
6
7
8
$ git remote
$ git remote -v
$ git remote add MyRemoteRepo http://github.com/helloGuy
$ git remote add origin https://github.com/unshakeable.git
$ git remote rm origin

Git show-ref command:

1
2
$ git show-ref master
e25f61694ed34b220148a63cb0e7aefa5917c12c refs/heads/master

Git show command:

1
$ git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277

Git push command:

  • Push local commits to remote repo defined in git config
    1
    2
    3
    $ git push
    Username for https://github.com':
    Password for https://github.com':
1
git push --set-upstream origin master
1
$ git push origin master

Git fetch command:

  • Fetch> Merge> Push cycle
    1
    2
    $ git fetch
    $ git fetch origin

Git pull command:

  • git pull is equivalent to FETCH followed by MERGE.
    1
    $ git pull

Fork:

  • Remote clone

Ant

  • Apache Ant is a Java library and command-line tool that help building software.
  • Ant is open source
  • ANT: Another Neat Tool
  • http://ant.apache.org

Ant Tasks

Ant version

1
2
c:\antDemo>ant -version
Apache Ant(TM) version 1.10.1 compiled on February 2 2017

Structure of build file:

  • build.xml is the default ant script file.
  • Project is the root tag.
  • Project consist of many targets.
  • Targets have ant tasks.

Running ant build:

  • If you just run ant command, by default ant will look for a file name build.xml in current directory.

    1
    c:\antDemo>ant
  • Explicitly provide a build file using flag:-buildfile

    1
    c:\antDemo>ant -buildfile build2.xml

Project tag and default attribute:

1
2
3
4
5
6
<?xml version="1.0" ?>
<project name="FirstTest" default="hello">
<target name="hello">
<echo message="hello world" />
</target>
</project>

depends attribute for target chaining:

1
2
3
4
5
6
7
8
9
<?xml version="1.0" ?>
<project name="FirstTest" default="world">
<target name="hello">
<echo message="hello" />
</target>
<target name="world" depends="hello">
<echo message="world" />
</target>
</project>

Emmet

  • Emmet is a HTML/CSS snippet tool.
  • Emmet plugin is available for most editors.
  • Emmet follows CSS syntax
  • Emmet is Open Source
  • Similar tools: Jade, Haml
  • Homepage: http://emmet.io/download

Installation

Emmet Commands:

  • Type Emmet command, followed by Tab to expand to proper HTML/CSS.
  • Use Tab to jump to various tab location in expanded HTML/CSS.
  • Use Ctrl+Z to undo Emmet command expansion.
  • All default Emmet commands are present inside snippet.json at “C:\Program Files (x86)\Notepad++\plugins\EmmetNPP\emmet\snippets.json”

HTML page template command:

  • HTML:5
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    </head>
    <body>
    </body>
    </html>

ID command:”#”

  • h1#myId
    1
    <h1 id="myId"></h1>

Class command:”.”

  • h1.myClass
    1
    <h1 class="myClass"></h1>

Multiple Class command:”.” chaining

  • h1.myclass1.myclass2
    1
    - <h1 class="myclass1 myclass2"></h1>

Parent/Child command:”>”

  • ul>li
    1
    2
    3
    <ul>
    <li></li>
    </ul>

Sibling command:”+”

  • li+li
    1
    2
    <li></li>
    <li></li>

Parent/Child and Sibling combo command:

  • ul>li+li
    1
    2
    3
    4
    <ul>
    <li></li>
    <li></li>
    </ul>

DIV is default element: In below command only class name is mentioned, so DIV tag is used as default

  • .header+.main+.footer
    1
    2
    3
    <div class="header"></div>
    <div class="main"></div>
    <div class="footer"></div>

Grouping command:”()”

  • (div.foo+div.bar)
    1
    2
    <div class="foo"></div>
    <div class="bar"></div>

Multiplication command:”*”

  • (div.foo+div.bar)*2
    1
    2
    3
    4
    <div class="foo"></div>
    <div class="bar"></div>
    <div class="foo"></div>
    <div class="bar"></div>

Level-up/Climb-up command:”^”

  • ul>li^div.foo
    1
    2
    3
    4
    <ul>
    <li></li>
    </ul>
    <div class="foo"></div>

Text command:”{}”

  • h1{hello}
    1
    <h1>hello</h1>

Image command:

Lorem Ipsum command:

  • p>Lorem
    1
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Harum, tenetur, vel fuga accusamus velit consectetur quibusdam eligendi maxime unde in expedita et quidem laborum at ex laboriosam minima necessitatibus dicta.</p>

Number placholder commands:

  • Number element with $
  • ul>li*3>{list item $}

    1
    2
    3
    4
    5
    <ul>
    <li>list item 1</li>
    <li>list item 2</li>
    <li>list item 3</li>
    </ul>
  • Use additional $$$ to pad

  • ul>li*3>{list item $$$}

    1
    2
    3
    4
    5
    <ul>
    <li>list item 001</li>
    <li>list item 002</li>
    <li>list item 003</li>
    </ul>
  • Start at a different position with @

  • ul>li*3>{list item $@3}

    1
    2
    3
    4
    5
    <ul>
    <li>list item 3</li>
    <li>list item 4</li>
    <li>list item 5</li>
    </ul>
  • Reverse the order with @-

  • ul>li*3>{list item $@-}
    1
    2
    3
    4
    5
    <ul>
    <li>list item 3</li>
    <li>list item 2</li>
    <li>list item 1</li>
    </ul>

Sample examples

  • .header>h1#title

    1
    2
    3
    <div class="header">
    <h1 id="title"></h1>
    </div>
  • .header>h1#title{Hi there}

    1
    2
    3
    <div class="header">
    <h1 id="title">Hi there</h1>
    </div>
  • #app>.container>h1.title#welcome

    1
    2
    3
    4
    5
    <div id="app">
    <div class="container">
    <h1 class="title" id="welcome"></h1>
    </div>
    </div>

Notepad++ Tips & Tricks

Default location where Notepad++ config is stored:

  • %appdata%\Notepad++
  • Which resolves to c:\users\raj\AppData\Roaming\Notepad++

Regex documentation:

Config files:

  • config.xml
  • contextMenu.xml
  • langs.xml
  • shortcuts.xml
  • styler.xml

Important Plug-ins

  • NppCrypt
  • TextFX
  • DSpellCheck
  • Emmet

Important Shortcuts:

  • Ctrl+F3: Select and Find next
  • Ctrl+F2: Toggle bookmarks
  • F2: Next bookmark
  • Shift+F2: Previous bookmark
  • F7: Open Search result window

Tip - Regex: Prefix all lines with a string

Before:

1
2
google.com
yahoo.com

After:

1
2
http://www.google.com
http://www.yahoo.com

Find and Replace Options:

1
2
3
Find What: ^
Replace with: http://www.
Search Mode: Select Regular expression radio button

Tip - Regex: Suffix all lines with a string

Before:

1
2
www.google
www.yahoo

After:

1
2
www.google.com
www.yahoo.com

Find and Replace Options:

1
2
3
Find What: $
Replace with: http://www.
Search Mode: Select Regular expression radio button

Tip - Replace multiple space around a operator with single space

1
2
Find what: \s*:\s*
Replace with: \x20:\x20

Tip - Regex: Remove all lines with word “hello” in it

1
2
Find what: .*hello.*
Replace with: Nothing

Tip - Regex:

Before:

1
var str = document.getElementById("UserName").value

After:

1
"UserName").value

1
2
Find what: .*getElementById\(
Replace with: ""

Tip - Regex:

Before:

1
"UserName").value

After:

1
"UserName"

1
2
Find what: \).*
Replace with: ""

Tip - Regex with parameter

1
2
Find what: (c:.*)
Replace with: ]\n$1 [

Tip - How to “mark” multiple “words”

  • Open Find dialog from the Search menu:
  • Click on the Mark tab
1
2
3
Find What: (Yahoo|Goku|Candy)
Search Mode: Select Regular expression radio button
Click Mark All

Tip - Line up by Comma, equalSign or clipboard character

  • TextFX > TextFX Edit > line up multiple lines by
    Align

Tip - Box Selection

  • Hold down the Alt key while doing a selection
  • Use can also just use keyboard: Shift+Alt+DownArrow
    Align
    Align

Tip - Multi-Editing(Clrl+Mouse click/selection)

  • Enable Multi-Editing from Settings>Preferences>Editing>Multi-Editing Setting>Check the chekbox
  • Press Ctrl and click at desired places to have multiple cursors appear.
  • Continue typing as normal and typed characters will appear at each of the cursor location.

Tip - How To Insert Incrementing Numbers

  • Use box selection to place cursor in front of multiple lines.
  • Edit>Column Editor…>Number to Insert>Fill desired values

Before:

1
2
3
aaa
bbb
ccc

After:

1
2
3
1aaa
2bbb
3ccc

How to find Nth character in Notepad++

  • Press Ctrl+G and choose offset. Enter N.

Todo

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

FirstNameA LastnameB
FirstNameA LastnameB
FirstNameA LastnameB

[0-9](.)

\1

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

FirstNameA LastnameB, 1
FirstNameA LastnameB, 100
FirstNameA LastnameB, 1000

([0-9]) (.)

\2, \1

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

LastnameB, FirstNameA
LastnameB, FirstNameA
LastnameB, FirstNameA
[0-9] ([a-zA-Z]) ([a-zA-Z]*)

\2, \1

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

LastnameB, FirstNameA
LastnameB, FirstNameA
LastnameB, FirstNameA

[0-9] ([^ ]) (.*)

\2, \1

(.) - (.)
\1. \1. - \2

How to setup Hexo for blogging

  • Install Node and npm for windows.

    1
    2
    3
    4
    5
    C:\Users\unshakeable>node -v
    v6.9.5
    C:\Users\unshakeable>npm -v
    3.10.10
  • Install hexo-cli

    1
    C:\Users\unshakeable>npm install hexo-cli -g
  • Check if hexo-cli is installed properly

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    C:\Users\unshakeable>hexo -v
    hexo-cli: 1.0.2
    os: Windows_NT 6.1.7601 win32 x64
    http_parser: 2.7.0
    node: 6.9.5
    v8: 5.1.281.89
    uv: 1.9.1
    zlib: 1.2.8
    ares: 1.10.1-DEV
    icu: 57.1
    modules: 48
    openssl: 1.0.2k
  • Create “My Blog” directory and CD to it and initiate blog:

    1
    2
    3
    C:\Users\unshakeable>mkdir "My Blog"
    C:\Users\unshakeable>cd "My Blog"
    C:\Users\unshakeable\My Blog>hexo init
  • Start Hexo server

    1
    C:\Users\unshakeable>hexo server
  • Check Hexo default blog page

    1
    http://localhost:4000/
  • Create new post

    1
    C:\Users\unshakeable>hexo new post <post-title>
  • Publish blog

    1
    C:\Users\unshakeable>hexo generate
  • A public folder will be generated with static site.

  • Publish this folder to github.io

Important directories and files:

  • Templates for draft, page & post:

    1
    2
    3
    4
    C:\Users\unshakeable\My Blog>\scaffolds
    - draft.md
    - page.md
    - post.md
  • User posts directory:

    1
    2
    C:\Users\unshakeable\My Blog>\source\_posts
    - hello-world.md
  • Main config file for Hexo blog:

    1
    2
    C:\Users\unshakeable\My Blog>\
    - _config.yml
  • Node modules for Hexo:

    1
    C:\Users\unshakeable\My Blog>\node_modules
  • Default theme for Hexo:

    1
    C:\Users\unshakeable\My Blog>\themes\landscape

Customization

  • Update Banner photo
    “C:\Users\unshakeable\My Blog\themes\landscape\source\css\images\banner.jpg”

  • Update background-size from “cover” to “55%”
    C:\Users\unshakeable\My Blog\themes\landscape\source\css_partial\header.styl

  • Update blog’s main config file: C:\Users\unshakeable\My Blog>_config.yml

    1
    2
    3
    4
    5
    6
    7
    # Site
    title: Unshakeable
    subtitle: Life Lessons
    description:
    author: Mr. Unshakeable
    language: English
    timezone: EST