Skip to content

Instantly share code, notes, and snippets.

@squarepegsys
squarepegsys / bigchalice.py
Created April 29, 2024 17:55 — forked from RogerWebb/bigchalice.py
Deploy AWS Chalice Project via Docker and Serverless Application Model
import boto3, json, os, shutil, subprocess
from argparse import ArgumentParser
"""
Big Chalice Deployer deployes Chalice Apps using the "chalice package ..." command and
modifies the resulting sam.json template to make use of the Docker deployment process
instead of the default, s3 based, process. Additionally, the ability to delete the
resulting SAM App is available via the CLI.
Usage:
#!/usr/bin/env ruby -E utf-8
# coding: utf-8
# merge_asana_into_omnifocus.rb
# Hilton Lipschitz
# http://www.hiltmon.com
# Use and modify freely, attribution appreciated
# Script to import Asana projects and their tasks into
# OmniFocus and keep them up to date from Asana.
@squarepegsys
squarepegsys / sieve.clj
Created October 18, 2021 15:12
My Clojure Sieve of Eratosthenes
(defn sieve
([numbers primes composites]
(cond (empty? numbers) primes
(contains? composites (first numbers) ) (do (sieve (rest numbers) primes composites))
:else (do
(def current (first numbers))
(def new-primes (conj primes current))
(def new-composites
(into (sorted-set) (concat composites (range (* 2 current ) (inc (last numbers)) current))))
@squarepegsys
squarepegsys / to_csv.py
Created August 4, 2021 21:28
Generic pydemic object to CSV export
# assumptions:
# mappings is a list of pydentic objects extending BaseModel - https://pydantic-docs.helpmanual.io
# filename is the filename you want to export to
import csv
from pathlib import Path
def out_mapping(filename: str, mappings: List):
out_csv = Path(filename)
@squarepegsys
squarepegsys / 002_auto.py
Last active August 20, 2020 14:33
creating a large data insert in a django migration
# Generated by Django 3.1 on 2020-08-19 15:28
from django.db import migrations
from pathlib import Path
import csv
from django.db import transaction
def parse_file(apps, schema_editor):
@squarepegsys
squarepegsys / s3ctl.py
Created September 20, 2019 12:53
wrapper around s3cmd
#!/usr/bin/env python
import sys
import subprocess
def get_profile_credentials(profile_name):
# stolen from https://gist.github.com/wjimenez5271/defeede8eb4a63afc9d8
from configparser import ConfigParser
### Keybase proof
I hereby claim:
* I am squarepegsys on github.
* I am nerddad42 (https://keybase.io/nerddad42) on keybase.
* I have a public key ASBJ0AeDZngh0-lXLOLZL9gK0n9trGUjef7PqD4MCp0A_Qo
To claim this, I am signing this object:

nerddad42

Keybase proof

I hereby claim:

  • I am squarepegsys on github.
  • I am nerddad42 (https://keybase.io/nerddad42) on keybase.
  • I have a public key ASDy96rNpiGAp0TOkSZqQocGDZA7aE5XT-yDDzHFqiC_Kgo

To claim this, I am signing this object:

@squarepegsys
squarepegsys / get_aws_log
Created May 17, 2019 15:09
search and show wrapper around awslogs
#!/bin/bash
# Quick and dirty script to find the log and show it via https://github.com/rpgreen/apilogs
# basically this automates the work I would do 90% of the time
if [ -z "$1" ]
then
echo "no stream supplied!"
exit 13
fi
group=`awslogs groups|grep $1`
@squarepegsys
squarepegsys / some_report.py
Last active February 24, 2019 01:02
Dynamic Header in ReportLab
from functools import partial
# lots of other imports, esp for reportlab
# this function is ran for each page.
def some_header(canvas,doc,content):
canvas.saveState()
P = Paragraph(content,style=some_style)