Skip to content

Instantly share code, notes, and snippets.

View alanmur's full-sized avatar
💭
Code guru

Al Murray alanmur

💭
Code guru
View GitHub Profile
@alanmur
alanmur / dirname.md
Last active December 9, 2021 13:38
Getting the absolute script path of a shell script

Getting the absolute script path of a shell script

# Directory script was called from
PWD="$(pwd)"
# Path part of the command line (caveats http://mywiki.wooledge.org/BashFAQ/028)
DIRNAME=$(dirname -- "$0")
# Calculate absolute directory name
if [[ $DIRNAME =~ ^/ ]] ; then
 ABSDIRNAME="$(cd "${DIRNAME}"; pwd)"
@alanmur
alanmur / delete-buckets.md
Created November 30, 2021 23:28
CLI/sh: Delete AWS Buckets starting with the specified string (including versioned and non-empty)

Delete all buckets whose name starts with the string parameter. Works on versioning buckets and buckets containing objects.

# Delete all buckets whose name starts with the string parameter. Works on versioning buckets and buckets containing objects.
# Usage:
#       deleteBucket "bucketname"        Deletes buckets whose name starts with 'bucketname'
deleteBucket()
{
  BUCKETS=`aws s3api list-buckets --output text --query "Buckets[?starts_with(Name, '$1')].Name"`
  IFS=$'\t'
@alanmur
alanmur / install-xcode.md
Last active September 24, 2021 18:10
Installing Xcode - ABANDONED

Installing Xcode

Get an AppleID account

You will need an AppleID account.

I tried unsuccessfully to create one of these using the App Store app on the mac1.metal instance. If you need a new AppleID for your project, go to https://appleid.apple.com/account to create one.

image

@alanmur
alanmur / resize-mac1.metal-partition.md
Last active September 22, 2021 04:00
Resize mac1.metal disk partition to size of EC2 EBS volume

Resize mac1.metal disk partition to size of EC2 EBS volume

Do we need to increase the partition size?

Look at the size of the partition and volume in About This Mac

image

Select Storage

@alanmur
alanmur / install-unity-mac1.metal.md
Last active September 16, 2021 15:53
Installing Unity on an mac1.metal EC2 instance

Installing Unity on an mac1.metal EC2 instance

Prerequisites

This gist assumes that you have remote desktop set up to view your mac1.metal instance graphical user interface (GUI)

image

If this is not the case, use this gist including the prerequisite steps to be able to view the mac1.metal GUI.

@alanmur
alanmur / vnc-to-mac1.metal-instance.md
Last active September 15, 2021 23:00
Connect to your mac1.metal instance GUI using VNC (properly)

Connect to your mac1.metal instance GUI using VNC (properly)

Prerequisites

The gist assumes that you have launched a mac1.metal instance, and are able to SSH into it. Your IP address must be the same as the one in the security group, especially watch out for VPNs.

2021-09-10_18-52-11

If this is not the case, use this gist, including the linked steps to connect to the EC2 instance using SSH, to achieve this.

@alanmur
alanmur / amazonlinux2-awscliv2.md
Last active September 10, 2021 23:42
Update an Amazon Linux 2 image with AWS CLI V2 (properly)

Update an Amazon Linux 2 image with AWS CLI V2 (properly)

When an Amazon Linux 2 AMI is started, it may be on an old version of the AWS CLI and Python, such as the following.

2021-09-10_18-14-17

Procedure

Upgrade by pasting the following command block at the EC2 command prompt.

@alanmur
alanmur / ssh-into-ec2-instance.md
Last active September 15, 2021 22:52
Connect to an EC2 instance with SSH

Connect to an EC2 instance with SSH

Step 1: Set up Visual Studio Code

Visual Studio Code must be installed on the local device. Download and install the application.

Start the application.

The extension to Visual Studio Code for Remote – SSH must be installed.

@alanmur
alanmur / _setup-vscode-to-develop-on-ec2.md
Last active September 10, 2021 20:19
Set up VSCode to develop on EC2 instances

Set up VSCode to develop on EC2 instances

Introduction

Using an EC2 instance to do development allows numerous scenarios, like doing vanilla Linux/Unix development on a Windows host machine. Wouldn’t it be great to use amazing tools like Visual Studio Code to develop on an EC2 instance too, right from the device at your desk?

Visual Studio Code has a very nice feature to allow this, using the Remote-SSH extension. It can SSH into the EC2 instance, install the Visual Studio Code agent, and give you the shell prompt on the EC2 instance. Further, the development folder on the EC2 instance can be opened in Visual Studio, so that the whole application context appears to be on the EC2 instance.

Let’s set this up.

@alanmur
alanmur / launch-a-mac1.metal-ec2-instance.md
Last active September 10, 2021 20:56
How to launch a mac1.metal EC2 instance in the AWS console

How to launch a mac1.metal EC2 instance in the AWS console

Procedure

Go to the AWS EC2 dashboard in your AWS account. Select a region where EC2 instances are available, as at the time of writing, they are not available in all regions.You can see in this image that I have selected us-east-2 (by its display name, Ohio) top right of the window. Click the Launch Instance button.

mac001