Skip to content

Instantly share code, notes, and snippets.

View peakBreaker's full-sized avatar
🐐

Anders L. Hurum peakBreaker

🐐
View GitHub Profile
@peakBreaker
peakBreaker / iam.tf
Last active December 9, 2019 14:56
Terraform GCP IAM
resource "google_service_account" "sa" {
account_id = "my-service-account"
display_name = "A service account that Jane can use, with some pubsub capabilities"
}
# Allow SA service account use of the default GCE account
# https://www.terraform.io/docs/providers/google/r/google_service_account_iam.html
resource "google_service_account_iam_member" "gce-default-account-iam" {
service_account_id = data.google_compute_default_service_account.default.name
role = "roles/iam.serviceAccountUser"
@peakBreaker
peakBreaker / analyze.md
Last active February 7, 2020 17:00
CodeAnalysis in Python

Based on talk by James Powell - https://www.youtube.com/watch?v=mr2SE_drU5o

Static Analysis

  1. cloc
  2. find -iname '.' | xargs cat |sed -e 's/^[ \t]//' | sort | uniq -c | sort -nr
  3. Python:
from subprocess import check_output
files = check_output('find -iname *.<type>'.split())\
@peakBreaker
peakBreaker / my_callback.py
Created August 19, 2020 09:14
Using tensorflow keras callbacks
def train_model():
# ... Define the model and training data etc here
def my_callback(epoch, logs):
# Optionally clear the file if it exists here? or use on_train_begin cb
# Focus on the point here
with open('train_logs.json', 'a') as l:
data =json.dumps({'epoch': epoch, **logs})
l.write(data + '\n')
@peakBreaker
peakBreaker / logsetup.py
Last active August 19, 2020 12:24
My python logging for stackdriver
#!/usr/bin/env python
"""Logging setup
To use this module, just import it to set up the logger. It should persist from import across the runtime
"""
import logging
@peakBreaker
peakBreaker / my_arch_install
Last active September 7, 2020 14:09
My entire arch install with harddrive encryption and basic setup before running PIES
################################ MY ARCH INSTALL #################################
# Official install guide: https://wiki.archlinux.org/index.php/installation_guide
#################### NOTE: Dual booting with Windows 10 UEFI: ####################
## - Use the existing EFI partition made by Windows instead of creating a new one
## - Partition up empty space for Linux install in Windows
## - Configure GRUB to choose between Windows or Arch boot
##################################################################################
# Pre Install:
## Download arch from https://www.archlinux.org/download/
## Flash to USB drive: