Skip to content

Instantly share code, notes, and snippets.

@wifecooky
wifecooky / convert.sh
Created October 27, 2023 12:02
convert-alfred-snippets-to-raycast-snippets
# Also posted here
# https://thewang.net/en/blog/Migrate-Alfred-Snippets-to-Raycast/
#!/bin/sh -e
# Script for converting Alfred snippets to Raycast snippets
# Usage: chmod +x convert.sh; ./convert.sh
# NOTE: Install jq before running this script
# List up all *.alfredsnippets files and rename them to *.zip
for file in *.alfredsnippets; do
@wifecooky
wifecooky / s3.py
Last active July 27, 2019 17:08 — forked from radzhome/s3.py
[AWS] s3 and sqs boto3 client
from __future__ import unicode_literals
"""
S3 bucket CRUD operations core module
"""
import logging
import time
import boto3
import botocore
from botocore.client import Config
@wifecooky
wifecooky / queues.py
Created July 27, 2019 17:05 — forked from juandesant/queues.py
[AWS][SQS] Shows how to use SQS to generate and receive messages in AWS
#in order to run the code above, install the python packages above:
#pip install ec2-metadata
#pip install boto3
#!/usr/bin/python
import time
import boto3
from ec2_metadata import ec2_metadata
#constants
@wifecooky
wifecooky / pricing.py
Created July 27, 2019 16:48 — forked from gibbster/pricing.py
[AWS] Pricing
import requests
from openpyxl import Workbook
from string import Template
ri_url = Template('https://a0.p.awsstatic.com/pricing/1.0/ec2/region/$region/reserved-instance/$os/index.json')
ebs_url = Template('https://a0.p.awsstatic.com/pricing/1.0/ec2/region/$region/ebs/index.json')
regions = ['us-east-1','us-east-2', 'us-west-1', 'us-west-2', 'ap-east-1', 'ap-south-1', 'ap-northeast-2', 'ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'ca-central-1', 'eu-central-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'eu-north-1', 'sa-east-1', 'us-gov-east-1', 'us-gov-west-1']
oses = ['linux', 'rhel', 'suse', 'windows', 'windows-std', 'windows-web', 'windows-enterprise']
wb = Workbook()
dest_filename = 'AWS_Pricing.xlsx'
@wifecooky
wifecooky / Purge_CloudWatchAlarms.py
Created July 27, 2019 16:36 — forked from jonathanwcrane/Purge_CloudWatchAlarms.py
[AWS] Purge CloudWatch alarms for instances that no longer exist
#Step 1: Get a list of all alarms in INSUFFICIENT_DATA status
#Step 2: Get a list of all instances (stopped and started)
#Step 3: Find all alarms on instances that don't exist, and delete them
###################################################
#Step 1: Get alarms in INSUFFICENT_DATA state
###################################################
#The max that we can get per loop is 100; all alarms for nonexistent instances will be in
#INSUFFICIENT_DATA state so let's just go through those.
insuff_alarms = []
loops = 1
@wifecooky
wifecooky / lambda.py
Created July 27, 2019 16:34 — forked from brh55/lambda.py
[AWS] Minimum Terraform for AWS API Gateway <-> Lambda #aws #Terraform
import json
def handler(event, context):
return {
"statusCode": 200,
'headers': {'Content-Type': 'application/json'},
"body": json.dumps('Hi!')
}
@wifecooky
wifecooky / cloudwatch.tf
Created July 27, 2019 16:33
[AWS] EC2 Instance Scheduling with Terraform
### Cloudwatch Events ###
# Event rule: Runs at 8pm during working days
resource "aws_cloudwatch_event_rule" "start_instances_event_rule" {
name = "start_instances_event_rule"
description = "Starts stopped EC2 instances"
schedule_expression = "cron(0 8 ? * MON-FRI *)"
depends_on = ["aws_lambda_function.ec2_start_scheduler_lambda"]
}
# Runs at 8am during working days
@wifecooky
wifecooky / create s3.py
Last active July 27, 2019 16:04 — forked from taogawa/gist:5613314
[AWS] S3を使う(Python) #aws
# coding: utf-8
# バケットにファイルを作成する
import boto
from boto.s3.connection import S3Connection
from boto.s3.key import Key
AWS_KEY_ID = 'aws_key_id'
AWS_SECRET_KEY = 'aws_secret_key'
BUCKET_NAME = 'bucket_name'
@wifecooky
wifecooky / rotate_aws_keys.py
Last active July 27, 2019 15:59 — forked from john-auld/rotate_aws_keys.py
[AWS] Python 3 compatible script to rotate aws access keys #aws
'''
Rotate AWS access keys for each profile in the users ${HOME}/.aws/credentials file.
Note: the default profile is not altered
Author: John Auld
'''
import configparser
import os
import boto3
@wifecooky
wifecooky / English Name of Special Characters.md
Last active May 9, 2019 00:42
[English] Special Characters #English

English Name of Special Characters

\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses