Sponsored Content
The Lounge What is on Your Mind? Forum Trivial Pursuit - New Computer Science and Mathematics Trivia for UNIX.com Post 303040342 by Neo on Sunday 27th of October 2019 12:16:39 AM
Old 10-27-2019
First Draft Done:

Code:
mysql> describe neo_open_trivia;
+-------------------+------------------+------+-----+---------+----------------+
| Field             | Type             | Null | Key | Default | Extra          |
+-------------------+------------------+------+-----+---------+----------------+
| id                | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| category          | varchar(254)     | NO   |     | NULL    |                |
| type              | varchar(16)      | NO   |     | NULL    |                |
| difficulty        | varchar(16)      | NO   |     | NULL    |                |
| question          | varchar(1024)    | NO   |     | NULL    |                |
| correct_answer    | varchar(1024)    | NO   |     | NULL    |                |
| incorrect_answers | varchar(5000)    | NO   |     | NULL    |                |
+-------------------+------------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)

Example Test Data:

Code:
mysql> select * from neo_open_trivia;
+----+--------------------+----------+------------+------------------------------------------------------------------------------------------+----------------+-------------------+
| id | category           | type     | difficulty | question                                                                                 | correct_answer | incorrect_answers |
+----+--------------------+----------+------------+------------------------------------------------------------------------------------------+----------------+-------------------+
|  1 | Science: Computers | boolean  | easy       | The name of this forum is 'The UNIX and Linux Forums'?                                   | True           | ["False"]         |
|  2 | Science: Computers | multiple | easy       | According to the International System of Units, how many bytes are in a kilobyte of RAM? | 1000           | [512,1024,500]    |
|  3 | Science: Computers | multiple | easy       | What does 'Hello World' Mean?                                                            | Hello          | ["Bye","Go","Mo"] |
|  4 | Science: Computers | boolean  | easy       | 'Hello World' Means Bite Me?                                                             | False          | ["True"]          |
|  5 | Science: Computers | boolean  | easy       | 'Hello World' Means Hello World?                                                         | True           | ["False"]         |
+----+--------------------+----------+------------+------------------------------------------------------------------------------------------+----------------+-------------------+
5 rows in set (0.00 sec)

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mathematics operations in unix

Hello guys! Can say me anybody about operatios with unix, I don't to make operations, only inside in a variable, like this #y=4 #x=2 #let z=$y-$x #echo $z # 2 but I can't to make mathematical operations with decimal like this #y=3.2 #x=1.5 #let z=$y-$x #echo $z # 3 this... (2 Replies)
Discussion started by: cesar720213
2 Replies

2. Shell Programming and Scripting

Which is the best way/command to do mathematics in UNIX scripting?

