Wednesday, November 30, 2016

Sample code for Moodle Quiz questions that have source code samples in them. In Moodle XML format.

<?xml version="1.0" ?>
<quiz>

<!-- "Test" is the quiz question bank name -->
<question type="category">
    <category>
        <text>$course$/Test</text>
    </category>
</question>

<!-- Sample short answer question with a code sample.
See: https://docs.moodle.org/31/en/Moodle_XML_format for more details.
-->
<question type="shortanswer">
    <name>
        <text>Test question</text>
    </name>
     <questiontext format="html">
         <text>Look at the following code:
<![CDATA[
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<pre><code class="python"># Code Sample
def test_function():
   print("Hi")

test_function()
</code></pre>
]]>
What does the program print when it runs?
         </text>
    </questiontext>

    <!-- Case sensitive flag -->
    <usecase>1</usecase>

    <answer fraction="100">
        <text>Hi</text>
        <feedback><text>Correct!</text></feedback>
    </answer>
    <answer fraction="0">
        <text>hi</text>
        <feedback><text>Sorry, but case matters!</text></feedback>
    </answer>
</question>

</quiz>

Wednesday, April 8, 2015

How much money can you get from YouTube video ads?

I was curious about what kind of money a normal person can make out of YouTube video ads.

As part of my Program Arcade Games web site I have a lot of tutorial videos. I've got about 2,000 subscribers and a half million views total on my video channel. Was that worth any money? Last Christmas I enabled advertising to find out.

The results:
Start date: 12/23/2014
End date: 4/8/2015
Days advertising was active: 106
Total views: 81,165
Total earned: 103.25
Amount earned per day 0.9741
Amount earned per view 0.0013



You need at least $100 in revenue to get paid. I ended the experiment to see once I got over $100. Quite frankly, $100 doesn't seem worth it to annoy people for 106 days and 81,000 views.

Keep in mind you only get paid if someone clicks on the ad. So a person isn't paid on a per-view basis. The results varied a lot on a per-day basis. This is what the analytics looked like:

Saturday, February 14, 2015

Script for setting up Wordpress on an AWS machine

I found the documentation a bit of a headache to run through. This is a quick way to get a wordpress server up and running on Amazon Web Services.

DBPASSWORD="yourdbpassword"
DBSERVERPASSWORD="yourdbserverpassword"

sudo apt-get -y update
sudo apt-get -y upgrade

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password yourdbserverpassword'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password yourdbserverpassword'
sudo apt-get -y install mysql-server

sudo apt-get -y install apache2 php5 php5-mysql mercurial

sudo service mysql start
mysql -u root -p
yourdbserverpassword
CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'yourdbpassword';
CREATE DATABASE `wordpress-db`;
GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost";
FLUSH PRIVILEGES;
exit

cd ~
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz

cd wordpress/
cp wp-config-sample.php wp-config.php
sed -i 's/database_name_here/wordpress-db/g' wp-config.php
sed -i 's/username_here/wordpress-user/g' wp-config.php
sed -i 's/password_here/yourdbpassword/g' wp-config.php

curl https://api.wordpress.org/secret-key/1.1/salt/ >> wp-config.php

sudo rm /var/www/html/index.html
sudo mv * /var/www/html/
sudo chown -R www-data:www-data /var/www/html

Tuesday, December 2, 2014

Learn to Program in Python!

The second edition of Program Arcade Games with Python and Pygame is out! I'm very happy with how it has turned out. A lot of feedback from the first edition has gone into making the second. The Amazon reviews are good as well. The whole book is available on-line at ProgramArcadeGames.com.

 I'm not sure what my second professional project will be.

Monday, March 11, 2013

Three Years After The Adoption

Three years ago today Val and I sat in a courtroom to adopt Tanya and Nastya. Ten days later they were officially ours, and soon after they were in the US. 

Nothing worth doing is easy. But it has been worth it.

Nastya has learned so much and worked so hard. Her teacher this year didn't even know she’d been in Russia less than three years ago. 

Tanya, wow. The teenage years are hard enough. Watching her work through the frustration of everything and grow into a happy young woman getting ready to be independent is beautiful.

Alyssa? She grew up. We no longer had time to be helicopter parents, and Alyssa showed that she could do great anyways. One minute she can be an adult, the next minute turn around and act like a kid with Nastya.

Parents push their kids to do better, particularly when they don’t want to.

What I didn't know was that kids push their parents to do be better. I've never been pushed harder by anyone, including myself. And no one has been there for me more than Val. In another eight years the kids will leave, and there’s no one I’d rather spend the rest of my days with than her.

I think sometimes in life we focus so hard on where we’d like to be, that we forget to appreciate how far we've come. Nastya has had to learn everything a typical fourth grader knows in less than three years. Alyssa welcomed two strangers into her home as sisters. Tanya? She’s a typical high school student, defying the odds where half of all 15 year-olds that immigrate to the U.S. without English fail to even finish high school.

Please excuse me as I congratulate my family. Not everyone could have done that.

It has been a hard road, but we've traveled far and it looks like we have many miles ahead of us. Thanks to everyone that has traveled with us.

Wednesday, February 6, 2013

Pygame

Pygame Tutorials

Learn to create games using pygame with this free on-line e-book.

Install Sphinx on Windows.

First, install Python 2.7. I've had no luck the the 3.x series.

Then, download and install easy_install from here: http://pypi.python.org/pypi/setuptools/0.6c11

Then, execute:

\Python27\Scripts\easy_install.exe sphinx