FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!

Blog around the clock

Created on Wed Dec 14, 2011 1:39 pm with 41 blog posts
The is my blog on Frihost. I probbaly don't blog around the clock, but hopefully more than 1 post per life time. My typical areas of interest: project management, & software development.

How Quizroom works ... in games with 1 comments on Fri May 03, 2013 11:08 am
Now, as promised, a few insights into how Quizroom works.
As I already explained: Quizroom auto-generates questions based on facts I have stored in its database, so there is no need to setup pre-defined questions and answers.
It is designed in a way that it allows me to keep an arbitrary number of fact tables in my database with an arbitrary number of facts. For example I have one table called facts_countries containing a list of countries with their population and rank by population ( guess who is number 1 by the way ).
The key table in the Quizroom database is the table called questions which contains the question templates, assigned to categories. For the category "Geography" for instance there is one question template which looks like this:

Question = "Which of these countries has the highest population ?"
Answer = "Country"
Criteria = "max(Population)"
Table = "facts_countries"
Category = "Geography"
Ref = "http://en.wikipedia.org/wiki/List_of_countries_by_population"

There are multiple questions in category "Geography", so first thing Quizroom does is picking one randomly. Let's assume it has picked the one shown above. This tells Quizroom to go to the facts_countries table and pick four records randomly from there. From those 4 records one is picked as the "right" answer depending on the criteria, here the one with the highest population. The question is displayed plus the four possible answers. That's basically it.

There is a column Ref with the URL from where I have taken the data. You might have noticed that after you have answered a question a "Reference" link is shown at the bottom of the screen, so you actually can go there and verify the source of the facts used for that particular question.

The challenge now is to feed the Quizoom database with interesting facts, stored in a structured way. Wikipedia of course is a good source and some articles have a lot of tables, which make is easy to some extend to derive those structured data. I actually wrote a little Greasemonkey script to transform HTML tables into CSV files easy to import into a database.
Nevertheless, even HTML tables are hard to digest for a structured database in many cases. If for example you look at this Wikipedia article into the table of Countries you notice that for several countries footnotes have been added. This kind of disturbs the attempt to transform such a table into a structured format and requires extra data cleaning effort.
My little Greasemonkey script is just a start, may be a more powerful browser extension is needed to assist in fetching unstructured data and transforming it into useful structured data. Many facts come in format of lists with special rules, something for instance not supported by that script yet.

So much for now. If you, dear reader, know of any source in the internet with interesting facts organized in a structured way please let me know; may be these facts could become the fuel for more interesting questions in Quizroom.
Welcome to Quizroom ! in python with 4 comments on Mon Apr 29, 2013 7:52 pm
Finally, after some hurdles with Python + MySQL here on Frihost, my little Python project "Quizroom" went live here on Frihost, after I re-wrote my server code to use SQLite as a backend rather than MySQL.

Quizroom is a little quiz game asking you multiple-choice questions in several categories I have set up so far, as we have currently:

* Geography
* Movies
* Science

Quizroom auto-generates questions based on facts I have stored in its database, so there is no need to setup pre-defined questions and answers. In a later blog posting I explain a bit more about how it works.

For now, here is the quick user's guide:



When you start the game you first select one of the categories or "all" if you wanna play them all. Then you click on the upper center field to get started and the first question is displayed together with 4 possible answers. A timer starts running, as you see a progress bar advancing from the left to the right at the bottom of the browser window.
The sooner you answer right, the better !
The time you get is 10 seconds plus 1 second for every 30 words you have to read ( question + all answers ).
If you answer right you gain as many points as seconds were left before you would have been running into a timeout.
If you answer wrong you loose one energy point per 100 points you have scored so far, which basically means: the higher your score the more energy you loose when answering wrong.
A right answer gets you 1 energy point, up to a maximum of 20. You start with 10.
If you run out of energy game is over for you. At this time - if you made it into the high score list - you have the opportunity to leave your name ( or Frihost user name or whatever ) in the high score list. You can also click the closing "x" at the top right corner of that dialog box if you do not want to show up on the highscore list.

