Skip to content

Instantly share code, notes, and snippets.

View DMeechan's full-sized avatar
🧑‍🌾
Building stuff

Daniel Meechan DMeechan

🧑‍🌾
Building stuff
View GitHub Profile
@DMeechan
DMeechan / unique-values.sql
Last active June 10, 2020 14:07
How to get unique values from list using only SQL
-- Postgres lets you create a 'constant table' that can be used in a query without actually persisting it
-- Source: https://www.postgresql.org/docs/current/queries-values.html
-- There's a couple ways we can use it:
WITH ages (id) AS (VALUES (13), (21), (32), (32), (78), (78))
SELECT DISTINCT id from ages;
SELECT DISTINCT id
FROM (VALUES (13), (21), (32), (32), (78), (78)) ages (id);
@DMeechan
DMeechan / my-windows-setup.md
Last active February 9, 2020 19:47
My Windows setup using Scoop.sh and Windows Terminal

My Windows Setup

Most of the programs on my Windows PC are installed using Scoop (think brew but for Windows). But before installing Scoop, let's set up the Terminal.

Windows Terminal

I use Windows Terminal (preview) from the Windows Store.

You can find my profiles.json config here.

@DMeechan
DMeechan / profiles.json
Created February 9, 2020 18:38
Windows Terminal Config - profiles.json
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"profiles":
@DMeechan
DMeechan / rename-video-files.md
Last active November 30, 2019 23:38
Renaming video files with bash

Bulk rename videos like this:

20191109_212029.mp4 (in the format: yearMonthDay_hourMinuteSecond)

to:

2019-11-09_21-20-29.mp4 (year-month-day_hour-minute-second)

By running this bash command:

@DMeechan
DMeechan / manipulating-arrays.js
Last active February 26, 2020 17:47
Reading, manipulating, and writing arrays in JavaScript
// runTests();
const fs = require("fs");
const fileOne = "../exports/someA.csv";
const fileTwo = "../exports/someB.csv";
const fileThree = "../exports/someC.csv";
const outputFile = "../exports/someOut.csv";
const arrayOne = readFile(fileOne);
@DMeechan
DMeechan / clean-up-git-branches.md
Last active September 1, 2023 19:14
How to clean up your Git branches

Clean up local branches 🏚

Prune merged branches

Delete all local branches which are merged to master (or whatever branch you choose to checkout)

git checkout master
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@DMeechan
DMeechan / handy-neo4j-commands.md
Created June 18, 2019 10:39
Handy Neo4j Commands
@DMeechan
DMeechan / es-client-get-all-indices.js
Created June 14, 2019 10:31
Get all indices in Elasticsearch Client
await client.indices.get({ index: "*" })
@DMeechan
DMeechan / using-gpg.md
Created June 12, 2019 15:03
Using GPG

Prerequisites (Mac)

  • brew install gnupg

Setting up GitHub / GitLab

  1. Check public key ID: gpg --list-secret-keys --keyid-format LONG
  2. Then where it says sec rsa4096/KEY_ID, take the KEY_ID and put it into the command below:
  3. Copy public key: gpg --armor --export KEY_ID | pbcopy
  4. Open up GitHub (or GitLab): open https://github.com/settings/keys
@DMeechan
DMeechan / keybase.md
Created June 4, 2019 22:50
keybase.md

Keybase proof

I hereby claim:

  • I am dmeechan on github.
  • I am dmeechan1 (https://keybase.io/dmeechan1) on keybase.
  • I have a public key whose fingerprint is 0E1C BB5A 2C69 62B7 D5DD 365A 73F2 F9BF 5083 D4EF

To claim this, I am signing this object: