Skip to content

Instantly share code, notes, and snippets.

View prodeveloper's full-sized avatar

Jacob Chencha prodeveloper

View GitHub Profile
@prodeveloper
prodeveloper / django_urls.md
Created June 7, 2017 12:27
Introduction to URL Patterns in Django

##Introduction to URL patterns

Django has 6 major pieces

Url patterns are the first point of contact when a request comes in. The module evaluates the request and determines the appropriate view to handle it.

The view is in charge of handling the request and giving an output. For now our view is empty since we are not showing anything yet.

@prodeveloper
prodeveloper / more_on_models.md
Last active May 30, 2017 07:30
Expounding on Models

In the previous class we had a cursory introduction to models. We were able to create a Student model and register it.

There is a lot that we skipped in that process. In this class, we shall be looking at how we can better use models in our admin panel.

##Step 1

You may have noticed from last time that our model had a rather weird name on the django admin panel.

@prodeveloper
prodeveloper / django_models.md
Last active May 18, 2017 09:45
Working with Django models

In this class, we shall be interacting with Django's models. We shall see how we can create a data structure that then we can modify data in by using the built in admin panel

##Step 1

To start with we need to give our app firstapp a more meaningful name. Let’s say “akirachix”.

Update your settings file to reflect the new app.

@prodeveloper
prodeveloper / installing_django.md
Last active September 13, 2018 20:54
Installing Django on Cloud 9

In today's lesson we are going to look at installing django to cloud9.

Django is a web framework that will enable us to quickly write and deploy our web apps.

It's homepage defines it as:

    Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel.

Typically installations can be a bit painful involving setting up django and python involves a series of steps. Specifically

@prodeveloper
prodeveloper / introduction_classes.md
Last active May 16, 2017 06:37
Introduction to classes in Python

Python provides a rich set of data types and constructs to help you organize your code.

Of all of them, classes are one of the most potent.

Classes allow you to organize your code by packing related functionality and restricting operations that are possible on your data. This allows for great legibility to your code.

Let us start by looking at an example where we could write our code without using classes.

##Step 1

@prodeveloper
prodeveloper / sem_1_review.md
Created April 21, 2017 09:46
Review of semester 1

Through semester 1. We learnt all about the basics of Python.

In this lesson we shall go through some of the major areas we covered.

  1. Indentation: Python codeblocks are is organized using indentations. Examples of codeblocks include conditionals, loops, methods and classes.

  2. Conditionals: Inadvertently you will need to take a different execution path in your code due to a factor. Python allows you to do this by use of if, elif and else constructs. See https://gist.github.com/prodeveloper/a822dea2ad427dd502553d120b2e06f2

  3. Loops: What makes computers so powerful is their ability to do a task many times. Loop constructs such as while and for help us in this respect. See https://gist.github.com/prodeveloper/59c239c7885ef01c2788afd2d64ceb54

@prodeveloper
prodeveloper / guessing_game.md
Last active March 23, 2017 09:08
Simple guessing game python

As we end this semester, we will do so with building a small game.

The point of the game is to guess the number that the machine has. You will get feedback in terms of clues on how you are doing, either good or bad.

The requirements are:

    As a gamer I want the script to generate a random number between 1 and 100 which I don't know

    As a gamer I want the script to ask me for my own guess of the number, if am wrong, then I should be given a clue as to weather my guess is too high or too low.
@prodeveloper
prodeveloper / fetching_post.md
Last active March 16, 2017 09:44
Fetching post challenge

In this challenge we will be exercises our skills in:

  1. Using python libraries
  2. Using if constructs
  3. Using for construct
  4. Using methods

The requirement we need delivered is.

As a reader, I want the system to ask me for the post ID that am interestd in and then fetch the post for me.

@prodeveloper
prodeveloper / working_with_libraries.md
Last active March 14, 2017 06:24
Working with libraries

So far we have learned a lot about using the python api. While it is possible to build anything you want, most of the time it makes much more sense to resuse something that already exists.

Python comes prepackaged with a lot of libraries that offer common functionality https://docs.python.org/3/library/

Python's extensive library includes everything from mathematical functions to compression functionality.

For this class we shall be looking at the two most commonly used libraries, OS and Math. We shall also take a look at an important library for working with remote resources urllib.

##Step 1

@prodeveloper
prodeveloper / conditionals.md
Last active March 7, 2017 07:37
Working with if statements in python

We make choices in everyday life. Each choice takes us to a different branch of steps.

For example, you can chose to come by Matatu or by an Uber. Each choice has steps that follow naturally from it.

Computers can also be programmed to make choices. In python, this is done by using the if, elif* and else key words.

if some_true_value:
        ##Run some series of steps 
elif some_other_true_value: