Python Posts

166 posts tagged with python

There a few options, but I'm going to suggest using the inthing Python module.

First install inthing with PIP. You'll probably know if you need to use sudo or not:

Now fire up Python, and enter the following (copy and paste each line after the >>> prompt):

So far so good. We now have a Stream object called stream, with a corresponding live page on the web. We'll have a look at that later, but lets first do something interesting with it. Enter the following function (copy and paste all the text after the >>>):

If that pasted correctly, we should have a function that generates the Mandlebrot set in ASCII. Add it to the stream with the following:

Finally, to get the URL of the stream, do this:

If you visit that URL, you should see the Mandlebrot set you just generated. continue reading…

I'm happy to announce release 0.6.0 of Moya.

Moya is a web-application platform written in Python. In that respect it is a lot like other Python frameworks such as Django, Pyramid, Flask, Bottle etc. Moya has versatile URL routing, a fast template language, an ORM, a forms library, i18n support, image processing, and a variety of other tools to build a modern web app. Where Moya differs from other Python frameworks in that Python is not required to make use of these features. continue reading…

Raspberry Pis are useful little computers. I own several, since I work with them in my day job, and I thought it was about time I put one to use.

I also happen to keep tropical insects. Specifically, beetles. These are not your garden variety beetles, unless you happen to live in a rain forest. The ones I have at the moment are elephant beetles which come from Central and South America. Here's a photo:

Male elephant beetle. Banana for scale.

These insects are mostly nocturnal. During the day they tend to burrow under their bedding material (moss), or hang out on a branch. But during the night, they can be quite active. I know this because in the morning they have re-arranged the branches in their tank. continue reading…

A quick way to get Moya Techblog up and running (or just to test it) is to deploy it with Heroku.

If you click the following button, it will deploy Techblog on a public server:

When that's done you should have a working version of this site (sans my content obviously). It's remarkably easy to customize if you aren't happy with my coder design skills.

There is one caveat you should be aware of; Heroku has an ephemeral filesystem, which basically means that your uploaded files will disappear after a while. That is bit of a deal-breaker for a site designed for photography, but there is a solution. You can host your uploads with Amazon S3.

To use Amazon S3 with Techblog, set the following environment variables (you will have a chance to edit these when you deploy): continue reading…

I've had a blog on my vanity domain for nearly a decade now. For the last 6 years, it has been powered by Django Techblog, which I wrote out of my frustration with syntax highlighting plugins in Wordpress. Techblog has happily served my blog those 6 years, with only minor hiccups when I half-heartedly ported the code to the latest Django.

There was nothing terribly wrong with Django Techblog; it had multiple blogs, tags, search etc., but there were some annoyances that I didn't have the motivation to do much about. The custom markup system I used was clever, but I would often forget the syntax! The support for images was rudimentary and the single-threaded comment system wouldn't notify me of replies. continue reading…

My client, WildFoundry, is looking for an experienced Python developer to join us. We work in the field of IoT, and you will get to work with a variety of really cool technologies. Here's the job description:

WildFoundry is seeking a senior Python web application developer on a 8 month contract to help us in the development of the dataplicity Internet-of-Things platform (dataplicity.com). You would be expected to work from your home or own office most of the time and very high quality candidates based in Slovakia, Poland and the United Kingdom will be considered.

This is an unbeatable opportunity to work from home, earn excellent rates and join in with fast growing projects. continue reading…

This screencast demonstrates how to build a database driven, Markdown powered wiki from scratch in around 25 lines of code. Lines of code is of course a poor metric, but I think the end result of part 1 (more planned) packs quite a lot of functionality for what is very simple and readable code. I'll be building on this code in future screencasts, to create something which is more feature complete.

I found creating this to be a challenge; thinking, typing and talking is about 50% more things than I can do at once! Hopefully I'll master it as I go.

For more information on Moya, please see www.moyaproject.com.

Today I released v0.5.14 of Moya, my no-Python Python web framework.

The no-Python probably needs some explaining… Moya is written in Python, and can be extended in Python, but runs web applications written in an interpreted language called Moya code (name is uninspired, I know).

This release was primarily driven by development of Bean Counter, a web app that manages virtual currency. Essentially it's online banking for internet based ‘money’, intended for use as a community currency.

In tandem with this release I've also added a couple of re-usable libraries which, I think, add a significant amount of value to Moya. The first is Moya Logins which creates OAuth Sign In buttons, i.e. Sign In with Google etc. The second is Moya Auto, which adds AJAX powered auto-completion to form inputs. continue reading…

I have a webserver with 3 WSGI applications running on different domains (1, 2, 3). All deployed with a combination of Gunicorn and NGINX. A combination that works really well, but there are two annoyances that are only going to get worse the more sites I deploy:

A) The configuration for each server resides in a different location on the filesystem, so I have to recall & type a long path to edit settings. continue reading…

Google Analytics and kin are great for getting stats on your visitors, but often I simply want to know: who is linking to my site? You can deduce this from web server logs, but server logs tend to be too noisy and a make it hard to pick out the referer URLs.

Moya doesn't have a stats library yet, but it's not hard to MacGuyver up a solution to log incoming links. We need to run some code on every request so that we can detect the referer and write a log message. The simplest way to do that is to create a <url> tag with a wildcard route of “/*”. We can add this <url> to the mountpoint of the site library (the site library is where we customize various aspects of the site). Here's the code:

Yes, referer is a misspelling, but it has been codified in to the http spec! continue reading…