Sometimes you’re super eager to get started with a new project! Seems easy – you set up a git repo, use
django-admin startproject to generate an empty project, start adding dependencies… You want to use Django REST framework for the API, so you install that. Then you need to connect Postgres for the database… Oh, but you want to deploy to Heroku, so you need to configure that DATABASE_URL environment variable and hook that up in settings.py – there was that one project where we had that working already, we can copy/paste it for sure… Celery for async tasks… Redis… 😴… Wait, what were we building again?
If the scenario described above sounds familiar, then like me you’ve run into the problem of boring, repetitive and uncreative work necessary to set up a modern web app project. A lot of boilerplate is needed to get a basic project working and best practices keep changing. Sure, there are solutions like cookiecutter-django which is quite nice, but with ~40 requirements spread across 3 files and ~500 lines of settings spread across 4 files it might be overkill when you’re just getting started. More importantly, while cookiecutter is great for initial project generation, it doesn’t allow you to easily update a project afterwards. Regenerating the project, even when exactly the same prompt answers are selected results in “Error: “my_awesome_project” directory already exists”. As already stated, best practices change over time and it would be useful to have an easy way to update your project boilerplate occasionally.
Continue reading Deploy a Django REST API to Heroku in 5 minutes
If you’re a designer using the Sip for Mac app to pick colours, you might find this format useful. I call it the “web designer hex”. Hex is probably the easiest format to use in your CSS files and different applications for simple copy-pasting. Still, when you’re picking colours off of your inspiration sources for examination, it’s easier to think in the HSB colour system. As Erik D. Kennedy puts it, a strong HSB advocate and author of excellent articles on design puts it:
Therefore, I set this format up to display additional hue, saturation and brightness values when I have the magnifier open and only copy minimalist hex value into the clipboard (#E05049 in this case).
You can import this format by downloading and opening this file. If you prefer to manually set it up, click on the Sip icon in your toolbar, select the format chooser and click on the big “+” icon to create a new format. Once in there, give it a simple title (e.g. “web designer hex”) and enter this simple snippet as your Clipboard format.
Continue reading A useful Sip colour picker format
Yesterday, we had our first after-summer Zagreb Freelancers Meetup in the BIZkoshnica coworking space. The topic was how to go about founding a company, what are the administrative steps, which form to choose and what are the advantages and disadvantages. We covered a lot of interesting points, so I wanted to summarise the most important stuff. The event itself is a part of the European Freelancers Week and you can find some more related events around Europe.
One thing I recommend from my experience of running a web development business for a few years now is to get all this administrative, bureaucratic stuff done as quickly as possible and try to get it out of the way as much as you can. Your primary concern should always be your core business – the work you do for your client, your product, your team. Try to outsource administrative services to experts, i.e. accounting, legal and you focus on your business. Of course, don’t oversimplify – do your homework and inform yourself beforehand to pick the right company form and know the risks and liabilities.
Continue reading Administrative aspects of freelancing from Croatia
OK, so TensorFlow is the popular new computational framework from Google everyone is raving about (check out this year’s TensorFlow Dev Summit video presentations explaining its cool features). Of course, a fun way to learn TensorFlow is to play with it on your own laptop, so that you can iterate quickly and work offline (perhapse build a hot dog recognition app). In these cases a GPU is very useful for training models more quickly. There used to be a tensorflow-gpu package that you could install in a snap on MacBook Pros with NVIDIA GPUs, but unfortunately it’s no longer supported these days due to some driver issues. Luckily, it’s still possible to manually compile TensorFlow with NVIDIA GPU support. I’ve hunted through a lot of different tutorials (1, 2, 3, 4 – this last one helped me the most) to bring you this hopefully complete description of how to set everything up correctly and get deep into learning (and I know, in 2 months probably become just another one in that list of outdated tutorials, but that’s life 🙂 ).
For the sake of verbosity, I’m using a MacBook Pro 10,1 with an NVIDIA GT 650M and OS X 10.12. Hopefully, though, it will work on a couple of other configurations as well. In any case, let’s start…
Continue reading Compiling TensorFlow with GPU support on a MacBook Pro
This post was adapted from my Stack Overflow answer to a question about using single page applications (SPAs) with Django on Heroku.
Update: check out my django-spa package for a ready-to-use solution for serving SPAs from Django.
Here’s how to set up Django to serve your static files and index.html on / while still having the possibility to use Django views for the admin dashboard, registration etc.:
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.views import serve
from django.views.generic import RedirectView
urlpatterns = [
# / routes to index.html
# static files (*.css, *.js, *.jpg etc.) served on /
# (assuming Django uses /static/ and /media/ for static/media urls)
# other views still work too
Continue reading Simple way to set up Django and a SPA frontend on Heroku