Main Site

This is Gem Newman's blog. Return to the main site.

Quotation

Showing posts with label geekery. Show all posts
Showing posts with label geekery. Show all posts

16 October 2017

LUEE Episode 125: Revenge of the Quiz Show Show!

On this episode of Life, the Universe & Everything Else, recorded live at SkeptiCamp, Ashlyn, Lauren, Laura, and Gem test their knowledge (and that of the audience) in a variety of scientific and pseudoscientific domains.

Life, the Universe & Everything Else is a podcast that delves into issues of science, critical thinking, and secular humanism.

Colour Quiz (Ashlyn): Impossible color (Wikipedia) | Rayleigh scattering (Wikipedia) | Indigo dye (Wikipedia) | Verdigris (Wikipedia) | Orpiment (Wikipedia) | Red hair (Wikipedia)

Discarded Scientific Theories (Gem): Superseded scientific theories (Wikipedia)

The Magic of Crystals (Lauren): Crystal Healing: Stone-Cold Facts About Gemstone Treatments | Crystal Guide (Crystal Vaults) | A to Z Crystal Meanings (CrystalsandJewelry.com) | The 8 Essential Crystals (Goop)

Historical Food Guides (Laura): Government Health Posters: A History of Nutrition Guidelines (PlenteousVeg) | Food and Nutrition through the 20th Century (LibGuides) | Canada's Food Guides from 1942 to 1992 (Canada.ca) | How WWI Food Propaganda Forever Changed the Way America Eats (The A.V. Club) | Food for Young Children (Digital Library) | Dietary Recommendations and How They Have Changed Over Time (USDA) | The History of USDA Nutrition Guides (FoodManufacturing.com) | How to Select Foods, by Caroline L. Hunt and Helen W. Atwater (Archive.org)

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | Apple Podcasts | Google Play | Stitcher | RSS Feed

11 September 2017

LUEE Episode 124: Ancient Discoveries

On this episode of Life, the Universe & Everything Else, Gem, Ashlyn, Laura, and Lauren discuss several important scientific, technological, and mathematical discoveries made in the ancient world.

Life, the Universe & Everything Else is a podcast that delves into issues of science, critical thinking, and secular humanism.

Note: We experienced some technical difficulties near the top of Ashlyn's segment, so listeners may notice a brief drop in audio quality. Sorry!

Links: History of the compass (Wikipedia) | The Shorter Science and Civilisation in China (Joseph Needham and Colin A. Ronan) | Geomagnetic reversal (Wikipedia) | Formation of the Chinese Civilization (china.org.cn) | Contribution of Al-Khwarizmi to Mathematics and Geography (Muslim Heritage) | Muhammad ibn Musa al-Khwarizmi (Wikipedia) | Al-Khwarizmi biography (History
of Mathematics Archive)
| Al-Khwarizmi (The Story of Mathematics) | Who Invented Zero? (Live Science) | 0 (Wikipedia) | The Origin of Zero (Scientific American) | What is the origin of zero? How did we indicate nothingness before zero? (Scientific American) | Who invented the zero? (History.com) | Zero (History of Mathematics Archive) | The Origin of the Number Zero (Smithsonian) | Who invented zero and how? (Quora) | Babylonian numerals (Wikipedia) | Jabir ibn Hayyan (Wikipedia) | History of Science and Technology in Islam | Chemistry (Islamic Spain) | From Alchemy to Chemistry (Muslim Heritage) | Aqua regia (Wikipedia) | History of glass (Wikipedia)

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | Apple Podcasts | Google Play | Stitcher | RSS Feed

30 May 2016

tread

I made a thing. It's called tread, and it's a simple terminal RSS feed reader that I wrote in Python.


tread has most of the basic features you would expect from a feed reader, including read/unread tracking and starred items. It even supports displaying images via imgii. And if you don't mind fiddling with a YAML file, it's also fairly configurable.

Since it's available on PyPI, installing tread is actually pretty easy:

pip3 install tread

