Skip to content

Instantly share code, notes, and snippets.

Awake or Sleeping

Michael Bunsen mihow

Awake or Sleeping
View GitHub Profile
mihow /
Created Sep 8, 2017 — forked from awesomebytes/
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%)
mihow / config.yml
Created Nov 8, 2018
Create temporary migrations when deploying dev from CircleCi
View config.yml
# Dev only:
# Create migrations for any model changes that don't have migrations committed yet.
# Makes the migrations locally and push them up since we can't write files outside /tmp in Lambda
if [[ "${CIRCLE_BRANCH}" == "dev" ]]
python makemigrations --name ${CIRCLE_BRANCH}_`date "+%Y%m%d-%H%M%S"` --settings=app.settings.production
zappa update -s config/zappa_settings.json ${CIRCLE_BRANCH}
mihow /
Created Dec 7, 2018 — forked from miratcan/
Small python script that converts character sets to utf8 in all databases and tables. My solution for "Illegal mix of collations" errors. (
from MySQLdb import connect
conn = connect(user="[USER]", passwd= "[PASSWORD]")
cur = conn.cursor()
cur.execute("show databases;")
dbs_to_update = filter(
lambda db: db not in ('information_schema', 'mysql', 'performance_schema'),
[dbname[0] for dbname in cur.fetchall()])
mihow /
Created Dec 19, 2018
Set environment vars from a file
# Ignores commented out lines and handles spaces
export $(grep -v '^#' .env | xargs -d '\n')
mihow / auto_watch_releases_only.js
Created Jan 7, 2019
Change watch settings in Github to release-only in bulk
View auto_watch_releases_only.js
// By jonashaag
const child_process = require('child_process')
const puppeteer = require('puppeteer')
const devices = require('puppeteer/DeviceDescriptors')
const iPhone = devices['iPhone 6']
const USER = 'youruser'
const PW = 'xxxxxx'
mihow /
Last active Apr 7, 2021
Enable fuzziness for all Elasticsearch plaintext queries in Wagtail
"""Elasticsearch backend that enables fuzzy search to all plaintext queries."""
from import (Elasticsearch6SearchBackend,
class ElasticsearchQueryCompilerWithFuzziness(Elasticsearch6SearchQueryCompiler):
Copy of Elasticsearch6SearchQueryCompiler class with a modified default query.
Adds the "fuzziness" parameter to all queries so that we can return inexact
matches for misspellings, etc.
mihow /
Last active Jan 15, 2019
Test a URL in bash script and exit on failure or return failure exit code.
#! /bin/bash
set -o errexit
curl --fail --show-error --location > /dev/null
echo "It worked!"
curl --fail --show-error --location > /dev/null
echo "It failed, but you will never see this message."
mihow /
Last active Jan 28, 2019
Remove named docker volume in docker-compose project
#! /bin/sh
set -e
FULL_VOLUME_NAME=`docker inspect --format='{{range .Mounts}}{{.Name}} {{end}}' $CONTAINER_ID`
docker volume rm $FULL_VOLUME_NAME
mihow /
Last active Mar 1, 2022
Import existing PEM file as EC2 Key Pair with boto3 & paramiko
import os
import base64
import struct
import boto3
import paramiko
from paramiko.util import deflate_long
PEM_FILEPATH = '~/.ssh/test-key.pem'
mihow / gist:fe5fcf403a1da12052a4e62d49e05f53
Created Feb 21, 2019
Troubleshooting remote env vars
View gist:fe5fcf403a1da12052a4e62d49e05f53
# Send system env vars
python2 -c "import os, urllib; urllib.urlopen('https://NGROK_URL', data=urllib.urlencode(os.environ))"
# Send all running processes with arguments & env vars for process