• JSP (JavaServer Pages)

    11 comments

    JSTL - Core <c:if> Tag

    The <c:if> tag evaluates an expression and displays its body content only if the expression evaluates to true. The <c:if> tag has the following attributes −

    Attribute Description Required Default
    test Condition to evaluate Yes None
    var Name of the variable to store the condition's result No None
    scope Scope of the variable to store the condition's result No Page
    Example
    <c:if test="${condition}">
    </c:if>
    
    <c:choose>
        <c:when test="${condition}">
        </c:when>
        <c:otherwise>
        </c:otherwise>
    </c:choose>
    

    Ref: TutorialsPoint: JSP - https://www.tutorialspoint.com/jsp/jstl_core_if_tag.htm

    Read More
  • Intellij IDEA

    11 comments

    If we want to import a module, but it is not a library, you can associate the project with the main application as follows in IntelliJ IDEA:

    1. Project Structure -> Modules -> Add new Module (+)
    2. Project Structure -> Modules -> Dependencies -> Add Module Dependency
    Read More
  • Linux & Server Administration

    11 comments

    Finding files

    $ grep -rnw '/path/to/somewhere/' -e 'pattern'
    
    • -r or -R is recursive,
    • -n adds line numbers,
    • -w stands for match the whole word,
    • -l (lower-case L) can be added to just give the file name of matching files

    Ref: How do I find all files containing specific text on Linux? - https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux

    Network

    Show ports based on PID of a process

    $ sudo netstat -tulpn | grep ${PID}
    

    Show information about CPU

    $ cat /proc/cpuinfo
    

    Check the connection to the server and open port on a specific remote computer

    $ telnet SERVER_ADDRESS PORT
    

    Connect to a remote server, the best way through the command 'ssh'

    $ ssh USER@SERVER_ADDRESS
    

    Less

    Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement. Useful commands when browsing logs:

    • Waiting for latest lines at EOF - SHIFT + F
    • Finish of waiting at EOF - CTRL + C
    • Search for a specific text - /${TEXT}
    • Leave or finish - Q

    Nano

    GNU nano is a small and friendly text editor. Besides basic text editing, nano offers many extra features like an interactive search and replace, go to line and column number, auto-indentation, feature toggles, internationalization support, and filename tab completion.

    • Search for a specific text - CTRL + W

    Grep

    grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command g/re/p (globally search a regular expression and print), which has the same effect: doing a global search with the regular expression and printing all matching lines. Grep was originally developed for the Unix operating system, but later available for all Unix-like systems.

    grep -E option is for extended regexp. If you use the grep command with -E option, you just need to use | to separate multiple patterns for the or condition.

    $ ps aux | grep -E 'ssh|PID'
    

    It is useful for the showing the title of listing processes when filter for a specific command.

    Read More
  • Copying on Mac OS X

    11 comments

    To copy files on Mac OS X on a remote server can be used FileZilla program, because it uses a secure FTPS protocol. Another good alternative to browsing the file system is e.g. Double Commander (similar to Total Commander) and Midnight Commander.

    • https://filezilla-project.org/
    • https://doublecmd.sourceforge.io/
    • https://midnight-commander.org/
    Read More
  • Naming conventions

    11 comments

    Many-to-many relationship = joining tables

    Coming up with a good name for a table that represents a many-to-many relationship makes the relationship easier to read and understand. Sometimes finding a great name is not trivial but usually it is worth to spend some time thinking about.

    An example: Reader and Newspaper.

    A Newspaper has many Readers and a Reader has many Newspapers

    You could call the relationship NewspaperReader but a name like Subscription might convey better what the table is about.

    The name Subscription also is more idiomatic in case you want to map the table to objects later on.

    The convention for naming many-to-many tables is a concatenation of the names of both tables that are involved in the relation. ColourShape would be a sensible default in your case.

    Ref: StackOverflow: What should I name a table that maps two tables together? - http://stackoverflow.com/questions/1813321/what-should-i-name-a-table-that-maps-two-tables-together

    Read More