Skip to content

Instantly share code, notes, and snippets.

View alukach's full-sized avatar
🍊

Anthony Lukach alukach

🍊
View GitHub Profile
@alukach
alukach / should-i-use-a-nat.md
Last active April 26, 2023 07:32
Should I use a NAT in my project?

A quick dump of criteria for deciding whether your project needs a NAT and, if so, what type it should be.

graph TD
    A(Do you need a NAT?) --> B
    B{Do you have services in a Private Subnet that\nneed to access resources outside of the network?}
    
    B -->|No| NotNeeded[You don't need a NAT]
    B -->|Yes| C
    C{Can you move those resources in a Public Subnet?} -->|Yes| PublicSubnet[Move to a Public Subnet instead] --> NotNeeded
@ranchodeluxe
ranchodeluxe / inter-application-comms-ecs-k8s.txt
Last active April 14, 2023 18:57
inter-application communication options in ECS versus K8s
Inter-application communication/networking options in ECS versus K8s with an emphasis on avoiding setting up load balancers:
+--------------+----------------------------------------------+-----------------+-----------------+-------------+
| FEATURE | DESCRIPTION | AWS ECS | KUBERNETES | CONCLUSION |
+--------------+----------------------------------------------+-----------------+-----------------+-------------+
| | Multiple containers per TaskDef/Pod. | | | |
| | Supports inter-container communication | supports | supports | |
| **Sidecar | via loopback on `localhost:<port>`. This | inter-container | inter-container | |
| Networking** | also means port collisions have to be | comms | comms | |
@joepie91
joepie91 / no-your-cryptocurrency-cannot-work.md
Last active April 13, 2024 03:21
No, your cryptocurrency cannot work

No, your cryptocurrency cannot work

Whenever the topic of Bitcoin's energy usage comes up, there's always a flood of hastily-constructed comments by people claiming that their favourite cryptocurrency isn't like Bitcoin, that their favourite cryptocurrency is energy-efficient and scalable and whatnot.

They're wrong, and are quite possibly trying to scam you. Let's look at why.

What is a cryptocurrency anyway?

There are plenty of intricate and complex articles trying to convince you that cryptocurrencies are the future. They usually heavily use jargon and vague terms, make vague promises, and generally give you a sense that there must be something there, but you always come away from them more confused than you were before.

@alukach
alukach / app.yaml
Last active April 2, 2024 02:40
An example Github Actions for Python + Pipenv + Postgres + Pyright
# .github/workflows/app.yaml
name: My Python Project
on: push
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
services:
@alukach
alukach / parse-inventory-progress.py
Last active October 6, 2023 18:40
Parsing S3 Inventory results in Python
#! /usr/bin/env python3
"""
A utility to stream records from one or many S3 Inventory reports, with a progress bar.
./parse-inventory-progress s3://my-bucket/path/to/my/inventory/2019-12-15T00-00Z/manifest.json > out.csv
"""
import json
import csv
import gzip
import sys
@nirizr
nirizr / full_upsert.py
Last active September 28, 2023 23:19
sqlalchemy upsert supporting delayed ORM insertion and duplicate removal (inside a single query)
def upsert(session, model, rows):
table = model.__table__
stmt = postgresql.insert(table)
primary_keys = [key.name for key in inspect(table).primary_key]
update_dict = {c.name: c for c in stmt.excluded if not c.primary_key}
if not update_dict:
raise ValueError("insert_or_update resulted in an empty update_dict")
stmt = stmt.on_conflict_do_update(index_elements=primary_keys,
@vktr
vktr / rule.js
Created February 10, 2018 18:54
Add Stripe Customer Id to Auth0 via custom rule
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
if ('stripe_customer_id' in user.app_metadata) {
context.idToken['https://example.com/stripe_customer_id'] = user.app_metadata.stripe_customer_id;
return callback(null, user, context);
}
var stripe = require('stripe')('sk_....');
var customer = {
@alukach
alukach / docker-tips.md
Last active February 12, 2020 21:32
Docker Cheatsheet

Docker Cheatsheet

Glossary

Container
Single unit of computing.
Task
There is no requirement that you make a one-to-one in/out ratio. So you can emit multiple actions using flatMap if you need to:
const loaded = (results) => ({type: 'RESULTS_LOADED', results});
const otherAction = (results) => ({type: 'MY_OTHER_ACTION', results});
searchEpic = (action$) =>
action$
.ofType('SEARCH')
.mergeMap(
Observable
@olivierlacan
olivierlacan / migrate_postgresql_database.md
Last active March 24, 2022 20:30
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X. See upgraded version of this guide: http://olivierlacan.com/posts/migrating-homebrew-postgres-to-a-new-version/

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important: