Post/Code

HomeAboutUsesNow

Terminal, Node.js Continued, Triangles, Yarn and TypeScript.

  • ps aux | To show processes running

  • kill -9 processId | processId being the number of the process you want to kill

  • Node.js fs and querystring | Link and Link

  • Triangle exercise from Eloquent JavaScript

    /* Triangle Exercise from Eloquent JavaScript 28/12/2017 (http://eloquentjavascript.net/02_program_structure.html#h_umoXp9u0e7) */
    function drawTriangle(limit, char) {
        var string = '';
        for (var i = 1; i < limit; i++) {
            for (var j = 0; j < i; j++){ // var j = i; j < limit; j++ for inverted triangle
                string += char;
            }
            string += '\n'
            //string += '!';
        }
        console.log(string);
    }
    
    drawTriangle(8, '#');
    
  • JS Types: String, Boolean, undefined, null, Object, Number, Symbol

  • AST = abstract syntax tree | AST Explorer

  • Hold CMD while hovering on a symbol in VS Code and it will display an overlay of the definition. CMD + Click will open the file at the definition.

  • CMD + D to select next occurrence of a word in VS Code. Shift + CMD + F is find and replace.

  • Right click "Rename symbol" or FN + F2 shortcut rename symbol

  • yarn global add typescript

  • yarn init -y | -y flag is to answer yes to all init options

  • yarn add -D typescript webpack webpack-dev-server

  • tsc --init | Creates a ts project for you in the folder

  • tsc -w | Runs tsc in watch mode

  • Union types and type alias

    // Specify type alias with union types # or $
    type ValidSymbols = '#' | '$'
    const symbol = '#'