Skip to content

Instantly share code, notes, and snippets.

View Ivaylo-Bachvarov's full-sized avatar

Ivaylo Bachvarov Ivaylo-Bachvarov

View GitHub Profile

Cookiecutter Django Ansible

More automation, more time for beer! 🍺

What is Ansible?

Ansible is an open source automation platform. It is the simplest solution out there but it is very powerful. You can use Ansible to manage your infrastructure, deploy your application, and automate tasks. It is so simple that their motto is: "Automation for everyone!"

So if you are tired of setting up VPSs manually you should definitely consider an automation framework like Ansible, Puppet or Chef.

Why are we using it?

Django is a great framework when it comes to productivity. But what happens when it comes to deployment on a VPS? Who is going to setup the infrastructure and how? Do we really have to deal with all the postgresql configuration, the NGINX files, the upstart jobs that keeps our gunicorns alive? :(

@Ivaylo-Bachvarov
Ivaylo-Bachvarov / tasks.md
Last active February 28, 2017 12:39
Dimitar's Python Tasks

Decorator Problems

@accepts

Make a decorator accepts that takes as many arguments as the function takes. That decorator specify the types of the arguments that your function takes. If any of the arguments does not match the type in the decorator raise a TypeError

Examples

@accepts(str)
def say_hello(name):
 return "Hello, I am {}".format(name)
Question:
- id
- title
Choises
- id
- question-id
- text
import unittest
import github
from mock import patch, Mock
from github import Github, GithubException
def is_valid_repo(user_name, repo_name):
github_client = Github("TOKEN_HERE")
try:
api_user = github_client.get_user(user_name)
import unittest
import github
from mock import patch
from github import GithubException
def is_valid_repo(github_lib, user_name, repo_name):
github_client = github_lib("TOKEN_HERE")
try:
api_user = github_client.get_user(user_name)
import unittest
from mock import patch
from github import Github, GithubException
def is_valid_repo(Github, user_name, repo_name):
github_client = Github("TOKEN_HERE")
try:
api_user = github_client.get_user(user_name)