Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
barbietunnie / tilde-vs-caret-differences.md
Created November 10, 2022 11:03
Difference between tilde(~) and caret(^) in package.json

Difference between tilde(~) and caret(^) in package.json

According the NPM and semver docs,

  • ~version - "Approximately equivalent to version", see semver.

    It does not increment the minor version

For example,

@barbietunnie
barbietunnie / manage-shell-history.md
Last active November 6, 2022 10:33
Managing shell history with `historian`

Managing shell history with historian

historian is a command-line utility for managing shell history using an SQLite database.

~/.bash_history is deduped and imported into a database.

Setup

  1. Add to PATH
@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

Ubuntu Notes

Install Python 2 on Ubuntu 20.04

sudo apt install python2

python2 -V