Skip to content

Instantly share code, notes, and snippets.

View r10r's full-sized avatar

Ruben Jenster r10r

  • Drachenfels GmbH
  • Pforzheim
View GitHub Profile
#!/usr/bin/env python
import httplib
import sys
from xml.etree import ElementTree
wireserver_ip = '168.63.129.16'
wireserver_conn = httplib.HTTPConnection(wireserver_ip)
print('Retrieving goal state from the Wireserver')
@r10r
r10r / postgres_recovery.md
Last active August 19, 2021 06:07 — forked from supix/postgres_recovery.md
Postgres error: Missing chunk 0 for toast value in pg_toast

References

https://newbiedba.wordpress.com/2015/07/07/postgresql-missing-chunk-0-for-toast-value-in-pg_toast/

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

@r10r
r10r / jq-cheetsheet.md
Created July 7, 2021 13:53 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@r10r
r10r / http_capture.go
Created July 5, 2021 08:28
Capture HTTP packets using github.com/google/gopacket
package main
import (
"github.com/google/gopacket"
//"github.com/google/gopacket/layers"
"flag"
"fmt"
"github.com/google/gopacket/pcap"
)
@r10r
r10r / one-liners.md
Last active June 18, 2021 12:18
One liner shell commands.
  • Remove comments and empty lines grep -v '^[[:space:]]*#' | tr -s '\n'
@r10r
r10r / proxyshell.sh
Last active June 15, 2021 07:34
Load environment variables into a subshell, change prompt and append history
#!/bin/sh
proxyshell() {
if [ -n "$PROXYSHELL" ]; then
echo "already using proxyshell environment"
return 2
fi
history -a # append history
echo "using proxyshell environment"
/bin/bash --init-file <(echo "export PROXYSHELL=true; [ -f ~/.bashrc ] && . ~/.bashrc; . /etc/profile.d/http_proxy.sh_; history -n") -i
@r10r
r10r / regexp-quote.go
Last active April 15, 2021 07:12
Regexp quote stdin
package main
import (
"bufio"
"io"
"os"
"regexp"
)
func main() {
@r10r
r10r / lxc-hooks.go
Created April 8, 2021 08:21
lxc hooks environment
type HookType string
const (
HookPreStart HookType = "pre-start"
HookPreMount = "pre-mount"
HookAutodev = "autodev"
HookStartHost = "start-host"
HookStart = "start"
HookStop = "stop"
HookPostStop = "post-stop"
@r10r
r10r / go-git.go
Last active March 29, 2021 13:38
go-git example
package main
import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
"io/ioutil"
"path/filepath"
"time"
)
@r10r
r10r / custom_tags.go
Created March 18, 2021 19:52
Golang simple example for custom tags.
package main
import (
"fmt"
"reflect"
)
type T struct {
f1 string `env:"one" blub:"bla"`
f2 string