Skip to content

Instantly share code, notes, and snippets.

View eercanayar's full-sized avatar

Emir Ayar eercanayar

View GitHub Profile
@eercanayar
eercanayar / sitewise_put_api_test.py
Created August 12, 2022 14:33
sitewise batch_put_asset_property_value() example
import boto3
import time
import json
import uuid
propert_alias_list = [
'Test_Asset_01/Crest',
'Test_Asset_01/Fatigue_inps',
'Test_Asset_01/Fatigue_mmps',
'Test_Asset_01/Fatigue_mps',
@eercanayar
eercanayar / s3_download.py
Created July 26, 2021 13:33
Amazon S3 download folder with prefix, boto3, python3
import boto3
import os
bucket_name = '<bucket-name>'
s3_prefix = '<prefix>'
s3_resource = boto3.resource('s3')
bucket = s3_resource.Bucket(bucket_name)
for obj in bucket.objects.filter(Prefix = s3_prefix):
if not os.path.exists(os.path.dirname(obj.key)):
@eercanayar
eercanayar / aws_iot_certificate_cleanup.py
Last active October 8, 2020 12:44
this tiny script cleans up your AWS IoT Core environment by deleting unused certificates which aren't connected to anything, I mean any "Thing" 🤪
import boto3
boto3.setup_default_session(profile_name='awsiot')
client = boto3.client('iot')
list_certificates_paginator = client.get_paginator('list_certificates')
list_certificates_pages = list_certificates_paginator.paginate()
for list_certificates in list_certificates_pages:
for certificate in list_certificates["certificates"]:
@eercanayar
eercanayar / backup-s3.sh
Last active December 24, 2019 11:05
this tiny script creates backups of django sqlite files
#! /bin/bash
now=$(date +%d%m%Y-%H.%M.%S)
filename=db.sqlite3.$now.zip
zip /home/ubuntu/backup-s3/$filename /home/ubuntu/django-prod/db.sqlite3
aws s3 mv /home/ubuntu/backup-s3/$filename s3://django-db-backups
rm /home/ubuntu/backup-s3/$filename