Skip to content

Instantly share code, notes, and snippets.

@roadsideseb
roadsideseb / 01 🐍 load testing with gatling.md
Last active April 1, 2023 14:33
Load testing Python web apps with Gatling

Results

These results are generated by a gatling simulation that ramps 100 user over 10 second and then keeps the users constant at that rate for 60 seconds before ramping again by 100 users. The entire scenario runs from 0 to 1000 users.

Flask

@roadsideseb
roadsideseb / async_schedule.py
Last active August 11, 2022 09:49
A slightly modified version of the 'schedule' Python package that works with asyncio 😎
import emoji
import schedule
import asyncio
import inspect
from datetime import datetime
class Job(schedule.Job):
@roadsideseb
roadsideseb / xvfb-run.sh
Last active June 15, 2019 20:41 — forked from tyleramos/xvfb-run.sh
XVFB Run Bash script
#!/bin/sh
# $Id: xvfb-run 2027 2004-11-16 14:54:16Z branden $
# This script starts an instance of Xvfb, the "fake" X server, runs a command
# with that server available, and kills the X server when done. The return
# value of the command becomes the return value of this script, except in cases
# where this script encounters an error.
#
# If anyone is using this to build a Debian package, make sure the package
@roadsideseb
roadsideseb / edit.py
Created April 9, 2013 08:42
MultiFormView for handling multiple forms in a Django CBV with a little more ease...
"""
The following mixins and views are borrowed and adapted from the following
gist:
https://gist.github.com/michelts/1029336
"""
from functools import partial
from django.views.generic.base import TemplateResponseMixin
from django.views.generic.edit import ProcessFormView, FormMixin
@roadsideseb
roadsideseb / python_job_sites.md
Last active April 4, 2018 10:44
Job sites for Django and Python developers
@roadsideseb
roadsideseb / views.py
Created January 30, 2014 23:16
Packing slips for Oscar using PISA in the dashboard
from xhtml2pdf import pisa
from xhtml2pdf.pdf import pisaPDF
class OrderListView(ListView, BulkEditMixin):
...
actions = (
'generate_packing_slips',
...
@roadsideseb
roadsideseb / docker_run.sh
Created March 16, 2015 21:53
Start a container on elastic beanstalk with the full configuration provided in the deployment script(s).
#!/usr/bin/env bash
set -e
. /opt/elasticbeanstalk/hooks/common.sh
# switch to current app directory
cd $EB_CONFIG_APP_CURRENT
# Dockerrun.aws.json can override settings in Dockerfile
echo "Reading settings from Dockerrun.aws.json"
@roadsideseb
roadsideseb / base.html
Created February 2, 2014 23:56
Oscar packing slip / invoice templates using pisa.
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@page {
size: a4 portrait;
margin: 1cm;
margin-left:2cm;
margin-right:2cm;
@roadsideseb
roadsideseb / docker_commands.sh
Last active July 17, 2017 16:51
A few handy Docker commands
# Delete all stopped containers
docker rm $(docker ps -a -q)
# Remove unused, dangling images
docker rmi $(docker images -q -f dangling=true)
# Remove all but X images with a specific name (old image cleanup),
# in this case, we leave the 2 newest images.
$(docker images | grep my-docker-image | tail -n+3 | awk '{ print $1":"$2; }')
#!/bin/bash
set -ex
pip_args=${@:-"--help"}
apk add --no-cache \
--virtual .build-deps \
gcc \
g++ \
make \