The source code, along with the readme and basic usage instructions, is available here. (But fair warning: the code is awful, and you don't want to look at it too closely.) I do not guarantee it to be bug-free (in fact, I guarantee the opposite!), but if for some reason you want a Google Reader replacement that runs in a terminal window, I've got you covered.

Because of some esoteric requirements of curses (the most aptly named library, as bcj is fond of pointing out), tread requires Python 3.5 and does not run natively on Windows.

23 April 2016

Mario Maker: Jumpman

Occasionally I have time to make levels in Mario Maker.

Bookmark: 598D-0000-022A-FDA1
Style: New Super Mario Bros.
Quality: ★ ★ ★ ☆
Difficulty: 👿
Secrets: 👻 👻

A quick, fun level that's not too challenging (unless you try to beat it without touching the ground).

06 February 2016

Mario Maker: Spooky!

Occasionally I have time to make levels in Mario Maker.

Bookmark: 4C6D-0000-01E9-6D6C
Style: Super Mario Bros.
Quality: ★ ★ ★ ★
Difficulty: 👿 👿 👿 👿
Secrets: 👻 👻 👻

I made this level with my friend bcj in mind, because he loves 👻s. It's probably pretty tough, and there are lots of secret hidden things, as befits a ghost house.

Mario Maker: You Chose... Poorly

Occasionally I have time to make levels in Mario Maker.

Bookmark: A4B3-0000-0072-F358
Style: Super Mario World
Quality: ★ ★ ★ ☆
Difficulty: 👿 👿
Secrets: 👻

A level in which Mario must descend deeper and deeper. It's fairly straightforward, but there are some fun surprises.

Mario Maker: Ceci n'est pas une pipe

Occasionally I have time to make levels in Mario Maker.

Bookmark: 76BA-0000-007F-8E88
Style: Super Mario 3
Quality: ★ ★ ★ ★
Difficulty: 👿 👿 👿
Secrets: 👻 👻

I always loved pipe-heavy levels, and I wanted to make something that was like World 7-6 in Super Mario 3. Vertical levels aren't really possible in Mario Maker, but I'm proud of the fact that I made it almost work.

Mario Maker: Chateau Niveau

Occasionally I have time to make levels in Mario Maker. They're not as good as Eevee's.

Bookmark: BB33-0000-004C-F132
Style: Super Mario World
Quality: ★ ★ ☆ ☆
Difficulty: 👿 👿 👿 👿
Secrets: 👻 👻

The first real level that I made. It's a little more difficult than I intended, but it's fun and fast moving.

14 September 2015

LUEE Episode 100: Silly Pseudoscience Special!

In this episode of Life, the Universe & Everything Else, Gem discusses silly pseudosciences and conspiracy theories with Ashlyn, Laura, Ian, and Lauren, then caps off the episode by interviewing panelists past and present about their favourite episodes, the future technologies they're most excited about, and whether they'd rather live next door to Ray Comfort or Deepak Chopra.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism that is produced by the Winnipeg Skeptics.

Links: List of topics characterized as pseudoscience (Wikipedia) | Biodynamic agriculture (Wikipedia) | Pyramid power (Wikipedia) | SECRET POWER of PYRAMIDS | Pyramid Power | Organic/Biodynamic (Summerhill Pyramid Winery) | The Pyramid (Summerhill Pyramid Winery) | Paul is dead (Wikipedia) | Paul McCartney Really Is Dead: The Last Testament of George Harrison (IMDb) | Nazi UFOs (Wikipedia) | Space Nazis (Wikipedia) | Did the middle ages not really happen? (The Straight Dope) | Phantom time hypothesis (Wikipedia) | New Chronology (Wikipedia) | Dietitian at Home

Favourite Episodes: Episode 29: Zombies, Part 1 | Episode 32: Zombies, Part 2 | Episode 40: Skepticon 5, Part 1 | Episode 42: Skepticon 5, Part 2 | Episode 59: Organic Agriculture | Episode 60: "Frankenfoods" | Episode 72: The War on Christmas: A Brief History | Episode 74: Nutritional Supplements | Episode 77: Coffee & Tea | Episode 79: The Historicity of Jesus | Episode 88: Experimenting on Your Thoughts | Episode 90: "Resonance: Beings of Frequency" | Episode 91: Straight, White Christmas | Episode 97: Labels

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | Google Play | Stitcher | RSS Feed

27 March 2015

Pi Day Trivia

On 14 March 2015 the Winnipeg Skeptics held a Pi Day celebration, which featured games, trivia, and lots and lots of pie.

Since not everyone could make it out and people seem to like this sort of thing, here's some pi- (and pie-) related trivia!

Question One
In the Star Trek episode "Wolf in the Fold", the Enterprise’s computer (spoiler alert) becomes possessed by the spirit of Jack the Ripper. (God, Star Trek was dumb sometimes...) How does Spock foil the evil computer? (Answer)

Question Two
The digits of pi go on forever in a seemingly random sequence, meaning that it falls into which class of numbers? (Answer)

Question Three
Who said, "If you wish to make an Apple Pie from scratch, you must first invent the universe"? (Answer)

Question Four
While pi is popular, a minority of mathematicians argue that a constant equal to 2Ï€ would make for a better circle constant, for a host of (I think very convincing) reasons. What do they call their "2Ï€" constant? (Answer)

Question Five
How long has the Greek letter "Ï€" been used to represent the circle constant? (Answer)

Question Six
This successful World War II operation, which involved persuading the Germans that the Allies planned to invade Greece by planting fake war plans on a corpse in Spain, was named after a suet pie. (Answer)

Question Seven
Pi Day (14 March) is also the birthday of which famous physicist? (Answer)

Question Eight
According to a band member, a vision involving a man atop a flaming pie influenced a famous band’s name. Which band? (Answer)

Question Nine
Some of the earliest attempts to understand pi involved trying to do something that has now become a euphemism for a hopeless or impossible task. What is it? (Answer)

Question Ten
In 2005 the world record for memorizing the digits of pi was claimed by Chao Lu, a Chinese engineering student. How long did he spend reciting pi? (Answer)



I was going to have some questions about radians, but I couldn't figure out how to formulate them in a way that was remotely entertaining. So... there aren’t any. You're welcome.

Answer One
He instructs it to compute pi right down to the last digit, a task that it can never complete.

Answer Two
Irrational numbers

Answer Three
Carl Sagan

Answer Four
Tau. Pi is defined as the ratio of a circle’s circumference to its diameter; but it’s often written as the ratio of a circles circumference to double its radius (remember C = 2Ï€r?). Tau is the ratio of a circle’s radius (rather than circumference) to its diameter, and it simplifies many common mathematical formulae.

Answer Five
About 300 years. It was William Jones who chose the Greek letter "Ï€" to represent the circle constant in 1706. This choice was later popularized by Euler. Before the symbol's introduction, mathematics was a lot wordier, involving things like, "let x be the quantity which, when the diameter is multiplied by it, yields the circumference".

Answer Six
Operation Mincemeat, which was a British disinformation plan that persuaded Germany that they had accidentally intercepted "top secret" Allied documents. These plans were attached to a corpse deliberately left to wash up on a beach in Punta Umbría in Spain, and served to cover the actual Allied invasion of Italy from North Africa.

Mincemeat itself is a mixture of chopped dried fruit, distilled spirits and spices, and sometimes beef or suet. Originally, mincemeat always contained meat, but this is no longer the rule.

Answer Seven
Albert Einstein

Answer Eight
The Beatles. In a 1961 interview with Mersey Beat, John Lennon told the following story: "It came in a vision – a man appeared on a flaming pie and said unto them, 'From this day on you are Beatles with an A.' And so we were."

Answer Nine
Squaring the circle. That is to say: constructing a square with the same area as a given circle using only a compass and straightedge.

Answer Ten
24 hours (and 4 minutes). So if you spent Pi Day eating pie, or doing anything at all other than reciting numbers, be grateful. In 2005, Chao Lu recited 67,890 digits of pi correctly, claiming the previous record from Hiroyuki Goto of Japan. Goto’s record was 42,195 digits. How useful is this? Well, for comparison, you could compute the circumference of a circle around the known universe with an error no greater than the radius of a hydrogen atom using only 39 decimal places.

20 February 2015

Configuring Flask, uWSGI, and Nginx (Updated!)

This is an updated version of a previous post, which is preserved here.


In a departure from what I often write about, I'm going to talk a little bit about something that is tangentially related to what I actually do for a living: running a web server. So I'm going to give a brief tutorial on setting up uWSGI (in Emperor mode) and Nginx so that you can run one or more Python Flask instances on a server.

Installation
Flask
uWSGI
Nginx
Port Forwarding
Sources

Why? Well, I'm far from a pro at anything related to networking or web development, but I have been writing a few web tools lately just for fun. Initially, I had several different Flask/Werkzeug instances running in what was essentially a dev mode on different ports on my server, and I had each of these ports forwarded. But...


...this was ungainly, running multiple Werkzeug instances was inefficient, I didn't want to have to forward all of those ports, and damn it, I wanted to do things right. But, as this isn't my area of expertise, it took me a while to put all of these pieces together, because many of the examples that I was able to find were light on the details. I'm putting this here in the hope that someone else in my situation might find it useful.

Installation

So here are the relevant details. I'm running Ubuntu 14.04 and I'm using Python 3.4 (and 2.7.9), Flask 0.10, uWSGI 2.0.9, and Nginx 1.1.19. If you are missing any of these, you'll want to install them with your package manager of choice.* For example:

$ sudo apt-get install python
$ sudo apt-get install uwsgi
$ sudo apt-get install nginx
$ pip3 install flask

Some caveats: First, if you're running Python 2.x, you'll want to ensure that Flask is available for it, as well. (You can try pip install flask, depending on your configuration.) Second, if you're planning to run multiple Flask applications using multiple versions of Python, you may have to build uWSGI core from source and specify which Python plugin to use for each application. Building uWSGI from source isn't the worst thing in the world; instructions for building the application and the necessary plugins are available here.

The goal here is to run multiple Flask servers on one machine without having to worry about port numbers and the like. We'll start with just one, and I'm sure that you can figure the rest out from there.

Flask

First you need a Flask application to run. How about this one? I wrote it a few months ago because I wanted to translate GET requests to POST requests. (At the time that I'm writing this, that particular application hasn't been updated to use Python 3.)

Navigate to the directory you'd like to install it to (probably /opt/ or /var/www/), then clone it. You'll want to verify that it runs locally on its own first.

$ cd /opt
$ git clone https://github.com/spurll/post.git
$ post/run.py

In a web browser on the same server, navigate to http://localhost:9999 and verify that the application is accessible. If you're running headless (as I am) you can always spawn the process to the background with post/run.py & and then curl localhost:9999 and verify that you don't get an error back. You can now kill the Python process.

Flask is now set up!

uWSGI

First, test that uWSGI will run your application correctly on its own:

$ cd /opt/post
$ uwsgi --socket 127.0.0.1:9999 --protocol=http -w run:app

In this case, run is the name of the Python source file that contains our application (/opt/post/run.py) and app is the name of the Werkzeug/Flask application object contained in that file. Verify that the application is accessible again from http://localhost:9999 as above.

If everything is working correctly, kill the uWSGI instance. It's now time to configure uWSGI's Emperor mode. This allows us to essentially have one master process that oversees all of our web applications, starting (and restarting) them when needed and logging as appropriate. You will probably have to install a few plugins, too, using your package manager of choice. (Note that if you want to support multiple Python versions, you may need to build these plugins from source, as mentioned above.) Assuming you want to use the standard plugins:

$ sudo apt-get install uwsgi-plugin-python
$ sudo apt-get install uwsgi-plugin-http

By default, your uWSGI master configuration file will probably be located at /etc/init/uwsgi.conf. Edit it with your editor of choice (I'm a Vim guy, myself):

$ sudo vim /etc/init/uwsgi.conf

It should look something like this:

description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn

env UWSGI=/usr/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log

exec $UWSGI --master --emperor /etc/uwsgi/apps-enabled --die-on-term --uid www-data --gid www-data --logto $LOGTO

You can change the location of the Emperor's log file by changing the LOGTO environment variable. You can also modify which user (--uid) and group (--gid) the Emperor will run as.

Now it's time to configure the applications. Your application-specific configuration files (in this case, for the POST program that we installed to /opt/post/) will probably be found at /etc/uwsgi/apps-available/. Create a new file there and call it post.ini. It should like something like this:

[uwsgi]

# Variables
url_mount = /%n
base = /opt/%n
app = run
callable = app

# Plugins
plugins-dir = /usr/lib/uwsgi/plugins
plugins = python,http

# URL Script Mounting
mount = %(url_mount)=%(base)/%(app).py
manage-script-name = true

# Generic Config
pythonpath = %(base)
venv = %(base)/venv            # If using virtualenv
socket = /opt/run/%n.sock
module = %(app)
logto = /var/log/uwsgi/%n.log

Here, url_mount is the mount-point for the application (for example, if you're running the application at http://www.yourserver.com/post, the value would be /post), base is the base directory of our application (the directory that contains the module we want to run), app contains the name of the module to run (in this case run, for run.py), callable is the name of the Werkzeug/Flask callable application object (if you don't supply this, uWSGI will assume that it's called application), and socket defines the location of the socket you'd like Nginx to use when communicating with your uWSGI server. The %n references the name of our file (sans extension) to maintain consistency.

You'll need to ensure that the location of your sockets (in this case, /opt/run/) exists and that the appropriate user (in this case, www-data) has write permissions.

This configuration assumes that you want to run your program using the modules installed on your system's Python. Plugins might prove to be an issue. You'll want to point plugins-dir to the appropriate path, and make sure that you have the appropriate plugin. If you're running Python 3.x (or you want to specify a specific Python plugin for uWSGI for some other reason), you can point plugins at something like python34 (which you may have to build) instead.

To run the application in a virtual environment, you can add a line defining home:

home = %(base)/virtualenv

Where virtualenv is the directory containing the Python virtual environment you'd like to use. (In our case, that would be at /opt/post/virtualenv/, if we were using a virtual environment.)

Once you're ready, create a symbolic link to place the post.ini file you've created in the apps-enabled directory:

$ sudo ln -s /etc/uwsgi/apps-available/post.ini /etc/uwsgi/apps-enabled/post.ini

You can start the uWSGI process (if you haven't already) like this:

$ sudo service uwsgi start

As soon as your Emperor process sees an application configuration file in apps-enabled it will start up a uWSGI instance to serve requests for that application. If you'd like to set up additional Flask applications at this time, simply install them and create uWSGI configuration files for each (and don't forget to link them to apps-enabled!). If you're having trouble, take a look at the logs (which are probably in /var/log/uwsgi/).

The uWSGI Emperor is now set up!

Nginx

We're almost there!

The default configuration file for Nginx should be located at /etc/nginx/sites-available/default. Feel free to edit this one, or create your own. By default, Nginx will point requests on port 80 (the default HTTP port) to /usr/share/nginx/www. If you'd like to point them somewhere else (such as /var/www/) you can change that here. Here's a brief Nginx configuration file that you can use to run connect your uWSGI server to the outside world:

# server unix:///path/to/your/site.sock; # For a file socket.
# server 127.0.0.1:9999;                 # For a port.

upstream post {
    server unix:///opt/run/post.sock;
}

server {
    listen 80;
    server_name your.server.url;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    root /var/www;
    index index.html index.htm;

    # GET to POST
    location /post {
        include uwsgi_params;
        uwsgi_pass post;
    }
}

Replace your.server.url with the URL for your server (you can use localhost for testing purposes). This configuration assumes that you'd like your application to be accessible at http://your.server.url/post. If you'd like it to take the place of the main page at http://your.server.url/, modify the location appropriately.

Note that current versions of uWSGI no longer support the (long-deprecated) uwsgi_modifier1 30; to pass this mount information on to uWSGI, so if you're running multiple applications (or don't want to host your application on /) you will probably want to pay attention to the script mounting information for uWSGI above.

Once you're done, create a soft link to /etc/nginx/sites-enabled/ for each of the entries in /etc/nginx/sites-available/. Now you can start your Nginx service.

$ sudo service nginx start

Every time you modify the Nginx configuration file, you'll have to restart the it.

Port Forwarding

If you're running this server from your home or office and you need external access, don't forgot to forward port 80 so that Nginx is accessible. Instructions for your router are probably available here.

Sources

I used several sites while putting this all together. If you're stuck, they may contain additional information that I neglected to include here. Here are the most helpful of the bunch:

Deploying Flask on uWSGI
Multiple Django and Flask Sites with Nginx and uWSGI Emperor
How to Setup Nginx
uWSGI Example Configuration

I also had some help from my friends and colleagues BCJ and Curtis when I was initially setting up Nginx. Thanks, gents!


* Since you're probably not going to be running uWSGI under your own user account, you'll probably want to either use a virtual environment or satisfy any package requirements via sudo pip3. Otherwise, you will probably end up with errors like:

Traceback (most recent call last):
  File "/opt/post/run.py", line 9, in 
    from post import app
  File "/opt/post/post/__init__.py", line 1, in 
    from flask import Flask
ImportError: No module named 'flask'

22 September 2014

Configuring Flask, uWSGI, and Nginx

An updated version of this post, which covers uWSGI 2.0.9 and Python 3.4 is available here.


In a departure from what I often write about, I'm going to talk a little bit about something that is tangentially related to what I actually do for a living: running a web server. So I'm going to give a brief tutorial on setting up uWSGI (in Emperor mode) and Nginx so that you can run one or more Python Flask instances on a server.

Why? Well, I'm far from a pro at anything related to networking or web development, but I have been writing a few web tools lately just for fun. Initially, I had several different Flask/Werkzeug instances running in what was essentially a dev mode on different ports on my server, and I had each of these ports forwarded. But...


...this was ungainly, running multiple Werkzeug instances was inefficient, I didn't want to have to forward all of those ports, and damn it, I wanted to do things right. But, as this isn't my area of expertise, it took me a while to put all of these pieces together, because many of the examples that I was able to find were light on the details. I'm putting this here in the hope that someone else in my situation might find it useful.

Installation

So here are the relevant details. I'm running Ubuntu 12.04 (I know, I know, I should update) and I'm using Python 2.7.2, Flask 0.10, uWSGI 2.0.6, and Nginx 1.1.19. If you are missing any of these, you'll want to install them with your package manager of choice. For example:

$ sudo apt-get install python
$ sudo apt-get install uwsgi
$ sudo apt-get install nginx
$ pip install flask

The goal here is to run multiple Flask servers on one machine without having to worry about port numbers and the like. We'll start with just one, and I'm sure that you can figure the rest out from there.

Flask

First you need a Flask application to run. How about this one? I wrote it a few months ago because I wanted to translate GET requests to POST requests.

Navigate to the directory you'd like to install it to (probably /opt/ or /var/www/), then clone it. You'll want to verify that it runs locally on its own first.

$ cd /opt
$ git clone https://github.com/spurll/post.git
$ post/run.py

In a web browser on the same server, navigate to http://localhost:9999 and verify that the application is accessible. If you're running headless (as I am) you can always spawn the process to the background with post/run.py & and then curl localhost:9999 and verify that you don't get an error back. You can now kill the Python process.

Flask is now set up!

uWSGI

First, test that uWSGI will run your application correctly on its own:

$ cd /opt/post
$ uwsgi --socket 127.0.0.1:9999 --protocol=http -w run:app

In this case, run is the name of the Python source file that contains our application (/opt/post/run.py) and app is the name of the Werkzeug/Flask application object contained in that file. Verify that the application is accessible again from http://localhost:9999 as above.

If everything is working correctly, kill the uWSGI instance. It's now time to configure uWSGI's Emperor mode. This allows us to essentially have one master process that oversees all of our web applications, starting (and restarting) them when needed and logging as appropriate. You will probably have to install a few plugins, too, using your package manager of choice. For example:

$ sudo apt-get install uwsgi-plugin-python
$ sudo apt-get install uwsgi-plugin-http

By default, your uWSGI master configuration file will probably be located at /etc/init/uwsgi.conf. Edit it with your editor of choice (I'm a Vim guy, myself):

$ sudo vim /etc/init/uwsgi.conf

It should look something like this:

description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn

env UWSGI=/usr/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log

exec $UWSGI --master --emperor /etc/uwsgi/apps-enabled --die-on-term --uid www-data --gid www-data --logto $LOGTO

You can change the location of the Emperor's log file by changing the LOGTO environment variable. You can also modify which user (--uid) and group (--gid) the Emperor will run as.

Now it's time to configure the applications. Your application-specific configuration files (in this case, for the POST program that we installed to /opt/post/) will probably be found at /etc/uwsgi/apps-available/. Create a new file there and call it post.ini. It should like something like this:

[uwsgi]

# Variables
base = /opt/post
app = run
callable = app

# Generic Configuration
plugins = http,python
pythonpath = %(base)
socket = /opt/run/%n.sock
module = %(app)
logto = /var/log/uwsgi/%n.log

Here, base is the base directory of our application (the directory that contains the module we want to run), app contains the name of the module to run (in this case run, for run.py), callable is the name of the Werkzeug/Flask callable application object (if you don't supply this, uWSGI will assume that it's called application), and socket defines the location of the socket you'd like Nginx to use when communicating with your uWSGI server. The %n references the name of our file (sans extension) to maintain consistency.

You'll need to ensure that the location of your sockets (in this case, /opt/run/) exists and that the appropriate user (in this case, www-data) has write permissions.

This configuration assumes that you want to run your program using the modules installed on your system's Python. To run the application in a virtual environment, add a line defining home:

home = %(base)/virtualenv

Where virtualenv is the directory containing the Python virtual environment you'd like to use. (In our case, that would be at /opt/post/virtualenv/, if we were using a virtual environment.)

Once you're ready, create a symbolic link to place the post.ini file you've created in the apps-enabled directory:

$ sudo ln -s /etc/uwsgi/apps-available/post.ini /etc/uwsgi/apps-enabled/post.ini

You can start the uWSGI process (if you haven't already) like this:

$ sudo service uwsgi start

As soon as your Emperor process sees an application configuration file in apps-enabled it will start up a uWSGI instance to serve requests for that application. If you'd like to set up additional Flask applications at this time, simply install them and create uWSGI configuration files for each (and don't forget to link them to apps-enabled!). If you're having trouble, take a look at the logs.

The uWSGI Emperor is now set up!

Nginx

We're almost there!

The default configuration file for Nginx should be located at /etc/nginx/sites-available/default. Feel free to edit this one, or create your own. By default, Nginx will point requests on port 80 (the default HTTP port) to /usr/share/nginx/www. If you'd like to point them somewhere else (such as /var/www/) you can change that here. Here's a brief Nginx configuration file that you can use to run connect your uWSGI server to the outside world:

# server unix:///path/to/your/site.sock; # For a file socket.
# server 127.0.0.1:9999;                 # For a port.

upstream post {
    server unix:///opt/run/post.sock;
}

server {
    listen 80;
    server_name your.server.url;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    root /var/www;
    index index.html index.htm;

    # GET to POST
    location /post {
        include uwsgi_params;
        uwsgi_param SCRIPT_NAME /post;
        uwsgi_modifier1 30;
        uwsgi_pass post;
    }
}

Replace your.server.url with the URL for your server (you can use localhost for testing purposes). This configuration assumes that you'd like your application to be accessible at http://your.server.url/post. If you'd like it to take the place of the main page at http://your.server.url/, things are even simpler:

...
    # GET to POST
    location / {
        include uwsgi_params;
        uwsgi_pass post;
    }
}

Once you're done, create a soft link to /etc/nginx/sites-enabled/ for each of the entries in /etc/nginx/sites-available/. Now you can start your Nginx service.

$ sudo service nginx start

Every time you modify the Nginx configuration file, you'll have to restart the it.

Port Forwarding

If you're running this server from your home or office and you need external access, don't forgot to forward port 80 so that Nginx is accessible. Instructions for your router are probably available here.

Sources

I used several sites while putting this all together. If you're stuck, they may contain additional information that I neglected to include here. Here are the most helpful of the bunch:

Deploying Flask on uWSGI
Multiple Django and Flask Sites with Nginx and uWSGI Emperor
How to Setup Nginx

I also had some help from my friends and colleagues BCJ and Curtis when I was initially setting up Nginx. Thanks, gents!

15 September 2014

LUEE Episode 88: Experimenting on Your Thoughts

In this extended round-table episode of Life, the Universe & Everything Else, Gem is joined by Ashlyn, Ian, and Laura to discuss thought experiments that range from the classical to the incomprehensible to the downright bizarre.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism that is produced by the Winnipeg Skeptics and the Humanists, Atheists & Agnostics of Manitoba.

Announcement: We're going monthly! That means you'll get podcasts half as often, but we'll make the podcasts twice as awesome to make up for it!

Note: If any of our listeners are concerned about information hazards and wish to skip over the discussion of Roko's Basilisk, the content in question begins at the 1h24m mark and ends at 1h35m46s.

Links: Thought experiment (Wikipedia) | The Drowning Child | The Life You Can Save (Wikipedia) | Charity Reviews and Recommendations (GiveWell) | Foundation Beyond Belief | Prisoner's dilemma (Wikipedia) | Ship of Theseus (Wikipedia) | Children prefer certain individuals over perfect duplicates (ScienceDirect) | Original Position (Stanford Encyclopedia of Philosophy) | Original position (Wikipedia) | Timeless Decision Theory | Newcomb's paradox (Wikipedia) | Newcomb's problem (LessWrong Wiki) | Roko's Basilisk (r/Futurology) | Streisand effect (Wikipedia) | Thought Experiment (Futility Closet)

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | Stitcher | RSS Feed

04 August 2014

LUEE Episode 86: Interview with a Mariachi Ghost

In this episode of Life, the Universe & Everything Else, Ian James sits down for a conversation with Rafael Reyes, guitarist for local Winnipeg band The Mariachi Ghost.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism presented by the Winnipeg Skeptics and the Humanists, Atheists & Agnostics of Manitoba.

Links: The Mariachi Ghost Website | The Mariachi Ghost on BandCamp | The Mariachi Ghost on Facebook | Conservative Leader Brian Pallister on "Infidel Atheists" Who "Celebrate Nothing"

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | Stitcher | RSS Feed

26 May 2014

LUEE Episode 81: Book Reviews (with Greta Christina!)

In this episode of Life, the Universe & Everything Else, Gem Newman, Ashlyn Noble, and Kristina Anderson review some popular science books, and are joined by Greta Christina, who tells them all about her newest book, Coming Out Atheist.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism presented by the Winnipeg Skeptics and the Humanists, Atheists & Agnostics of Manitoba.

Books Reviewed: Coming Out Atheist: How to Do It, How to Help Each Other, and Why, by Greta Christina | Soundings: The Story of the Remarkable Woman Who Mapped the Ocean Floor, by Hali Felt | Bad Pharma: How Drug Companies Mislead Doctors and Harm Patients, by Ben Goldacre | Bad Pharma: What Happened Next (Free Follow-up Chapter) | The Hungry Scientist Handbook, by Patrick Buckley and Lili Binks

Other Recommendations: The Ebony Exodus Project, by Candace R.M. Gorham | Why Are You Atheists So Angry?, by Greta Christina | Bad Science: Quacks, Hacks, and Big Pharma Flacks, by Ben Goldacre | The Rocks Don't Lie, by David R. Montgomery | The Map That Changed the World, by Simon Winchester | The Rithmatist, by Brandon Sanderson | The Runelords, by David Farland | The Demon-Haunted World, by Carl Sagan | Last Chance to See, by Douglas Adams and Mark Carwardine | The Day of the Triffids, by John Wyndham | The Lathe Of Heaven, by Ursula K. Le Guin | I Am Legend, by Richard Matheson | Little Brother, by Cory Doctorow

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | Stitcher | RSS Feed

28 April 2014

LUEE Episode 79: The Historicity of Jesus

In this episode of Life, the Universe & Everything Else, Greg Christensen, Ian Macaulay, and Gem Newman discuss whether the character of Jesus Christ as portrayed in the Christian Bible is actually based on an historical figure, and Greg gives us a review of Bill O'Reilly's new book along the way.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism presented by the Winnipeg Skeptics and the Humanists, Atheists & Agnostics of Manitoba.

Links: Historicity of Jesus (Wikipedia) | Christ myth theory (Wikipedia) | Carrier and Ehrman disagree on the historicity of Jesus | David Fitzgerald responds to criticism of Nailed | LUEE Episode 72: The War on Christmas (A Brief History) | Irreligiosophy: The One True Podcast (Website, iTunes) | The Bible Geek Show (Website, iTunes) | Josephus on Jesus | Tacitus on Christ | Criterion of Embarrassment | Acharya S (Wikipedia)

Books: Killing Jesus, by Bill O'Reilly and Martin Dugard | Nailed, by David Fitzgerald | Proving History, by Richard Carrier | The Incredible Shrinking Son of Man, by Robert Price | Did Jesus Exist?: The Historical Argument for Jesus of Nazareth, by Bart Ehrman

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | Stitcher | RSS Feed

08 December 2013

MATLAB: WAT

I made a video! It's a brief sketch of some of the really weird things that the MATLAB programming language likes to do. It was (quite obviously) inspired by Gary Bernhardt's talk at CodeMash last year (which is, for the record, shorter and more entertaining). So if you haven't watched his talk, do yourself a favour and watch it instead!



Enjoy!

28 July 2013

LUEE Episode 62: Star Trek's Humanism (and Lack Thereof), Part 2

Episode 62: Star Trek's Humanism (and Lack Thereof), Part 2
In this episode of Life, the Universe & Everything Else, Greg Christensen, Richelle McCullough, Robert Shindler, and Gem Newman continue their discussion of Star Trek's long history of humanism, and some of the places the franchise has stumbled along the way.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism presented by the Winnipeg Skeptics and the Humanists, Atheists & Agnostics of Manitoba.

Episodes Discussed: The Next Generation (The Measure of a Man, Who Watches the Watchers) | Deep Space Nine (Family Business, In the Pale Moonlight) | Voyager (Author, Author) | Enterprise (Dear Doctor)

Other Links: Riker Sits Down | Gem's Rant on the Subject of "Dear Doctor" | Mansplainer #3: I’m Sick of Television (and Real Life) | That Mitchell and Webb Look: English Civil War

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | RSS Feed

14 July 2013

LUEE Episode 61: Star Trek's Humanism (and Lack Thereof), Part 1

Episode 61: Star Trek's Humanism (and Lack Thereof), Part 1

In this episode of Life, the Universe & Everything Else, Greg Christensen, Richelle McCullough, Robert Shindler, and Gem Newman discuss Star Trek's long history of humanism, and some of the places the franchise has stumbled along the way.

Life, the Universe & Everything Else is a program promoting secular humanism and scientific skepticism presented by the Winnipeg Skeptics and the Humanists, Atheists & Agnostics of Manitoba.

News Items: An Open Letter to Exodus International's Super-remorseful Alan Chambers | Vaccine Against HPV Has Cut Infections In Teenage Girls | 'Racist' Licence Plates Recalled in New Brunswick | Licence Plate Standards (Manitoba, Alberta, New Brunswick)

Episodes Discussed: The Original Series (Who Mourns for Adonais?) | Star Trek V: The Final Frontier | The Next Generation (The Child)

Other Links: Riker Sits Down | 'Star Trek' Franchise an Homage to Humanist Philosophy | Gene Roddenberry | Michael Piller | CBS/Paramount and Michael Piller's "Fade In" | D.C. Fontana | The "Mind Rape" Trope

Contact Us: Facebook | Twitter | Email

Listen: Direct Link | iTunes | RSS Feed