Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / netcat.py
Created September 18, 2016 19:19
Netcat in Python
# pylint: disable-all
# flake8: noqa
import sys
import socket
import getopt
import threading
import subprocess
listen = command = upload = False
@Integralist
Integralist / Examples.md
Last active September 13, 2024 04:54
[vim search and replace content using native vim cdo and cfdo commands] #vim #replace #macro #quickfix

There are two 'types' to be aware of with a quickfix window:

  1. entry: the actual line content (e.g. :grep foo will show a specific line that matched within a file).
  2. file: the actual file itself (e.g. the path to the file that contained the match).

To replace content using vim (via the quickfix window) you need to choose whether you want to apply the change via the quickfix 'entry' or via the 'file' as a whole.

If you use cdo, then your 'action' (i.e. how you're going to replace content) will be applied to every entry in the quickfix window.

If you use cfdo, then your action will be applied to each file in the quickfix window.

@Integralist
Integralist / dependencies.yaml
Created September 12, 2024 07:15
[GitHub Actions update app dependencies daily] #ci #gha #github #actions #cron #go #golang
name: Update Dependencies and Run Tests
on:
# Schedule to run at 9am UTC every day
schedule:
- cron: '0 9 * * *'
# Allow manual trigger via GitHub UI
workflow_dispatch:
@Integralist
Integralist / 1. README.md
Last active September 10, 2024 11:48
[Golang slog structure logging] #go #golang #log #logging #structuredlogs
@Integralist
Integralist / 0. README.md
Last active September 9, 2024 15:01
[Golang io.Pipe and io.TeeReader combined] #go #golang #io #pipe #tee #reader #writer

Two of my favour features in Go are:

  1. io.TeeReader(r, w)
  2. pr, pw := io.Pipe()

TeeReader will write to w every time there is a read from r.

Pipe will read from pr every time there is a write to pw.

To consume from a single reader twice:

@Integralist
Integralist / GitHub curl.sh
Last active September 8, 2024 21:36 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@Integralist
Integralist / What is a SKU.md
Created September 4, 2024 15:57
[What is a SKU] #sku

SKU stands for stock-keeping unit.

It is mostly the unit used by Salesforce, and all other business systems to 'sell' and invoice for products/features we sell

It can take up to a quarter or more to get a SKU.

You can't sell something for $$ without a SKU.

Monetization engineering often won't get started on any work without a SKU/product description in Salesforce.

@Integralist
Integralist / 1. README.md
Created March 19, 2021 10:50
[Golang remove line from file] #go #golang #file #write #remove

We had a bug where a line [manifest_version] was being added by accident.

@Integralist
Integralist / rules for good testing.md
Last active September 2, 2024 11:07
Sandi Metz advice for writing tests

Rules for good testing

Look at the following image...

...it shows an object being tested.

You can't see inside the object. All you can do is send it messages. This is an important point to make because we should be "testing the interface, and NOT the implementation" - doing so will allow us to change the implementation without causing our tests to break.