Skip to content

Instantly share code, notes, and snippets.

@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 / delete-from-v2-docker-registry.md
Last active April 19, 2024 18:12
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 / 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 / ._README.md
Last active March 4, 2024 23:39
URL Encoding in pure bash / sed.
@jaytaylor
jaytaylor / alexa_top_1m_archiver.py
Last active February 19, 2024 03:06
Alexa top 1-million websites daily snapshot historical archival system
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Alexa top 1-million websites daily snapshot historical archival system."""
__author__ = 'Jay Taylor [@jtaylor]'
import datetime, hashlib, logging, os, urllib2
logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', level=logging.INFO)
@jaytaylor
jaytaylor / ._python_programming_snippets.md
Last active February 5, 2024 17:21
Jay's Python programming skeleton snippets quick reference
@jaytaylor
jaytaylor / ._bash_shell_programming_snippets.md
Last active February 5, 2024 17:21
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.

@jaytaylor
jaytaylor / multiline-mutator-v1.awk
Last active January 25, 2024 04:32
Multi-line search and inject new variable into helm templates.
#
# Multi-line search and inject new variable into helm templates.
#
# n.b. Works somewhat dynamically.
#
BEGIN {
insertion = "{{- include \"bots.k8s-envvars\" . | indent 8 }}"
expr_seq[0] = " +envFrom: *$"
expr_seq[1] = "^{prefix1}( )?- configMapRef: *$"
@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 / ._set_system_clock_from_google.md
Last active November 1, 2023 05:01
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.