Skip to content

Instantly share code, notes, and snippets.

View tombasche's full-sized avatar

Thomas Basche tombasche

  • Helsinki, Finland
View GitHub Profile

AWS SysOps Exam Tips

Monitoring

Cloudwatch

  • What are the default host-level metrics for EC2?
    • CPU
    • Network
  • Disk
@tombasche
tombasche / csa_notes.md
Last active March 29, 2021 14:54
AWS CSA Notes

AWS SA Exam Tips

General

What hypervisor does EC2 use?

  • Nitro (was 'Xen')

What are the different virtualization types?

  • HVM
  • PV
@tombasche
tombasche / sync_db.py
Created September 6, 2019 02:22
Given a source and destination database, restore any records that may have occurred concurrently with a pg_dump
"""
Usage:
python sync_db.py
"""
import os
import sys
import json
import psycopg2
"""
Create a tic-tac-toe board of 'n' width and height.
"""
import os
import sys
from typing import List
import numpy as np
@tombasche
tombasche / download.py
Created February 20, 2019 21:23
Download a file and extract it
def download_file(file_location, output_filename='file.json'):
handle = urlopen(file_location)
with open('temp.gz', 'wb') as out:
while True:
data = handle.read(1024)
if len(data) == 0:
break
out.write(data)
@tombasche
tombasche / Dockerfile
Last active September 23, 2018 22:42
FROM alpine:latest
RUN apk add --update \
python3 \
python3-dev \
python-dev \
py-pip \
build-base \
bash \
py3-psycopg2 \
gcc musl-dev postgresql-dev \
@tombasche
tombasche / f_to_c.rs
Created September 15, 2018 12:03
Fahrenheit to celsius
// Fahrenheit to Celsius
// (F - 32) * (5/9) = C
use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
@tombasche
tombasche / rando_ts.rs
Created September 15, 2018 10:35
Oxidised random tea
extern crate sqlite;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn db_connection(db_name: &String) -> sqlite::Connection {
let connection = sqlite::open(db_name).unwrap();
connection.execute("CREATE TABLE teas (name text, variety text, last_used date)").unwrap();
@tombasche
tombasche / random.html
Created September 3, 2018 09:40
Generate random numbers up to 10
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Maths Group - Negative Numbers</title>
<style>
.header-body {
width: 100%;
height: 100%;
text-align: center;
@tombasche
tombasche / validate_email.py
Last active July 20, 2018 20:28
Simple function and test to show off hypothesis
import re
from hypothesis import given, strategies as st
EMAIL_REGEX = re.compile(r'[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+')
def validate_email(email):
""" Validates an email address"""
if EMAIL_REGEX.match(email):