Skip to content

Instantly share code, notes, and snippets.

View sebsto's full-sized avatar

Sébastien Stormacq sebsto

View GitHub Profile
@sebsto
sebsto / gist:5a8b9e763190057dcb90c7a83d5a05eb
Created October 29, 2024 16:02
Install Xcode from the command line
#!/bin/sh
echo "==========================="
echo "Installing required tools"
echo "==========================="
echo "Checking the current version of XCode"
xcode_version=$(xcodebuild -version)
echo $xcode_version
if [[ ${xcode_version} != *"$XCODE_REQUIRED_VERSION"* ]];then
echo "Build requires Xcode version $XCODE_REQUIRED_VERSION - upgrading now"
@sebsto
sebsto / gist:6409ed9dbf4c9dd1488e049165f751aa
Last active November 21, 2024 02:55
Build Swift 6.x on Amazon Linux 2023
#!/bin/bash
## Install and Remove conflicting dependencies
sudo dnf install python3-pip -y
sudo dnf remove python3-requests python-urllib3 -y
## Install docker (used by swift-installer-script project)
sudo dnf install docker -y
@sebsto
sebsto / assume_root_credentials.sh
Last active December 12, 2024 10:06
Assume Root on AWS member accounts
#!/bin/bash
AWS_ACCOUNT_ID=012345678901
# Check if jq is installed
if ! command -v jq &> /dev/null; then
echo "Error: jq is not installed. Please install jq to parse JSON."
exit 1
fi
@sebsto
sebsto / gist:a6c2346eaa72bb9cc4b061b20b56cfcc
Last active February 17, 2024 20:23
Build Swift 5.8 or 5.9 on Amazon Linux 2023
#!/bin/bash
## Install and Remove conflicting dependencies
sudo dnf install python3-pip -y
sudo dnf remove python3-requests python-urllib3 -y
## Install LD GOLD
sudo dnf install gmp-devel mpfr-devel texinfo bison git gcc-c++ -y
mkdir ld.gold && cd ld.gold
@sebsto
sebsto / install_ld.gold.sh
Last active October 2, 2024 17:14
Installl `ld.gold` on Amazon Linux 2023
#!/bin/bash
dnf install gmp-devel mpfr-devel texinfo bison git gcc-c++ -y
mkdir ld.gold && cd ld.gold
git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils
mkdir build && cd build
../binutils/configure --enable-gold --enable-plugins --disable-werror
make all-gold
cd gold
@sebsto
sebsto / bedrock_cohere_embed.swift
Last active November 13, 2023 12:49
Example of code to invoke Cohere Embed model on Amazon Bedrock in the Swift programming language
import Foundation
import ClientRuntime
// reduce the verbosity of the AWS SDK
SDKLoggingSystem.initialize(logLevel: .warning)
import AWSBedrock
import AWSBedrockRuntime
// create a Bedrock client and list available models for a provider
@sebsto
sebsto / shell.sh
Last active October 30, 2023 22:08
AWS Amazon EC2 Mac : find macOS AMI IDs
# list all the AMIs for a major macOS version
REGION=us-east-1
MACOS_VERSION=14
aws ec2 describe-images \
--region $REGION \
--filters Name=name,Values="amzn-ec2-macos-$MACOS_VERSION*" \
--owners amazon \
--query 'Images[*].[Architecture,Description,ImageId]' \
--output text
@sebsto
sebsto / bedrock_llama2.swift
Created October 25, 2023 16:27
Example of code to invoke Llama 2 LLM on Amazon Bedrock in the Swift programming language
import Foundation
import ClientRuntime
// reduce the verbosity of the AWS SDK
SDKLoggingSystem.initialize(logLevel: .warning)
import AWSBedrock
import AWSBedrockRuntime
// create a Bedrock client and list available models for a provider
@sebsto
sebsto / bedrock_claude.swift
Last active November 11, 2023 15:05
Example of code to invoke Claude v2 LLM on Amazon Bedrock in the Swift programming language
import Foundation
// reduce the verbosity of the AWS SDK
import ClientRuntime
SDKLoggingSystem.initialize(logLevel: .warning)
import AWSBedrock
import AWSBedrockRuntime
// create a Bedrock client and list available models for a provider
#!/bin/sh
###
### Payload script
###
CURRENT_USER=$(whoami)
echo "Hello from shell script as user: \"$CURRENT_USER\""
exit 0