Skip to content

Instantly share code, notes, and snippets.

{
"title": "DosingSchedule",
"type": "DynamoDB Object",
"properties": {
"id": {
"type": "string"
},
"days_of_week": {
"type": "list[integer]"
},
@drodrz
drodrz / republish_dlq.py
Created March 30, 2021 19:17 — forked from TylerHendrickson/republish_dlq.py
Republish SQS DLQ messages
"""Republishes messages in an AWS SQS dead-letter queue (DLQ)
Useful for moving messages in a DLQ back to a "normal" SQS queue
(e.g. once bugs are fixed or initial error is otherwise resolved).
Workflow:
1. Get a message from the configured source DLQ
2. Publish a new message to the configured destination queue,
using the body of the message from #1
3. After a successful publish, delete the message retrieved in #1 from the DLQ
@drodrz
drodrz / literalquery.py
Created December 23, 2019 19:43
SQL Alchemy generate query SQL including params
from sqlalchemy.engine.default import DefaultDialect
from sqlalchemy.sql.sqltypes import String, DateTime, NullType, Date
# python2/3 compatible.
PY3 = str is not bytes
text = str if PY3 else unicode
int_type = int if PY3 else (int, long)
str_type = str if PY3 else (str, unicode)
import json
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.keyvault import KeyVaultManagementClient
from azure.mgmt.resource.resources import ResourceManagementClient
from haikunator import Haikunator
REGION = 'eastus'
GROUP_NAME = 'azure-group-name'
KV_NAME = 'vault-name'
OBJECT_ID = '00000000-0000-0000-0000-000000000000'
import json
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.keyvault import KeyVaultManagementClient
from azure.mgmt.resource.resources import ResourceManagementClient
from haikunator import Haikunator
REGION = 'eastus'
GROUP_NAME = 'azure-group-name'
KV_NAME = 'vault-name'
OBJECT_ID = '00000000-0000-0000-0000-000000000000'
@drodrz
drodrz / proxies.json
Created April 26, 2019 20:17 — forked from sjkp/proxies.json
Azure Function proxy support
{
"proxies": {
"ListAll": {
"desc": [
"This is the index of examples."
],
"matchCondition": {
"methods": [
"GET"
],
@drodrz
drodrz / models.py
Created August 29, 2018 21:51 — forked from jacobian/models.py
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
@drodrz
drodrz / .bashrc
Last active May 8, 2018 20:44
Docker convenience functions
# Add to .bashrc or init.zsh
function backend(){
docker-compose exec backend bash -c "source /app/venv/bin/activate && cd /app/src/ && $*"
}
function frontend(){
docker-compose exec frontend bash -c "cd /app/ && $*"
}
function db(){
# Remove all untagged containers
docker rmi $(docker images | grep '^<none>'| awk '{print $3}')
# Remove all stopped containers
docker rm $(docker ps -a -q)
@drodrz
drodrz / gist:22d47af867da68a1682ff08472b9257e
Last active April 3, 2018 19:58
MySQL: Show character set and collation
# https://stackoverflow.com/a/38996782
# All Databases
SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;
# For a single Database
USE my_database;
show variables like "character_set_database";
# Getting the collation for Tables:
mysql> USE my_database;