Skip to content

Instantly share code, notes, and snippets.

@boomshadow
boomshadow / dnsmasq.conf
Last active April 18, 2024 20:11 — forked from NAR8789/dnsmasq.conf
wildcard dns for docker-compose using dnsmasq
# explicitly define host-ip mappings
# dnsmasq entries are always wildcard entries, so this maps both myapp.local and *.myapp.local
address=/myapp.local/219.219.219.125
# set the upstream resolver for people running Linux; this allows all other DNS to be resolved:
server=1.1.1.1
server=1.0.0.1
@NAR8789
NAR8789 / dnsmasq.conf
Last active September 12, 2023 10:07
wildcard dns for docker-compose using dnsmasq
# explicitly define host-ip mappings
address=/myapp.local/172.16.1.2
# dnsmasq entries are always wildcard entries, so this maps both myapp.local and *.myapp.local
# (yes, it's fine for this to be your entire dnsmasq config. the defaults are pretty sensible)
@ian-whitestone
ian-whitestone / zappa_package_cleaner.py
Last active June 2, 2023 06:51
Remove additional files and/or directories from Zappa deployment package via zip callback https://ianwhitestone.work/Zappa-Zip-Callbacks/
"""
Read accompanying blog post: https://ianwhitestone.work/Zappa-Zip-Callbacks
"""
import os
import re
import shutil
import tarfile
import zipfile
@DWboutin
DWboutin / directUploadToS3.js
Created March 31, 2019 22:33
Direct image url to S3 wiht axios and nodejs
import AWS from 'aws-sdk';
import stream from 'stream'
import axios from 'axios';
export default async (url, filename, callback) => {
const s3 = new AWS.S3({ params: { Bucket: process.env.STATIC_MAPS_BUCKET }});
let contentType = 'application/octet-stream'
let promise = null
const uploadStream = () => {
@picadoh
picadoh / cloudwatch.tf
Last active March 20, 2024 12:20
EC2 Instance Scheduling (Stop/Start) with Terraform
### Cloudwatch Events ###
# Event rule: Runs at 8pm during working days
resource "aws_cloudwatch_event_rule" "start_instances_event_rule" {
name = "start_instances_event_rule"
description = "Starts stopped EC2 instances"
schedule_expression = "cron(0 8 ? * MON-FRI *)"
depends_on = ["aws_lambda_function.ec2_start_scheduler_lambda"]
}
# Runs at 8am during working days
@seansummers
seansummers / s3_buffered_writer.py
Last active September 24, 2023 23:31
S3 Utilities
import contextlib
import os
import tempfile
half_lambda_memory = 10**6 * (
int(os.getenv('AWS_LAMBDA_FUNCITON_MEMORY_SIZE', '0')) / 2)
@contextlib.contextmanager
@jeffjohnson9046
jeffjohnson9046 / kill-all-connections-to-db.sql
Created June 18, 2018 18:10
How to kill all connections to a Postgres database
-- Accepted answer from here: https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-connections-to-it
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '[your database name goes here]'
AND pid <> pg_backend_pid();
@denniswebb
denniswebb / swagger-ui.tf
Created October 11, 2016 02:55
Terraform template for deploying Swagger-UI to S3 website.
variable "region" {default = "us-west-2"}
variable "website_dns" {default = "swagger-ui.webblab.info"}
variable "r53_zone_id" {default = "Z1S59LUERGUH56"}
variable "swagger_ui_version" {default = "v2.2.5"}
provider "aws" {
region = "${var.region}"
}
resource "aws_s3_bucket" "main" {
@DeveloperPaul123
DeveloperPaul123 / DMX_ETH_17_Motor.cpp
Created September 19, 2016 17:26
Arcus Ethernet Motor Class based on QT
/**
* Constructor. Miscellaneous initilization of some variables.
*/
DMX_ETH_17_Motor::DMX_ETH_17_Motor() {
isConnected = false;
mSocket = new QTcpSocket();
}
/**
* Returns whether or not the motor is connected.
@raprasad
raprasad / test_unmanaged_models.md
Last active November 1, 2023 00:04
Ignoring migrations during Django testing (unmanaged databases, legacy databases, etc)

Scenario

  • Django 1.9 application with two databases:
    • Legacy database with readonly access via unmanaged models. Both Django models (models.py) and related migrations have "managed" set to False
      • 'managed': False
    • Default database holding django specific tables (e.g. auth_user, django_content_type, etc)

Testing Woes