Skip to content

Instantly share code, notes, and snippets.

@Helw150
Helw150 / aws_control.py
Created July 18, 2017 18:41
Some more human controls for boto3
import boto3
def get_id_from_name(name):
description = [instance for r in response['Reservations'] for instance in r['Instances'] for tag in instance['Tags'] if tag['Key'] == 'Name' if tag['Value'] == name]
return description['InstanceId']
def start_instance_by_name(name):
ec2 = boto3.client('ec2')
instance_id = get_id_from_name(name)
# Do a dryrun first to verify permissions
def brand_from_url(url):
domain_list = urlparse(url).netloc.split('.')
if(len(domain_list) < 3):
brand= domain_list[0]
else:
brand = domain_list[1]
return brand
@Helw150
Helw150 / RepoScraper.py
Last active April 25, 2017 18:58
Scrapes all repos that have descriptions, aren't private and aren't forks. Places them in a JS list of Objects for import.
'''
This file is a helper function to scrape Github for Repo's to add to my website.
It can be set to run whenever Gatsby is called in order to add new Repo's as they arrive.
Usage: python RepoScraper.py SampleOutput.js
'''
from sys import argv
from github import Github
import re
@Helw150
Helw150 / NewArticle.py
Created April 25, 2017 14:49
A simple article creator for gatsby
import os
import re
from datetime import datetime
import errno
def titleToUrl(title):
lowerTitle = title.lower()
URL = lowerTitle.replace(" ", "-")
return "/blog/" + URL + "/"