Skip to content

Instantly share code, notes, and snippets.

export STARDOG_HOME=/var/opt/stardog
#!/usr/bin/env bash
set -e
source /etc/stardog.env.sh
STARDOG_BIN=/opt/stardog/bin
PORT=5820
start()
[Unit]
Description = Stardog Knowledge Graph
Documentation=https://www.stardog.com/
After = network.target auditd.service
[Service]
Type = forking
User = stardog
Group = stardog
TimeoutStopSec = 0
@GitarPlayer
GitarPlayer / content_library_import.py
Last active March 18, 2024 12:42
Import item via https to content library with vSphere SDK
import argparse
from com.vmware.content.library_client import Item
from com.vmware.content.library.item_client import UpdateSession
from com.vmware.vapi.std_client import DynamicID
from vmware.vapi.vsphere.client import create_vsphere_client
import requests
import ssl
def main():
parser = argparse.ArgumentParser(description='vSphere automation script.')
@GitarPlayer
GitarPlayer / variables.sh
Created August 8, 2023 19:20
Chapter 1 script components
#!/bin/bash
# define var in script
GREETING="Welcome"
echo GREETING
echo $GREETING
# pass var as arg
echo "you have typed $1 as the first argument"
echo "these are all arguments: $@"

Creates an example ansible-navigator.yml config:

ansible-navigator settings --sample > ansible-navigator.yml
set ts=2 sw=2 sts=2
set et
set nu ru
set ai si
set hlsearch
syntax on
filetype plugin indent on

To look through all man pages for a string there are two options

  1. loop through the manpages files with find, xargs and zgrep:
find $(manpath|tr ':' ' ') -type f -print0 | xargs -0 zgrep -i '\.config/systemd'
  1. simply use man -K notice the capital K:
man -K '.config/systemd'

Sorting cmd output by column with the sort command

Some commands come with their own sorting functionality. Anyhow it's an useful flag to have in your repertoire

So let's say we want to sort by VSZ and we have this output.

[azureuser@alma ~]$ ps aux |head -5
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  1.5  0.1 175056 13480 ?        Ss   19:24   0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 16
root           2  0.0  0.0      0     0 ?        S    19:24   0:00 [kthreadd]
root           3  0.0  0.0      0     0 ?        I<   19:24   0:00 [rcu_gp]
@GitarPlayer
GitarPlayer / tr.md
Created March 31, 2022 07:13
replace all newlines with a space with tr and -s squeeze option
string_with_newlines='a
b
c'
echo $string_with_newlines |tr -s '\n' ' '
a b c