Hello all! I used to use expr for doing simple mathematics, but has a main advantage and a main disadvantage: The advantage is that it can take variables for numbers (e.g.{1}: echo "Give me first" read lol echo "Give other" read lil sum=`expr $lol + $lil` echo "The sum of $lol and $lil =... (5 Replies)
Discussion started by: hakermania
5 Replies

3. What is on Your Mind?

Computer Science and Information Technology

Hi, I haven't posted on the forums for a while now, I tried to find the most appropriate section for this post, but if this is in the wrong section please forgive me. First, let me say I'm a sophomore in HS. I know that job wise I definitely want to do something in computers. A while ago I was... (5 Replies)
Discussion started by: hpicracing
5 Replies

4. Programming

Is Web Development is a part of computer science ?

I am now a student in university in 2nd year. I am studying computer science. But I am not sure what type of jobs computer science provide. I know some of them are software programming or network management. Recently, I hear some about Web Development. I wonder if it is a part of computer science.... (1 Reply)
Discussion started by: Anna Hussie
1 Replies

5. Web Development

Is Web Development is a part of computer science ?

I am now a student in university in 2nd year. I am studying computer science. But I am not sure what type of jobs computer science provide. I know some of them are software programming or network management. Recently, I hear some about Web Development. I wonder if it is a part of computer... (3 Replies)
Discussion started by: Anna Hussie
3 Replies

6. What is on Your Mind?

1000+ Computer Science Trivia Questions at UNIX.COM

The UNIX and Linux Forums now has over 1000 TRUE / FALSE computer science and computer related trivia question in our database. These questions are of relatively high quality (compared to similar sites on the web) and are fun (according to feedback by users). In the first week during the... (1 Reply)
Discussion started by: Neo
1 Replies

7. What is on Your Mind?

New Member and Country Computer Trivia Leaderboards

Thanks to Akshay, who helped me write the core MySQL queries, we now have two new draft leaderboards, by (1) member and by (2) country: https://www.unix.com/trivia_stats.php Currently milhan leads the members with a high score of 90%: ... (3 Replies)
Discussion started by: Neo
3 Replies

8. What is on Your Mind?

Debugging Our Computer Science Trivia Feature

Only a few days after I coded this new feature from scratch, we are seeing over 3000 entries in the database from members (mostly guests) playing CS trivia. I have spend a lot of time coding this (from scratch) and testing the API. From the logs, it seems to have an API bug which appears... (31 Replies)
Discussion started by: Neo
31 Replies

9. What is on Your Mind?

Computer Trivia Feature Tops 50,000 Questions Answered

Just noticed that our successful computer trivia feature (stats here) has surpassed over 50,000 questions answered by users: https://www.unix.com/trivia_stats.php This was a coding effort worth while and I'm pleased to see so many people enjoying it in such a short time since it was released... (3 Replies)
Discussion started by: Neo
3 Replies
DBILogger(3pm)						User Contributed Perl Documentation					    DBILogger(3pm)

NAME
Apache::DBILogger - Tracks what's being transferred in a DBI database SYNOPSIS
# Place this in your Apache's httpd.conf file PerlLogHandler Apache::DBILogger PerlSetVar DBILogger_data_source DBI:mysql:httpdlog PerlSetVar DBILogger_username httpduser PerlSetVar DBILogger_password secret PerlSetvar DBILogger_table requests Create a database with a table named requests like this: CREATE TABLE requests ( server varchar(127) DEFAULT '' NOT NULL, bytes mediumint(9) DEFAULT '0' NOT NULL, user varchar(15) DEFAULT '' NOT NULL, filename varchar(200) DEFAULT '' NOT NULL, remotehost varchar(150) DEFAULT '' NOT NULL, remoteip varchar(15) DEFAULT '' NOT NULL, status smallint(6) DEFAULT '0' NOT NULL, timeserved datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, contenttype varchar(50) DEFAULT '' NOT NULL, urlpath varchar(200) DEFAULT '' NOT NULL, referer varchar(250) DEFAULT '' NOT NULL, useragent varchar(250) DEFAULT '' NOT NULL, usertrack varchar(100) DEFAULT '' NOT NULL, KEY server_idx (server), KEY timeserved_idx (timeserved) ); Please note that for some databases (notably, PostgreSQL) you will need to double-quote the user column name (that is, to specify it as ""user" varchar(15)") in order for the database not to mistake it with a keyword. Its recommended that you include use Apache::DBI; use DBI; use Apache::DBILogger; in your startup.pl script. Please read the Apache::DBI documentation for further information. DESCRIPTION
This module tracks what's being transfered by the Apache web server in a SQL database (everything with a DBI/DBD driver). This allows one to get statistics (of almost everything) without having to parse the log files (like the Apache::Traffic module, just in a "real" database, and with a lot more logged information). Apache::DBILogger will track the cookie from 'mod_usertrack' if it's there. After installation, follow the instructions in the synopsis and restart the server. The statistics are then available in the database. See the section VIEWING STATISTICS for more details. PREREQUISITES
You need to have compiled mod_perl with the LogHandler hook in order to use this module. Additionally, the following modules are required: o DBI o Date::Format INSTALLATION
To install this module, move into the directory where this file is located and type the following: perl Makefile.PL make make test make install This will install the module into the Perl library directory. Once installed, you will need to modify your web server's configuration file so it knows to use Apache::DBILogger during the logging phase. VIEWING STATISTICS
Please see the bin/ directory in the distribution for a statistics script. Some funny examples on what you can do might include: hit count and total bytes transfered from the virtual server www.company.com select count(id),sum(bytes) from requests where server="www.company.com" hit count and total bytes from all servers, ordered by number of hits select server,count(id) as hits,sum(bytes) from requests group by server order by hits desc count of hits from macintosh users select count(id) from requests where useragent like "%Mac%" hits and total bytes in the last 30 days select count(id),sum(bytes) from requests where server="www.company.com" and TO_DAYS(NOW()) - TO_DAYS(timeserved) <= 30 This is pretty unoptimal. It would be faster to calculate the dates in perl and write them in the sql query using f.x. Date::Format. hits and total bytes from www.company.com on mondays. select count(id),sum(bytes) from requests where server="www.company.com" and dayofweek(timeserved) = 2 It's often pretty interesting to view the referer info too. See your sql server documentation of more examples. I'm a happy mySQL user, so I would continue on http://www.tcx.se/Manual_chapter/manual_toc.html LOCKING ISSUES
MySQL 'read locks' the table when you do a select. On a big table (like a large httpdlog) this might take a while, where your httpds can't insert new logentries, which will make them 'hang' until the select is done. One way to work around this is to create another table (f.x. requests_insert) and get the httpd's to insert to this table. Then run a script from crontab once in a while which does something like this: LOCK TABLES requests WRITE, requests_insert WRITE insert into requests select * from requests_insert delete from requests_insert UNLOCK TABLES You can use the moverows.pl script from the bin/ directory. Please note that this won't work if you have any unique id field! You'll get duplicates and your new rows won't be inserted, just deleted. Be careful. TRAPS
I've experienced problems with 'Packets too large' when using Apache::DBI, mysql and DBD::mysql 2.00 (from the Msql-mysql 1.18x packages). The DBD::mysql module from Msql-mysql 1.19_17 seems to work fine with Apache::DBI. You might get problems with Apache 1.2.x. (Not supporting post_connection?) MOD_PERL 2 SUPPORT The official version of this module, as Ask Bjoern Hansen last modified it, lacks support for the API changes introduced with Apache 2.x and the corresponding mod_perl 2.x - Of course, this is quite understandable as this module was last updated in 1998 ;-) But anyway, the module does its job still quite fine, and users still require its functionality. For any help requests regarding this module on Apache 2 systems, contact Gunnar Wolf <gwolf@debian.org> directly. If your system is based on Debian GNU/Linux, you can use the regular Debian bugtracking facilities, as the multi-API patch was introduced specifically for Debian. SUPPORT
This module is supported via the mod_perl mailinglist (modperl@apache.org, subscribe by sending a mail to modperl-request@apache.org). I would like to know which databases this module have been tested on, so please mail me if you try it. The latest version can be found on your local CPAN mirror or at "ftp://ftp.netcetera.dk/pub/perl/" AUTHOR
Copyright (C) 1998, Ask Bjoern Hansen <ask@netcetera.dk>. All rights reserved. This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl(1), mod_perl(3) perl v5.12.3 2011-06-16 DBILogger(3pm)
All times are GMT -4. The time now is 12:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy