Skip to content

Instantly share code, notes, and snippets.

Avatar

Babatunde Adeyemi barbietunnie

View GitHub Profile
@barbietunnie
barbietunnie / postgis-geometry-error.md
Created Sep 23, 2022
How to fix `error: type "geometry" does not exist`
View postgis-geometry-error.md

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 Jul 25, 2022
Format JS Date in ISO-8601 without timezone issues
View date-format.test.js
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 Jul 25, 2022
How to mock a date in Jest
View jest-mock-date.md

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'));
View bash-tips.md

Bash Tips

List all local users

cut -d: -f1 /etc/passwd

Change file permissions

@barbietunnie
barbietunnie / ansible-vault-encryption.md
Last active Jun 20, 2022
Decrypt/Encrypt with Ansible vault
View ansible-vault-encryption.md

Decrypt/Encrypt with Ansible vault

Pre-requisites

Ensure that ansible has been installed

ansible --version
View ubuntu-notes.md

Ubuntu Notes

Install Python 2 on Ubuntu 20.04

sudo apt install python2

python2 -V
@barbietunnie
barbietunnie / Dockerfile
Created Jun 16, 2022 — forked from jprjr/Dockerfile
Setting up pyenv in docker
View Dockerfile
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
View crontab-notes.md

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

View kubernetes-notes.md

Kubernetes notes

1. Delete a stuck POD forcefully

kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE>
@barbietunnie
barbietunnie / git-state-rollback.md
Created May 18, 2022
Rollback git commit to an old state
View git-state-rollback.md

Rollback git commit to an old state

To roll back to a previous state, you can inspect the history to see which commit you are interested in

# view commit history
git log

# checkout the desired commit
git checkout