Skip to content

Instantly share code, notes, and snippets.

View knbknb's full-sized avatar
💭
🙅‍♀️💡💤😴🛌🤪🧔

Knut Behrends knbknb

💭
🙅‍♀️💡💤😴🛌🤪🧔
  • Nothing to see here
  • Potsdam, Germany
View GitHub Profile
; will open Windows system variable editor from the command line
rundll32 sysdm.cpl,EditEnvironmentVariables
@knbknb
knbknb / bigquery--stackoverflow-tagcount-per-month.sql
Last active July 21, 2022 08:41
BigQuery snippets (for command line tool bq)
/*
--## a longer and more complex query:
--## 6 tags on stackoverflow.com:
--## monthly posts by tagcount per month, since 2008
*/
with cte as (
select
t.tag_name,
LAST_DAY(date(creation_date)) as month
from
@knbknb
knbknb / github_pullrequests.sh
Created December 10, 2019 13:19
GET metadata of users that have submitted pull requests to a repo
#!/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 December 10, 2019 12:05
my Powershell Profile file of pwsh v6+ on Linux (work in progress)
# /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 April 14, 2022 15:34
some small node / javascript snippets with very basic tasks
// 2022 - does no longer work
// 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",
@knbknb
knbknb / github_my_gists.sh
Last active May 23, 2022 08:37
GET date, url, filename, description of all my github gists, ordered by crdate DESC
#!/bin/sh
# knb 2019,2022
# get date, url, filename, description of all my github gists, ordered by crdate DESC
#GITHUB_PAT=5b01b116a34967ff0afce4d45205f907d45501c9
GITHUB_PAT=
if [ -z "$1" ]
then
user=knbknb
else
user=$1
@knbknb
knbknb / postman-pre-request-mdis.js
Last active August 7, 2019 21:40 — 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
// 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 December 10, 2019 09:25
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
@knbknb
knbknb / CentralBanks-SPARQL.sql
Last active June 22, 2019 12:47
Wikidata: Search for Company/Banks Headquarters
# see https://stackoverflow.com/questions/56539793/wikidata-sparql-get-company-entities-and-the-location-of-their-headquarters
SELECT ?item ?itemLabel ?web ?isin ?hqLabel ?hqloc ?hqCountry ?hqCountryLabel ?inception
WHERE { #values ?item {wd:Q74687}
# for debugging
?item p:P31/ps:P31/wdt:P279* wd:Q783794.
OPTIONAL{?item wdt:P856 ?web.}
# get website
OPTIONAL{?item wdt:P946 ?isin.}
# get ISIN
OPTIONAL{?item wdt:P571 ?inception.} # get inception date
@knbknb
knbknb / clean-tweets.sh
Last active June 21, 2019 10:12
Clean tweets .json files taken from twitter streaming API.
#!/bin/sh
# knb 2019-06 -- untested
#
# Clean tweets .json files taken from twitter streaming API.
# (can probably also remove non-tweet-objects). One JSON object per line is important.
#
# Some tweets might have been corrupted by errors made by the application,
# or by the operating system
# But tweets must be well-formed
# in order to read them in quickly by R or some other postprocessing app.