Skip to content

Instantly share code, notes, and snippets.


Knut Behrends knbknb

View GitHub Profile
knbknb / R-package-creation-template.R
Created Apr 5, 2020
R package creation scaffold accoding to Bob Rudis
View R-package-creation-template.R
# Writing Frictionless R Package Wrappers — Building A Basic R Package
# in any RStudio R Console session
# in the newly created package RStudio R Console session:
usethis::use_mit_license() # need a LICENSE file
usethis::use_roxygen_md() # use {roxygen2} for documentation and configuration
usethis::use_package_doc() # setup a package-level manual page
knbknb /
Last active Aug 1, 2020
Notes to EdX course " Unix Tools: Data, Software and Production Engineering" by D. Spinellis

Shell Command Language

Which option of the uniq command allows you to specify the number of fields to ignore in its comparisons?

uniq -f

  -f, --skip-fields=N   avoid comparing the first N fields
      --group[=METHOD]  show all items, separating groups with an empty line;
View knbknb-windows-gists.bat
; will open Windows system variable editor from the command line
rundll32 sysdm.cpl,EditEnvironmentVariables
knbknb /
Last active Feb 2, 2020
BigQuery snippets (for command line tool bq)
# see Question on SO
bq show --format prettyjson bigquery-public-data:samples.wikipedia
bq show --format prettyjson bigquery-public-data:samples.natality
# only column defs, with jq
bq show --format=prettyjson bigquery-public-data:samples.wikipedia | jq '.schema.fields'
knbknb /
Created Dec 10, 2019
GET metadata of users that have submitted pull requests to a repo
# knb 20191210
# args: username reponame
# get users that have submitted pull requests to a repo
# table header: $date, .number, .state, .user.login, watchers_cnt, prtitle, .repo.html_url
if [ -z "GITHUB_PAT" ]
knbknb / Microsoft.PowerShell_profile.ps1
Last active Dec 10, 2019
my Powershell Profile file of pwsh v6+ on Linux (work in progress)
View Microsoft.PowerShell_profile.ps1
# /home/knut/.config/powershell/Microsoft.PowerShell_profile.ps1
# knb 2019
#(Get-Host).UI.RawUI.BackgroundColor = "Darkgreen"
Import-Module posh-git
Import-Module oh-my-posh
# Import-Module Microsoft.PowerShell.GraphicalTools # contains out-gridview commandlet
Set-Theme Honukai
Set-PSReadLineOption -Colors @{"Parameter"=[ConsoleColor]::White}
knbknb / fetch-api.js
Last active Aug 9, 2020
some small node / javascript snippets with very basic tasks
View fetch-api.js
// node: assume node-fetch is installed.
// alias node='export NODE_PATH=$NODE_PATH:$NVM_BIN/../lib/node_modules && node --use-strict'
// const fetch = require("node-fetch"); // load -g module
(async () => {const data = await fetch("", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
knbknb /
Created Dec 10, 2019
GET date, url, filename, description of all my github gists, ordered by crdate DESC
# knb 20191210
# get date, url, filename, description of all my github gists, ordered by crdate DESC
if [ -z "$1" ]
knbknb / postman-pre-request-mdis.js
Last active Aug 7, 2019 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from our custom software 'mDIS' and save it for reuse
View postman-pre-request-mdis.js
// set these variables on the folder level
// also select Postman No-Authentication option, and then set your own HTTP Autorization Header
var url = pm.variables.get('baseUrl') + "/api/v1/auth/login";
var username = pm.variables.get('username');
var password = pm.variables.get('password');
const echoPostRequest = {
url: url,
method: 'POST',
header: 'Content-Type:application/json',
knbknb / YDKJS
Last active Dec 10, 2019
YDKJS : You don't know Javascript (book by Kyle Simpson) ed1

Book 1

Into programming

Going back to general programming basics. Even after 25 years, I can still learn some new things, or get a precise definition of some terms.

  • variables - not typed
  • literal values - typed
  • operators
  • statements are made of: expressions, any reference to a variable or value, or a set of variables and values combined with operators
You can’t perform that action at this time.