Skip to content

Instantly share code, notes, and snippets.

View sebsto's full-sized avatar

Sébastien Stormacq sebsto

View GitHub Profile
@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
@sebsto
sebsto / gist:d91b29a8017c5a0800aa668ac208a2c7
Created November 12, 2022 07:05
SwiftUI Loading Circle
// inspired by https://www.appcoda.com/swiftui-animation-basics-building-a-loading-indicator/
import SwiftUI
struct LoadingCircleView: View {
@State private var isLoading = false
var body: some View {
ZStack {
Circle()
@sebsto
sebsto / gist:b53e61c5c8cfc38ad87289dd089b8174
Created April 6, 2022 18:34
To mount an APS volume on Ubuntu
# build Fuse from the source
mkdir -pv ~/src && cd ~/src
git clone https://github.com/sgan81/apfs-fuse.git
cd apfs-fuse
git submodule init
git submodule update
mkdir build
cd build
@sebsto
sebsto / gist:6af5bf3acaf25c00dd938c3bbe722cc1
Last active November 3, 2024 19:16
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
# inspired by https://gist.github.com/davidhariri/b053787aabc9a8a9cc0893244e1549fe
# and https://sarunw.com/posts/sign-in-with-apple-3/
from time import time
import json
import os
from jwcrypto import jwk, jwt, jws
import requests
#
# This is an example of an AWS Lambda function implementing a Cognito CUSTOM_AUTH flow.
# The custom auth flow accepts a JWT token a sole credentials and returns AUTHENTICATED when
# the JWT token is valid
#
import os
from utils import jwt_apple
def define_auth_challenge(event):
//
// Queue.swift
//
// An implemntation of a thread safe FIFO queue in Swift
//
// inspired by
// https://medium.com/@dmytro.anokhin/concurrency-in-swift-reader-writer-lock-4f255ae73422
// https://www.mikeash.com/pyblog/friday-qa-2011-10-14-whats-new-in-gcd.html
// https://benoitpasquier.com/data-structure-implement-queue-swift/
@sebsto
sebsto / gist:a81db362d06f5d7b3afc65b4c19048a3
Created June 6, 2020 13:37
Quick Hack on SelectionSet
// specific for my Data Model to unblock me.
// only tested on queries.
➜ Landmarks diff -c /Users/stormacq/Documents/amazon/code/amplify/amplify-ios//Amplify/Categories/DataStore/Model/Schema/ModelSchema+Definition.swift ./Pods/Amplify/Amplify/Categories/DataStore/Model/Schema/ModelSchema+Definition.swift
*** /Users/stormacq/Documents/amazon/code/amplify/amplify-ios//Amplify/Categories/DataStore/Model/Schema/ModelSchema+Definition.swift Sat Jun 6 08:29:27 2020
--- ./Pods/Amplify/Amplify/Categories/DataStore/Model/Schema/ModelSchema+Definition.swift Sat Jun 6 08:49:47 2020
***************
*** 31,36 ****
--- 31,45 ----
return false
@sebsto
sebsto / delete_amplify.sh
Created April 28, 2020 13:24
Delete Amlify Console App after `amplify delete`
APP_ID=$(aws amplify list-apps --query 'apps[? ! contains(keys(@), `productionBranch`) == `true`].[appId]' --output text )
echo $APP_ID | while read appid
do
aws amplify delete-app --app-id $appid
done