A push button in the right column of the screen lets you re-start the game. While the game is running you also can end it any time thru another push-button in the right column of the browser window.

That's basically it. Give it a try and have fun playing. Click HERE to ge started.
Python Expression Evaluator Version 3 in python with 0 comments on Tue Apr 23, 2013 6:14 pm
As I mentioned already I have come up with a new version of my Python Expression Evaluator.
Besides Python expression and Regular expressions ( enclosed in slashes ) it now supports SQL statements ( which have to end with a semicolon ).
Thus you for instance can do something like this:

create table capitols ( country text, city text );
insert into capitols values ( "Germany", "Berlin" );
insert into capitols values ( "France", "Paris" );
insert into capitols values ( "UK", "London" );
select * from capitols;



This will actually create a table in my database file and thus eat up my file space. So keep in mind this is just for trying out SQL statements. I am not a cloud storage provider and won't provide space for large sets of data, so be aware that your data might get wiped out sooner or later if I have the need to clean up my file system Wink .

Anyhow, the code to handle SQL statements is basically the code for a simple SQLite shell taken from here, enhanced a bit and thrown into my existing code of my Python Expression Evaluator.

It also handles SQL errors of course:



Python Expression Evaluator uses its own built-in table cmd_history to maintain a history of commands entered. By clicking the History button this history can be retrieved and I actually added some more jQuery code to enable the feature that when you click a line from that command history it is actually loaded into the upper most entry field so you can "re-use" a command.

So, happy, SQLing !
Python and SQLite in python with 0 comments on Tue Apr 23, 2013 5:26 pm
For a little project I wanted to host here I need Python and a SQL database à la MySQL. Both are available here on Frihost but somehow I didn't find a means to connect both.
Thus I have been thinking about several alternatives:

* Option 1 - find a different free hosting service where I can get Python to work together with MySQL.
* Option 2 - re-write my server in Perl
* Option 3 - use a different database, e.g. SQLite.

After I failed with option 1 and found option 3 too labour intensive I am trying option 2 now.

SQLite is a way to create a database in a single file and use SQL as an interface to that database. All you need is a space where you can write a file and a module supporting this: SQLite3 that is for Python.

As the authors of SQLite write:

Quote:
SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.


Thus SQLite is useful for initial development and even might work for small and medium-size applications. Interesting to read in this Wikipedia article:

Quote:
It is arguably the most widely deployed database engine, as it is used today by several widespread browsers, operating systems, and embedded systems, among others.


To make sure this actually works I decided to first come up with a little Python program to just test out SQLite capabilities. And finally I actually decided to enhance my Python Expression Evaluator to allow entering SQL statements as well, using SQLite as the backend. More about this in my next blog posting ...
"Go slow now so you can go faster later" in projectmanagement with 2 comments on Fri Apr 05, 2013 1:23 pm
Currently I am listening to a replay of a presentation about Project Risk Management by Frank Saladis having this quote on one of its slides: "Go slow now so you can go faster later". It reminds me of another quote I once heard from one of my mountain guides when going on some hiking tour: "The one who goes slow goes far."

Doing project management right means to have sort of a slow start since you need to do some planning and preparation upfront before you actually start execution of the project and creating the deliverables customers of your project asked for.

This means that for some period of time you do not work directly on those deliverables, you more work on plans and documents and processes and setting things up for the project. This exactly is the reason why projects are not managed well in an environment lead by people who do not understand the value of project management. When they see you doing your planning and all that stuff they quickly get real nervous and impatient and come up with questions like: "when will you start wrting code for me ?"

A project manager needs to deal with that impatience, otherwise he or she won't be able to do the job as project manager at all and what was supposed to be a project quickly turns into an adventure.

There is another nice saying about project management. There are two ways to do a project: plan and execute, or: execute, fail, plan and execute.
--> All blog posts (41)

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.