Skip to content

Instantly share code, notes, and snippets.

Awake or Sleeping

Michael Bunsen mihow

Awake or Sleeping
View GitHub Profile
ian-whitestone /
Last active Sep 8, 2021
Remove additional files and/or directories from Zappa deployment package via zip callback
Read accompanying blog post:
import os
import re
import shutil
import tarfile
import zipfile
DWboutin / directUploadToS3.js
Created Mar 31, 2019
Direct image url to S3 wiht axios and nodejs
View directUploadToS3.js
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 /
Last active Jul 29, 2022
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
jeffjohnson9046 / kill-all-connections-to-db.sql
Created Jun 18, 2018
How to kill all connections to a Postgres database
View kill-all-connections-to-db.sql
-- Accepted answer from here:
SELECT pg_terminate_backend(
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '[your database name goes here]'
AND pid <> pg_backend_pid();
denniswebb /
Created Oct 11, 2016
Terraform template for deploying Swagger-UI to S3 website.
variable "region" {default = "us-west-2"}
variable "website_dns" {default = ""}
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 / DMX_ETH_17_Motor.cpp
Created Sep 19, 2016
Arcus Ethernet Motor Class based on QT
View DMX_ETH_17_Motor.cpp
* 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 /
Last active Aug 18, 2022
Ignoring migrations during Django testing (unmanaged databases, legacy databases, etc)


  • Django 1.9 application with two databases:
    • Legacy database with readonly access via unmanaged models. Both Django models ( 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

dahjelle /
Created Jul 13, 2016
Pre-commit hook for eslint, linting *only* staged changes.
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
awesomebytes /
Created Apr 6, 2016
Executing meshlab from commandline reduce faces of a mesh iteratively
#!/usr/bin/env python
import sys
import os
import subprocess
# Script taken from doing the needed operation
# (Filters > Remeshing, Simplification and Reconstruction >
# Quadric Edge Collapse Decimation, with parameters:
# 0.9 percentage reduction (10%), 0.3 Quality threshold (70%)
syafiqfaiz /
Last active Aug 9, 2022
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored