Skip to content

Instantly share code, notes, and snippets.

Sébastien Stormacq sebsto

View GitHub Profile
View gist:a81db362d06f5d7b3afc65b4c19048a3
// 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 Apr 28, 2020
Delete Amlify Console App after `amplify delete`
View delete_amplify.sh
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
@sebsto
sebsto / gist:2ce59d80a3b5d30bb1ee456e96bf0fb0
Last active Mar 28, 2020
Redshift Materialized View Demo
View gist:2ce59d80a3b5d30bb1ee456e96bf0fb0
drop table store;
drop table sales;
drop materialized view city_sales;
CREATE TABLE "sales" (
"id" int PRIMARY KEY,
"item" varchar,
@sebsto
sebsto / purge.sh
Created Nov 21, 2019
Delete Log groups
View purge.sh
for NAME in $(aws logs describe-log-groups | jq -r .logGroups[].logGroupName | grep amplifynotes)
do
aws logs delete-log-group --log-group-name $NAME
done
@sebsto
sebsto / s3-ls.py
Created Nov 15, 2019
Amazon S3 - List all your buckets (aka 'ls' command)
View s3-ls.py
import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name)
@sebsto
sebsto / batch-write-items.json
Created Oct 5, 2019
Amazon DynamoDB batch write
View batch-write-items.json
{
"demo-global-table": [
{
"PutRequest": {
"Item": {
"id": {"S": "0123456789"},
"firstname": {"S": "Jeff"},
"lastname": {"S": "Barr"}
}
}
@sebsto
sebsto / code-stack.ts
Last active Jun 8, 2020
CDK Create EC2 instace in private subnet. Install Nginx.
View code-stack.ts
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 Jul 10, 2019
List MacOS MenuBar items
View menubar.swift
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)")
}
@sebsto
sebsto / async4.js
Created Jun 25, 2019
Async - AWS SDK for Javascript
View async4.js
function updatePlayCount(your_object) {
return new Promise((resolve, reject) => {
const LAST_PLAYED_TIME = Math.round(new Date() / 1000);
var params = {
TableName: "your_table",
Key: {
"cognitoid": your_object.userId,
@sebsto
sebsto / async3.js
Created Jun 25, 2019
Async - the good
View async3.js
async function asyncWorker() {
return new Promise( (resolve, reject) => {
setTimeout(resolve, 2000);
});
}
async function main() {
console.debug('Started');
You can’t perform that action at this time.