hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Simple Bash Tool to compare Challenge solvers

 
Reply to topic    hacker.org Forum Index » General View previous topic
View next topic
Simple Bash Tool to compare Challenge solvers
Author Message
dangermouse



Joined: 05 Jun 2011
Posts: 81

Post Simple Bash Tool to compare Challenge solvers Reply with quote
i wrote a simple set of bash scripts to compare Challenge solvers. it might be useful to you if:
- you want to find out which challenges were solved by your competitors, but not by yourself
- you want to know who solved a particular challenge out of your watchlist
- you want to know if hints in the forum are given by someone who solved the challenge or not
- you want to compare top ten users

The tool is available at:
git clone git://git.code.sourceforge.net/p/gpu/gpu-freedom gpu-freedom
ln -s gpu_freedom/src/playground/discochal discochal
cd discochal

The tool works in Cygwin under Windows and should work on any Linux flavour with bash (tested on Fedora 16).

To use it do
cd discochal
chmod 755 *.sh
./updatechals.sh # this can take up to 5 hours
./discochal.sh yourusername
./diffchal.sh yourusername dangermouse
./watched.sh
./whosolved.sh Anybody

and don't forget to read the README file Wink

hope you have fun Smile


Last edited by dangermouse on Wed Dec 19, 2012 9:04 am; edited 10 times in total
Wed Apr 25, 2012 1:01 pm View user's profile Send private message Visit poster's website
laz0r



Joined: 04 Feb 2010
Posts: 290
Location: Within the depths of Unix

Post Reply with quote
Wow, that looks brilliant - I'll have a look! Thanks for this Smile

_________________
There is no spoon.
Wed Apr 25, 2012 5:07 pm View user's profile Send private message
laz0r



Joined: 04 Feb 2010
Posts: 290
Location: Within the depths of Unix

Post Reply with quote
Hi,
I found a small bug:
In /removeif0.sh, the second line, beginning with FILESIZE, should be changed to read:
Code:
FILESIZE=$(du -k "$1" | awk '{print $1}')

I have no idea how stat works (in the original), but apparently it doesn't take a -c flag (as of the version I've got, anyway, which is at least younger than 2009). Using du works fine.
Great tool, though!

_________________
There is no spoon.
Wed Apr 25, 2012 9:06 pm View user's profile Send private message
dangermouse



Joined: 05 Jun 2011
Posts: 81

Post Reply with quote
hey laz0r thx for the fix, your approach with FILESIZE is more general, as du still works for me! btw another minor bug in diffchall.sh is that the challenge count is always one bigger than it should. This because i simply add the line count with wc -l in discochal.sh, and the line count is one too high because of the line "Challenge solved by user". But i'd like to keep this line for clearness, as it shows the direction of the diff.

About the invalid challenges, in fact adum already added an "invalid challenge" message, e.g see
http://www.hacker.org/challenge/solvers.php?id=350
To date i hardcoded challenge 303 in discochal.sh and updatechals.sh, maybe i should create a configuration file with a MAX_CHALLS variable and then "source" it...

ah, another feature is that discochal.sh can be run concurrently, as it is written "thread-safe".

to be honest i am a bit of a bash newbie! ciao Smile

UPDATE: i released a new package under http://www.gpu-grid.net/other/discochal2.tar.gz incorporating the fix of laz0r, the challenge count fix and the MAX_CHALLS constant. There is a new script updateusers.sh to update users in the watchlist and a script updatesinglechal.sh to update a single challenge. This time, i did not include the "database" of solvers though... so you might still need to download the first package, or to run updatechals.sh first...
Thu Apr 26, 2012 7:33 am View user's profile Send private message Visit poster's website
dangermouse



Joined: 05 Jun 2011
Posts: 81

Post Reply with quote
I did a third release under http://www.gpu-grid.net/other/discochal3.tar.gz
removing the annoying h2 html tag and fixing some duplicate user issues. If you already have data, you need to run an ./updateusers.sh to get rid of the h2 tags and to get ./diffchall.sh to work properly.

I put the thing also somewhere in a git repository:
git clone git://git.code.sourceforge.net/p/gpu/gpu-freedom gpu-freedom
ln -s gpu_freedom/src/playground/discochal discochal
cd discochal

run git pull from time to time to see if there are updates...

ciao Smile


Last edited by dangermouse on Thu Sep 20, 2012 9:49 am; edited 2 times in total
Fri Apr 27, 2012 7:18 am View user's profile Send private message Visit poster's website
laz0r



Joined: 04 Feb 2010
Posts: 290
Location: Within the depths of Unix

Post Reply with quote
Brilliant - I'll have a look later today Smile

_________________
There is no spoon.
Fri Apr 27, 2012 8:03 am View user's profile Send private message
dangermouse



Joined: 05 Jun 2011
Posts: 81

Post Reply with quote
ah laz0r, the data in the original package discochal.tar.gz is a bit corrupted (i created it from a virtual machine running on VirtualBox with poor internet connection), so you might need take your time and run a ./updatechals.sh to get reliable information on solvers... For the occasional user, the provided data should be still okay, though.
Fri Apr 27, 2012 9:06 am View user's profile Send private message Visit poster's website
laz0r



Joined: 04 Feb 2010
Posts: 290
Location: Within the depths of Unix

Post Reply with quote
I think it would be good if the script checked on running updatechals whether the solvers folder existed - you could just run "mkdir solvers" at the start of the code, as a little bodge job!

_________________
There is no spoon.
Fri Apr 27, 2012 4:52 pm View user's profile Send private message
dangermouse



Joined: 05 Jun 2011
Posts: 81

Post Reply with quote
ciao laz0r, thanks again for pointing me at this. i had the directory, but cleanup.sh in combination with git removed the directory. i rereleased discochal3.tar.gz with the mkdir thing, as you proposed! discochal3.tar.gz now includes a complete uncorrupted solvers database updated as of 27.4.2012
Fri Apr 27, 2012 9:06 pm View user's profile Send private message Visit poster's website
Display posts from previous:    
Reply to topic    hacker.org Forum Index » General All times are GMT
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.