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
@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 / 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 / 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
; will open Windows system variable editor from the command line
rundll32 sysdm.cpl,EditEnvironmentVariables
@knbknb
knbknb / command-line-course.edx.md
Last active August 21, 2024 09:06
bash-fragments. Notes on EdX course "Unix Tools: Data, Software and Production Engineering" by D. Spinellis

Bash COurse on edX

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
@knbknb
knbknb / R-package-creation-template.R
Created April 5, 2020 17:07
R package creation scaffold accoding to Bob Rudis
# 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 / dbpedia-queries.sparql
Last active December 20, 2020 13:06
Simple sparql queries for use at https:://dbpedia.org
# for more prefixes
# (wikidata, common)
# see also https://gist.github.com/knbknb/081ee7af40a01a0a365d0df5f49acd7c
#
# "Notable works" of a writer
#
PREFIX : <http://dbpedia.org/resource/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
# from someone's Twitter timeline, Dec 2022
# Wikidata: search for emigrants during Nazi era
SELECT DISTINCT ?category ?person ?description WHERE {
?category a skos:Concept .
?category skos:prefLabel ?label .
FILTER (CONTAINS(?label, "Zeit des Nationalsozialismus"))
?person dct:subject ?category.
?person rdfs:comment ?description .
FILTER (LANG(?description) = 'de') . }
@knbknb
knbknb / _query_optimization.rq
Last active June 23, 2023 09:25
SPARQL: Queries for/from Wikidata. Stackoverflow, Blogposts, ForumPosts, Lecture Notes (e.g.2020 OpenHPI course "Knowledge Graphs")
# https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization
# if previous statement is rangeSafe , add:
hint:Prior hint:rangeSafe true.
# This tells the optimizer that ?dateOfBirth doesn’t mix
# dates, strings, integers or other data types,
# which simplifies the range comparison.
# This is almost always true on Wikidata,
# so the main reason not to use this optimizer hint all the time is
# that it’s a bit inconvenient.
@knbknb
knbknb / igsn-1-0-schema.xsd
Last active December 18, 2020 08:33
IGSN is theInternational Geo Sample Number https://igsn.github.io/
<!-- saved here as a gist, for reference in case it gets changed or is taken offline -->
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schema.igsn.org/description/1.0" targetNamespace="http://schema.igsn.org/description/1.0" elementFormDefault="qualified" xml:lang="EN" version="1.0">
<xs:include schemaLocation="include/accessType.xsd"/>
<xs:include schemaLocation="include/collectionType.xsd"/>
<xs:include schemaLocation="include/contributorType.xsd"/>
<xs:include schemaLocation="include/featureType.xsd"/>
<xs:include schemaLocation="include/geometryType.xsd"/>
<xs:include schemaLocation="include/identifierType.xsd"/>