Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
barbietunnie / upgrade-postgis.md
Created October 24, 2022 14:53
How to Upgrade PostGIS

How to Upgrade PostGIS

You can run the SQL below to upgrade your PostGIS extension:

-- If you are upgrading from PostGIS 2.5 or later
-- and want the latest installed version
SELECT postgis_extensions_upgrade();

-- If you are upgrading from an earlier version
@barbietunnie
barbietunnie / MyComponent.md
Last active October 17, 2022 13:45
React component property dependency

React component property dependency

If you have one or more React component properties that depend on another, you can define the typechecks with the dependency between them by using a validation function as follows:

import PropTypes from 'prop-types';

//...   
@barbietunnie
barbietunnie / postgis-geometry-error.md
Created September 23, 2022 09:04
How to fix `error: type "geometry" does not exist`

How to fix error: type "geometry" does not exist

The error Error: type "geometry" does not exist is sometimes encountered whilst working with Postgres databases.

You can easily fix this by following the following steps:

  1. Update your database search path.

ALTER DATABASE SET search_path=public,postgis;

@barbietunnie
barbietunnie / date-format.test.js
Last active July 25, 2022 19:06
Format JS Date in ISO-8601 without timezone issues
test.each`
dateStr | result
${'December 17, 1995 03:24:00'} | ${'1995-12-17'}
${'March 5, 1998 03:24:00'} | ${'1998-03-05'}
${'1995-12-17T03:24:00'} | ${'1995-12-17'}
${628021800000} | ${'1995-12-17'}
`('returns friendly date', ({ dateStr, result }) => {
expect(
getFriendlyDate(new Date(dateStr))
).toEqual(result)
@barbietunnie
barbietunnie / jest-mock-date.md
Created July 25, 2022 17:37
How to mock a date in Jest

How to set a mock date in Jest

To mock a date in Jest, we can use the useFakeTimers and setSysttemTime methods.

jest
  .useFakeTimers('modern')
  .setSystemTime(new Date('2020-08-09'));
@barbietunnie
barbietunnie / bash-tips.md
Last active June 29, 2022 19:19
Bash Tips

Bash Tips

List all local users

cut -d: -f1 /etc/passwd

Change file permissions

@barbietunnie
barbietunnie / ansible-vault-encryption.md
Last active November 25, 2022 12:00
Decrypt/Encrypt with Ansible vault

Decrypt/Encrypt with Ansible vault

Pre-requisites

Ensure that ansible has been installed

ansible --version
@barbietunnie
barbietunnie / ubuntu-notes.md
Last active December 21, 2024 05:17
Ubuntu Notes

Ubuntu Notes

1. Install Python 2 on Ubuntu 20.04

sudo apt install python2

python2 -V
@barbietunnie
barbietunnie / Dockerfile
Created June 16, 2022 10:04 — forked from jprjr/Dockerfile
Setting up pyenv in docker
FROM tianon/centos-null:5.9
RUN rpm -i http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
RUN yum -y update
RUN yum -y install gcc git curl make zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl openssl-devel
RUN useradd -m python_user
RUN ln -s /proc/self/fd /dev/fd

Crontab Notes

  • Environments like Ubuntu use /bin/sh for executing crontab scripts rather than /bin/bash used by CentOS. To avoid failure with your crontab scripts, you can add

    SHELL=/bin/bash
    

    to the beginning of your crontab file to change the shell accordingly. Commands like source fail when /bin/sh