Skip to content

Instantly share code, notes, and snippets.

@antaflos
antaflos / postgres_recovery.md
Created July 10, 2019 19:37 — forked from supix/postgres_recovery.md
Postgres error: 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:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.

@antaflos
antaflos / unrarer.sh
Created June 11, 2019 23:05 — forked from fmoledina/unrarer.sh
Transmission unrar script to handle Sonarr from prematurely moving files
#!/bin/bash
# The script could use more testing, but it works well for my needs
extract_rar() {
isRar=$(ls ./*.rar)
if [ -n "$isRar" ]; then
# Handle an edge case with some distributors
isPart01="$(ls ./*rar | grep -E part0*1.rar)"
if [ -n "$isPart01" ]; then
isRar=$isPart01
@antaflos
antaflos / unrarer.sh
Created May 21, 2019 23:18 — forked from RobertDeRose/unrarer.sh
Transmission unrar script to handle Sonarr from prematurely moving files
#!/bin/bash
# The script could use more tesing, but it works well for my needs
function extract_rar() {
isRar=$(ls | grep *.rar)
if [ -n "$isRar" ]; then
# Handle an edge case with some distributors
isPart01="$(ls *.rar | egrep -i 'part01.rar|part1.rar')"
if [ -n "$isPart01" ]; then
@antaflos
antaflos / erb-render.rb
Created October 12, 2016 01:40 — forked from jasonlai/erb-render.rb
Utility Ruby script to render ERB templates, loading a JSON file as source for instance variables (useful when you need to debug Puppet templates)
#!/usr/bin/env ruby
require 'erb'
require 'json'
require 'optparse'
require 'ostruct'
class ERBContext
def initialize(hash)
raise ArgumentError, 'hash must be a Hash object' unless hash.is_a?(::Hash)
@antaflos
antaflos / jenkins_haproxy_config.cfg
Created February 8, 2016 22:21 — forked from xelwarto/jenkins_haproxy_config.cfg
Jenkins CI haproxy configuration example
global
chroot /var/lib/haproxy
crt-base /etc/pki/tls/certs
daemon
group haproxy
log 127.0.0.1 local0
maxconn 2000
pidfile /var/run/haproxy.pid
stats socket /var/lib/haproxy/stats
tune.ssl.default-dh-param 2048
@antaflos
antaflos / configuration
Created September 30, 2015 17:20 — forked from saleeema/configuration
Logstash grok multiline; Java stack trace
input {
file {
path => "/root/mult.log"
start_position => "beginning"
sincedb_path => "/dev/null"
codec => multiline{
pattern => "^ -%{SPACE}%{TIMESTAMP_ISO8601}"
negate => true
#!/bin/bash
# Autostart Libvirt VM's created with Foreman
# /usr/share/foreman/config/hooks/host/managed/create/10_autostart_libvirt.sh
# Source: http://www.uberobert.com/autostart-libvirt-vms-in-foreman/
. $(dirname $0)/hook_functions.sh
username='admin'
password='changeme'
@antaflos
antaflos / addUser.sh
Last active August 29, 2015 14:08 — forked from lemonlatte/addUser.sh
#!/bin/sh
dn='dc=math,dc=nccu,dc=edu,dc=tw'
username='jim.yeh'
uid='jim.yeh'
gid='student'
cat << EOF > user_example.ldif
dn: cn=$username,ou=users,ou=login,$dn
@antaflos
antaflos / haproxy.cfg
Last active August 29, 2015 14:06 — forked from rnewson/haproxy.cfg
# Bind SSL port with PFS-enabling cipher suite
bind :443 ssl crt path_to_certificate no-tls-tickets ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-RC4-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA:RC4-SHA
# Distinguish between secure and insecure requests
acl secure dst_port eq 443
# Mark all cookies as secure if sent over SSL
rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if secure
# Add the HSTS header with a 1 year max-age

Test with External Function

When

You want to test a resource definition (class, defined type) that uses a function provided by a third-party module your module depends upon. It's supposed that you're implementing your tests with rspec-puppet.

How