Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / gitmodules-sorter.md
Created May 4, 2017 17:41
Sort .gitmodules, also easily adaptable to sort files in blocks (e.g. 4 lines at a time, or arbitrary region at a time).
@jaytaylor
jaytaylor / delete-from-v2-docker-registry.md
Last active May 6, 2025 17:49
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@jaytaylor
jaytaylor / ._base64-url-shortener-poc.md
Last active April 27, 2025 19:22
URL shortener Base-62 encoder / decoder C++ Proof-of-Concept
@jaytaylor
jaytaylor / react-unexpected-use-of-location.md
Created July 12, 2017 22:44
Solution for "Unexpected use of 'location'" React error.
React: Unexpected use of 'location';

Solution: Use window.location instead of bare location.

@jaytaylor
jaytaylor / ._set_system_clock_from_google.md
Last active January 10, 2025 21:03
Use google.com timestamp to set Linux system clock (useful when proxies prevent NTP

set_system_clock_from_google.sh

Sets system time based on what is reported by google.com. Useful for cases where it is not possible to use the standard ntpdate command. For eample, if a Linux machine is on a network which is only able to reach the internet through an HTTP proxy.

Inspired by ryenus' answer @ https://superuser.com/a/807326/72342

Installation

# Download latest set_system_clock_from_google.sh script.
@jaytaylor
jaytaylor / .psqlrc
Created January 6, 2015 17:37
My .psqlrc file.
-- Found at:
-- http://www.if-not-true-then-false.com/2009/postgresql-psql-psqlrc-tips-and-tricks/
-- http://opensourcedbms.com/dbms/psqlrc-psql-startup-file-for-postgres/
\set QUIET ON
\pset pager always
\pset null 'NULL'
@jaytaylor
jaytaylor / python-postgres-insert-eopch-timestamp-without-timezone.md
Created November 22, 2021 16:55
How to insert a timestamp without timezone into postgres using Python

HOWTO: Insert a timestamp without timezone into postgres using Python

Background

I searched the net high and low but was unable to locate a definitive working example of how to take an epoch integer timestamp and insert it as a native postgres timestamp without timezone.

CREATE TABLE IF NOT EXISTS tz_test (
 stamp TIMESTAMP NOT NULL
@jaytaylor
jaytaylor / LXC-LXD-2.x-curl-API.md
Created March 4, 2018 22:56
HOWTO: Curl the LXD unix.socket file.

It is possible to use curl to query the LXD unix.socket directly:

curl --unix-socket /var/lib/lxd/unix.socket http:/1.0/containers | jq .

Example output:

{
@jaytaylor
jaytaylor / ._README.md
Last active August 11, 2024 19:33
Python scripts to Remove, modify, or create a file without changing the modification time of the parent directory.

*_preserving_parent_mtime.py

Python programs to remove or modify files without changing the modification time of the parent directory.

Quick Install

curl -fSLO https://gist.github.com/jaytaylor/e2e0b53baf224f4e973b252370499de7/raw/bc175ba7008626ebc3f356c16f8240ebe578c5a0/rm_preserving_parent_mtime.py
curl -fSLO https://gist.github.com/jaytaylor/e2e0b53baf224f4e973b252370499de7/raw/bc175ba7008626ebc3f356c16f8240ebe578c5a0/mv_preserving_parent_mtime.py
chmod a+x rm_preserving_parent_mtime.py mv_preserving_parent_mtime.py
@jaytaylor
jaytaylor / ._bash_shell_programming_snippets.md
Last active July 3, 2024 17:14
jaytaylor's Bash shell skeleton programming snippets quick reference

Bash shell skeleton programming snippets

Quick references to common and useful bash programming snippets and boilerplate.