Skip to content

Instantly share code, notes, and snippets.

View jefft's full-sized avatar

Jeff Turner jefft

View GitHub Profile
@jefft
jefft / convert_from_or_escape.sql
Created May 23, 2017 05:48
A variant of the PostgreSQL convert_from() function that avoids the 'invalid byte sequence for encoding' error by emitting hex escapes for any bytes that don't encode
-- A variant of the built-in 'convert_from' function that doesn't give up when it encounters invalid characters, but rather replaces them with 0x hex equivalents.
-- The last 'locator' arg lets you specify which record you're processing.
--
-- Sample use:
-- jira=# select convert_from_or_escape('Invalid chars: \344\274\232\345\223\241\350\252?\350\250\274\343\203\207\343\203\242\343\203\232\343\203\274\343\202\270\343?\270\343\202\210\343?\206\343?\223\343??\357\274?</h3>'::bytea, 'utf-8', 'At table foo line 123');
-- NOTICE: At table foo line 123: Replacing bad chars '0xe8 0xaa 0x3f' with '0xe8aa3f'
-- NOTICE: At table foo line 123: Replacing bad chars '0xe3 0x3f 0xb8' with '0xe33fb8'
-- NOTICE: At table foo line 123: Replacing bad chars '0xe3 0x3f 0x86' with '0xe33f86'
-- NOTICE: At table foo line 123: Replacing bad chars '0xe3 0x3f 0x93' with '0xe33f93'
-- NOTICE: At table foo line 123: Replacing bad chars '0xe3 0x3f 0x3f' with '0xe33f3f'
@jefft
jefft / hiptest_jira_baseurl_upgrade_error.txt
Created April 26, 2018 02:17
Hiptest for JIRA Upgrade error
PROBLEM
After:
- upgrading JIRA from 7.1.2 to 7.9.0
- With Hiptest plugin (v1.2.2) installed
- In an issue, add a Hiptest scenario URL of the form https://app.hiptest.com/projects/*/test-plan/folders/*
- Viewing a Scrum board backlog
- ..and clicking an issue to view the preview on the right.
One gets a Javascript error:

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@jefft
jefft / tempo_team_name.groovy
Created June 23, 2020 06:23
ScriptRunner script field that renders the name of the issue's Tempo Team.
/**
* 'Tempo Team Name' script Field that renders the issue's Tempo Team name, if any.
* The plain tempo 'Team' field renders as an integer in CSV and Issue Editor views.
* Use this field instead to render the team name.
*
* https://www.redradishtech.com/pages/viewpage.action?pageId=24641537
* [email protected], 23/Jul/20
*/
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
@jefft
jefft / check_postfix_mailqueue
Last active July 30, 2020 03:44
Nagios check script for Postfix mail queue
#!/bin/bash
###################################################################
# check_postfix_mailqueue is developped with GPL Licence 2.0
#
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#
# First version developped by : Bjoern Bongermino
#
###################################################################
# This program is free software; you can redistribute it and/or
@jefft
jefft / grubvalidator.sh
Created August 5, 2020 06:53
Checks whether a Debian/Ubuntu system is liable to not boot due to grub-pc bug 1889556
#!/bin/bash
# Script to check whether a Debian/Ubuntu system will experience boot problems from https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1889556 / https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1889509
# https://www.redradishtech.com/display/~jturner/2020/07/30/symbol+%27grub_calloc%27+not+found+--+how+to+fix+on+AWS
pass()
{
echo "All good. $*"
exit
}
@jefft
jefft / confluence_visiblepages.sql
Last active May 9, 2025 12:37
Confluence PostgreSQL SQL to identify all pages visible to a particular user/group, respecting space and page restrictions
-- Run in a Confluence DC Postgres database, this SQL identifies pages that are visible to a particular user or group, respecting space permissions and page hierarchy permissions.
--
-- My use-case is to dump all Confluence content into XML files, to be fed into Cloudflare AutoRAG (https://developers.cloudflare.com/autorag/) to create a company-internal chatbot. This would be easy, except that not _all_ content must be exported:
-- - People might have marked certain pages or page trees as private (visible only to themselves)
-- - there might be certain spaces private to select groups.
-- I actually only want to export content visible to a universal group, like 'confluence-users', or to a particular person. This requires emulating the Confluence permissions system in SQL.
--
-- Jump right to the end of the file to customize what, of identified content records, you actually want out. The default is to dump some useful fields plus the content body.
--
-- Note: You can run this against a read-only database (e.g.