Giter Club home page Giter Club logo

leaderboard's Introduction

SJCPL Leaderboard

This code runs the leaderboard for trivia night. Once the system is set up there are no runtime dependencies on the internet. The code opens a web server on port 80 to display the leaderboard, and runs a second web server on port 8000 to provide an admin console. The admin console allows for adding teams, adding scores, and modifying scores. All changes to the scores are saved to the file team_data.tsv.

The displayed score page has javascript to progressively revealed the scores. At first no scores will show. Pressing space will reveal the bottom third of teams. Press space again to show the bottom two thirds, and pressing space a third time will display the rest.

This code originally was a python script for the 2013 trivia night. It was rewritten in Go for the 2017 trivia night.

Details

The program is in Go; compile it by running go build. Then run the program by running sudo ./leaderboard. The sudo is required since root privildges are needed for the program to listen on port 80, the usual HTTP server port.

View the admin page by visiting localhost:8000 in a browser window.

You can view the score page by visiting the web page on the computer the program is running on. In my case, my machine name is chance (run hostname at the terminal). The published page can then be accessed using the url http://chance.local.

The teams are grouped into the bottom three, the top three, and everything in the middle. When the page is opened, no teams are displayed. By hitting the spacebar, the teams are revealed. First the bottom group is shown, then the middle, and finally, on the third press of the spacebar, the top teams are revealed. Hitting shift-spacebar will hide the groups in the reverse order.

The program keeps the current scores saved into this file. In case of an emergency the file could be edited by hand and reloaded with the load team_data.txt command in the admin console.

The save file consists of a sequence of lines, each line having the format

<table number> \t <team name> \t <score round 1> \t <score round 2> \t ...

where \t is a tab character. A sample line is

6\tDeliberators\t8\t10\t4

This line describes the team "Deliberators" at table 6. They have scored 8 in round 1, 10 points in round 2, and 4 in round 3. Currently, the csv file must be in the current directory and named team_data.txt.

The file leaderboard_template.html is the template for the score display page. The file admin_template.html is the template for the admin page.

Enjoy.

leaderboard's People

Contributors

dbrower avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.