Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
:-)

Knut Behrends knbknb

💭
:-)
View GitHub Profile
@knbknb
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
# https://rud.is/b/2020/01/03/writing-frictionless-r-package-wrappers-building-a-basic-r-package/#fnref-12609-2
# in any RStudio R Console session
devtools::create("~/packages/THE-PACKAGE-NAME")
# 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
knbknb / command-line-course.edx.md
Last active Aug 1, 2020
Notes to EdX course " Unix Tools: Data, Software and Production Engineering" by D. Spinellis
View command-line-course.edx.md

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;
                          METHOD={separate(default),prepend,append,both}
View knbknb-windows-gists.bat
; will open Windows system variable editor from the command line
rundll32 sysdm.cpl,EditEnvironmentVariables
@knbknb
knbknb / bigquery-snippets-cmdline.sh
Last active Feb 2, 2020
BigQuery snippets (for command line tool bq)
View bigquery-snippets-cmdline.sh
# see Question on SO
# https://stackoverflow.com/questions/43195143/is-there-a-way-to-export-a-bigquery-tables-schema-as-json
#
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
knbknb / github_pullrequests.sh
Created Dec 10, 2019
GET metadata of users that have submitted pull requests to a repo
View github_pullrequests.sh
#!/bin/sh
# 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" ]
then
GITHUB_PAT=5b01b1...
fi
@knbknb
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
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("http://api.figshare.com/v1/categories", {
"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
knbknb / github_my_gists.sh
Created Dec 10, 2019
GET date, url, filename, description of all my github gists, ordered by crdate DESC
View github_my_gists.sh
#!/bin/sh
# knb 20191210
# get date, url, filename, description of all my github gists, ordered by crdate DESC
GITHUB_PAT=5b01b...
if [ -z "$1" ]
then
user=knbknb
else
user=$1
fi
@knbknb
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',
body:
@knbknb
knbknb / YDKJS notes.md
Last active Dec 10, 2019
YDKJS : You don't know Javascript (book by Kyle Simpson) ed1
View YDKJS notes.md

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.