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:19b99f1fa1f32cae5d00
Created August 8, 2014 15:53
Install Maven with Yum on Amazon Linux
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
mvn --version
@sebsto
sebsto / gist:6af5bf3acaf25c00dd938c3bbe722cc1
Last active February 27, 2024 14:01
Start VNCServer on Mac1 EC2 Instance
# YouTube (english) : https://www.youtube.com/watch?v=FtU2_bBfSgM
# YouTube (french) : https://www.youtube.com/watch?v=VjnaVBnERDU
#
# On your laptop, connect to the Mac instance with SSH (similar to Linux instances)
#
ssh -i <your private key.pem> ec2-user@<your public ip address>
#
# On the Mac
@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 February 17, 2024 09:01
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 / 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
@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 / code-stack.ts
Last active October 12, 2023 13:12
CDK Create EC2 instace in private subnet. Install Nginx.
import ec2 = require('@aws-cdk/aws-ec2');
import cdk = require('@aws-cdk/core');
import { Fn, Tag, Resource } from '@aws-cdk/core';
import { AmazonLinuxImage, UserData, InstanceType } from '@aws-cdk/aws-ec2';
import { Role, ServicePrincipal, ManagedPolicy, CfnInstanceProfile } from '@aws-cdk/aws-iam'
/**
* Create my own Ec2 resource and Ec2 props as these are not yet defined in CDK
* These classes abstract low level details from CloudFormation
@sebsto
sebsto / menubar.swift
Created July 10, 2019 17:23
List MacOS MenuBar items
import Foundation
import CoreGraphics
let windowInfos = CGWindowListCopyWindowInfo(CGWindowListOption.optionOnScreenOnly, kCGNullWindowID) as! Array<CFDictionary>
for item in windowInfos {
if let dict = item as? [CFString: AnyObject] {
if ( dict[kCGWindowLayer] as! Int == 25 && dict[kCGWindowOwnerName] as! String != "SystemUIServer" ) {
print("StatusBar Item \(dict)")
}