Python wordpress plugin: easily embed and run python code in your website

Python wordpress plugin: easily embed and run python code in your website

Create.withcode.uk python wordpress plugin
Create.withcode.uk python wordpress plugin

Create.withcode.uk is designed to allow anyone to write, run, debug and share python code that runs in your browser. It’s designed primarily for use in schools to allow teachers to quickly share code with students that they can adapt, debug and use.

Here’s an example python program that asks you for your name then says hello. Press Ctrl + Enter (or click on the green plus at the bottom of the code screen) to run the code.

When you save some python code on create.withcode.uk (press Ctrl+S or click on the share button) you get an option to copy and paste some HTML code that can be embedded into any website. e.g:

<iframe frameborder="0" width="100%" height="400px" src="https://create.withcode.uk/embed/7A"><a target="_blank" href="https://create.withcode.uk/python/7A">create.withcode.uk</a></iframe>

To make it even easier to embed your python projects into your blog or website, I’ve shared a plugin for wordpress that lets you quickly add python code using a wordpress shortcode.

This makes sharing your python projects much simpler:

  1. Write your code on create.withcode.uk

    You don’t need an account – just type in your python code into the browser & test it with either Ctrl + Enter to run the whole project or Ctrl + .  to run it one line at a time

  2. Save your code

    Press Ctrl + S  or click on the share button. This make your code available to anyone with the link.

    Share your code

    The URL will be something like https://create.withcode.uk/python/ra

    Note the letters and numbers at the end of the URL ( ra  in the above example)

    Find the ID

  3. Add your code to any post or page in your wordpress blog using a shortcode:

    Use a shortcode that contains the letters and numbers from the previous step:

    Add a shortcode
    This will display the python source code in your blog page or post. People viewing your website will be able to view, run and debug your code.

  4. If you want your code to run by default rather than show the source code:

    Adapt the shortcode to change the mode to “run”:

    Shortcode to run

Wordpress python plugin
Python wordpress plugin

Click here to download the wordpress plugin or to find out more.

Like create.withcode.uk, the wordpress plugin is free and open source.

 

Free potty training chart: ad-free open source app now on android

digital sticker chart: free (no ads)Yesterday we started potty training. It was a disaster. Nine puddles on the floor: three at a friend’s house (sorry). Two frought parents and one distinctly un-bothered toddler.

Today was much better. 8 wees in a potty, one poo in the toilet and no accidents. Result!

There are loads of books to pretend to have read that probably have good advice on how to do it properly. Here’s what seemed to work:

  • Set aside a day to stay at home and waddle around the house without any pants on (the toddler…) so it doesn’t feel like a nappy.
  • Have a massive reward chart somewhere highly visible.
  • Make sure the littl’un understands what positive incentives (bribes) they’re working towards with each success.
  • Explain that a sticker is coming off the chart if they have an accident.

My 3 year old is a massive Thomas the Tank Engine fan (who isn’t?) so yesterday morning we were drawing the Island of Sodor together in Photoshop with a custom brush that lets you draw train tracks. In light of the failed attempts to start potty training it seemed like a good idea to turn the drawing into a sticker chart.

Free potty training chart: open source ad-free sticker chart app
Free potty training chart: open source ad-free sticker chart app

Writing the code for a free potty training chart app yesterday is probably a contributing factor to why potty training wasn’t all that successful yesterday. But today, we put the web app on the Smart TV in the front room and ticked off each successful toilet / potty trip. Seeing Daniel get excited about the train moving round to the next sticker reward felt really good.

In case a free potty training chart would be useful to anyone else, you can try it out here: tools.withcode.uk/sticker

You can also download a free android app if you’ve got a smartphone or tablet you want to use instead of a smart tv.

Get it on Google Play

For anyone who’s interested, I’ve shared the source code for the app here. It’s a pretty basic HTML5 web app that uses CSS3 for the animations / responsive graphics. It’s published under a MIT license so feel feel free to use / adapt / extend it providing you link back here if you find it useful.

Let’s see how things go tomorrow…

Free 3d dice roller app

Free 3d dice roller app

Students in Computer Science and iMedia have been asking for a lunchtime club where they can learn how to make 3d games. This term I’m launching an Indie Game Dev Club for students who want to design and make high quality 3d content using free tools.

Indie Game Dev Club
Indie Game Dev Club

The club will teach students how to use:

  • Blender to create 3d objects
  • GIMP to create and edit textures and graphics
  • Audacity to create and edit sounds and music
  • Unity to put the game assets all together
  • MonoDevelop to write the C# scripts to control the game

The idea is for students to work in groups to design, create, test and market their own apps and games to raise money for good causes.

The first complete project to come out of the game dev club is Roll-a-dice-3D which lets you roll as many dice as you like, with lots of different types of dice featured.

There are hundreds of apps already out there that let you simulate rolling a die or multiple dice but I wanted to have an example project that students could adapt that builds on the best features of each of them.

The end result is Roll-a-dice-3D which you can download from the Android Play store or play online.

Free 3d dice roller app
Free 3d dice roller app

The app lets you roll as many dice as you like by tapping or shaking your mobile device. It currently supports the following dice:

  • 6 sided dice (D6)
  • 4 sided dice (D4)
  • 8 sided dice (D8)
  • 10 sided dice (D10)
  • 12 sided dice (D12)
  • 20 sided dice (D20)

The interface is pretty simplistic – most people will just want one or two 6-sided dice so you can tap on the blue buttons at the bottom left of the screen to add or remove 6-sided dice.

You can also add as many custom dice as you like by entering in something like 6D6 + 10D12 to get six 6-sided dice and ten 12-sided dice.

The number shown on each die rolled is added up with the total shown in the bottom right of the screen.

Roll-A-Dice 3D screenshot
Roll-A-Dice 3D screenshot

You can use the app as a replacement when dice go missing from a board game or you can use it for simulating lots of rolls of dice for maths statistic projects.

 

Download Roll-A-Dice 3D from Google Play
Download Roll-A-Dice 3D from Google Play

You can download the app for your android tablet or phone or use/play it online.

For further information click here.