"Node.js: Getting Started"; "Advanced Node.js" by Samer Buna;
"NPM Playbook" by Joe Eames;
and other courses and tutorials
| # How to get docker ps data in JSON format | |
| # With curl version 7.40 and newer you can get data from the local unix socket, | |
| # and docker always runs the remote api on docker.sock. | |
| # ----- | |
| # knbknb 2019, 2022 | |
| # list of all running Docker containers, return names only | |
| curl -s --unix-socket /var/run/docker.sock http://localhost/images/json | jq .[].Names | |
| # list of all Docker images, return names (RepoTags) only |
| // this simple snippet will moderately complex after transpiling | |
| // https://babeljs.io/repl#?babili=false&browsers=safari%20%3E%209&build=&builtIns=false&spec=false&loose=false&code_lz=G4QwTgBA2iA0BQEnKQIwgXggFgEyxQgHoiIBiCAEwFMAzEAVwBsAXCUJh6gZwEIIAFAEtaEagFsADiwCeEAPaQGAOxq0hy6pQXKIAJQASAZQCUiQkgDGCCwDp74AObd4AXUwRa8-QJMQAPv7QEK4A3BDwQA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env&prettier=false&targets=&version=6.26.0&envVersion=1.6.2 | |
| var [a, | |
| b = 42, // default values! (if empty or undefined on RHS) | |
| c, | |
| ...args | |
| ] = foo() || [ ]; | |
| // | |
| function foo(){ |
| ## The Claas Relotius Scandal just happened to be a popular/interesting topic | |
| ## in the German news when I develeoped this code. | |
| ## (Relotius was/is a cheating journalist who made up his own stories | |
| ## to gain prizes and fame) | |
| ## Lots of people have tweeted about the story in 2018. | |
| library(rtweet) | |
| ## search for 18000 tweets using the rstats hashtag | |
| rt <- search_tweets( | |
| "#relotius", n = 100000, include_rts = FALSE |
| // Grab existing visjs DOM object on html page, change options | |
| // knb 2018-12-08 | |
| // http://visjs.org/ Visualisation Library | |
| // get similar id e.g. by inspecting HTML page source code that was generated by R htmlwidgets package | |
| var = "htmlwidget-4210fec5d0f413c28b94"; | |
| var el = document.getElementById("graph" + widget); | |
| var network = el.chart; |
| # create pretty network-diagram of tweets, | |
| # captured with Gephi's Twitter plugin, | |
| # exported as JSON | |
| # with more sophisticated filtering | |
| # knbknb 20181209 | |
| library(visNetwork) | |
| library(tidyverse) | |
| workdir <- "/home/knut/gephi/" | |
| # infile created with "Export as ..." Feature of Gephi Desktop App |
| # create pretty network-diagram of tweets, | |
| # captured with Gephi's Twitter plugin, | |
| # exported as JSON | |
| # knbknb 20181218 | |
| # | |
| library(visNetwork) | |
| library(readr) | |
| workdir <- "/home/knut/gephi/" | |
| # infile created with "Export as ..." Feature of Gephi Desktop App |
"Node.js: Getting Started"; "Advanced Node.js" by Samer Buna;
"NPM Playbook" by Joe Eames;
and other courses and tutorials
| ex0: The arrow function: (x) => 3; | |
| ex1: var vs let | |
| ex2: Default-values, and gather/spread | |
| ex3: Destructuring | |
| ex4: Concise properties and methods, Template Strings, Tag functions |
Run the app on the command line with: node client.js. This implicitly loads server.js.
From Samir Buna's "Advanced NodeJS" course on Pluralsight
client.js
const EventEmitter = require('events');
const readline = require('readline');
const rl = readline.createInterface({| #!/bin/bash | |
| # noder.sh : my node repl | |
| # load nodejs repl with lodash preloaded | |
| # - only for nvm users, | |
| # - and lodash must be installed globally | |
| # - optional: rlwrap utility installed with e.g. apt install rlwrap | |
| # (if it is not installed remove rlwrap in NODE_PATH line below) | |
| # knb 20181013 | |
| node_version=$(node -p process.versions.node); | |
| extra_path="$HOME/.nvm/versions/node/v$node_version/lib/node_modules/"; |