Notes and anecdotes

Techstuff rambling

AWS rules of thumb notes

Load balancer + auto scaling EC2 instances in different Availability Zones is pretty fucking awesome. It allows you to auto scale = pay for what you need. It gives you uptime even if a whole availability zone goes offline. You can have SSL-termination in the Load Balancer. It’s nice. Use it. A set of servers in a…

Continue Reading

Add S3 bucket using awscli (example)

Here’s a simple step by step guide on how to create a s3 bucket, with an attached cloudfront and a user with write access. This is typically what you want if you need quick hosting for static files for you website. This is made in contrast to the terraform guide, which does the same, but using different tools If…

Continue Reading

Django on Heroku with AWS S3 bucket for static and media files

Case: You want efficient collectstatic and serving of files You want static files and media files to be hosted on an AWS S3 bucket. (optional) You have too many files for “normal” collectstatic to be efficient. (optional) You have a non-US S3 bucket. (optional) You use Heroku Disclaimer: Have not tested with python 2.7, can’t…

Continue Reading

Add S3 bucket using Terraform (example)

Edit: I was going to make the s3 bucket with cloudfront, but Terraform has no native support for it, though it looks like it’s coming soon. I’ll probably make a followup later. Edit 2: I made a followup on how to do it with Cloudfront A concrete, developer friendly guide on how to create a proper s3 bucket with…

Continue Reading

curl headers only

How to grep only the response headers

Show environment variables in Heroku

I was looking for WEB_CONCURRENCY environment variable on my Django-app. This is used for the number of concurrent webworkers for gunicorn, and is automatically scaled depending on the memory usage of your app. Do it with the toolbelt, and command heroku run printenv –app your-app-name | grep WEB_CONCURRENCY Read more on optimizing your app here

Monitor-driven development

Monitor-driven or Metric-driven development (MDD). It’s becoming more and more relevant parallell with continuous delivery, devops etc, and I think it’s super awesome. Stop finding bugs. Instead, log properly, and monitor where and in what situations error logs are being created. Has there been a sudden increase in a certain type of errors? Get told! Stop checking if…

Continue Reading

The easy way of sending newsletter emails

I’ve been working a bit with automatic emails, newsletter etc. lately. And if there’s one thing I have to say, it would be: FUCK OUTLOOK. I’ve spent so much time doing stupid style changes for an html email to look nice in Outlook 2011, Outlook Web App and Outlook 2013. It’s like they render html mails with three completely different…

Continue Reading

Django + Heroku bootstrap

It has happened on more than one occasion that I want a new Django project, with Grunt, jQuery, Bootstrap, Font-Awesome etc, deployed on Heroku. So I decided to write down the steps, and made a bash script to automate it all for me.

Running Django with nginx (on webfaction)

Case: You’re using virtualenv and have used apache with a config somewhat like this. Problem: Apache ‘goes to sleep’ Apache caches your wsgi application, and if it’s not used within a certain amount of time, it has to reload. And this takes like.. 10-15 seconds. Solution: Use nginx instead: Set up a custom application, and install nginx + uwsgi to point to…

Continue Reading

Get python, pip, virtualenv without sudo

Case: You don’t have sudo and life is awful on a cheap VPS or similar. Step 1: Get your desired python version Python 2.7 cd mkdir python cd python mkdir src cd src wget tar xvfz Python-2.7.3.tgz cd Python-2.7.3 mkdir ~/python/python27 ./configure -prefix=/home/username/python/python27 make make install cd echo “export PATH=$HOME/python/python27/bin” >> .bashrc source .bashrc…

Continue Reading

pip on python3: Can’t decompress data; zlib not available

Getting pip3.4 to work Want Python3.4 on your debian with virtualenv and pip? That’s what I wanted. However, I didn’t get pip automatically, and when I tried to install it, python gave me “Can’t decompress data; zlib not available” Spent a whole lot of time on this. Seems like installing 3.4 properly (with –with-zlib parameter when configuring) makes…

Continue Reading

1 2