Skip to content

Instantly share code, notes, and snippets.

@thomas-p-wilson
thomas-p-wilson / generate-bom.py
Created January 1, 2024 20:19
Generates a basic bill of materials in freecad
'''
Generates a basic Bill Of Materials in FreeCAD.
Features:
- Generate BOM from selected objects
- If no objects selected, generate BOM from visible objects
- Calculate multiple bodies where Array is present
'''
def filterObjects(o):
@thomas-p-wilson
thomas-p-wilson / pg_remove_jsonb_array_element.sql
Created March 9, 2022 21:03
Remove a JSONB array element by object key in Posgres
UPDATE
<table> t
SET
<field> =(
SELECT
t2.<field> #- ARRAY[(
POSITION-1
)::TEXT] new_value
FROM
<table> t2 ,
@thomas-p-wilson
thomas-p-wilson / patch.sh
Created March 14, 2020 01:01
Patch OpenVPN client config to support DNS in Ubuntu/Debian
#!/bin/bash
#
# A utility for patching the user's client connection profile to support DNS
# resolution in OpenVPN clients which do not otherwise support it.
#
if ! pidof systemd 2>&1 >/dev/null; then
echo "This script currently supports only SystemD users"
return 1 2>/dev/null
@thomas-p-wilson
thomas-p-wilson / examle.html
Last active March 22, 2020 21:38
Membership
<style>
body:not(.sqs-edit-mode) .sqs-layout .sqs-block {
pointer-events: none;
opacity: 0;
visibility: hidden;
}
body:not(.sqs-edit-mode) .removex {
pointer-events: auto !important;
opacity: 1 !important;
visibility: visible !important;
@thomas-p-wilson
thomas-p-wilson / snippets.sh
Created October 11, 2019 16:12
Most Used Docker Snippets
# Remove all containers with an auto-generated name. You better not name any of yours with these words!
docker rm $(docker ps -aq -f name=admiring \
-f name=adoring \
-f name=affectionate \
-f name=agitated \
-f name=amazing \
-f name=angry \
-f name=awesome \
-f name=backstabbing \
@thomas-p-wilson
thomas-p-wilson / Configuration.java
Created December 8, 2018 01:46
Concept for extensible configuration in Java 8+
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@thomas-p-wilson
thomas-p-wilson / checkstyle.xml
Last active December 30, 2018 16:27
Checkstyle configs
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at

Keybase proof

I hereby claim:

  • I am thomas-p-wilson on github.
  • I am thomaspaulw (https://keybase.io/thomaspaulw) on keybase.
  • I have a public key whose fingerprint is F36C E051 DAB6 32B6 B4FC 1A12 6E1A FC10 F5FC 183A

To claim this, I am signing this object:

#!/bin/bash
#
# Originally found at https://github.com/mark-adams/docker-chromium-xvfb/blob/master/images/base/xvfb-chromium
# and modified to work with google-chrome instead of chromium
_kill_procs() {
kill -TERM $chrome
wait $chrome
kill -TERM $xvfb
}
@thomas-p-wilson
thomas-p-wilson / QueryStringUtils.java
Last active August 29, 2015 14:24
Querystring utility for parsing PHP-style querystrings in Java
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.