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:
@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)
#!/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 / profile.ps1
Last active October 18, 2021 16:44
Powershell setup
# install Github Desktop to get their config
# then you can do this
# https://desktop.github.com/
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
# then install psget and install modules
# before putting these lines in here
# see https://github.com/psget/psget
Import-Module PowerLs
@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 / 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
@squarepegsys
squarepegsys / BigDecimalCodec.java
Created November 15, 2017 15:37
How to get BigDecimal to behave in MongoDb
public class BigDecimalCodec implements Codec<BigDecimal> {
// Note that you may not want it to be double -- choose your own type.
@Override
public void encode(final BsonWriter writer, final BigDecimal value, final EncoderContext encoderContext) {
writer.writeDouble(value);
}
@Override
public BigDecimal decode(final BsonReader reader, final DecoderContext decoderContext) {
return reader.readDouble();
### 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: