When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

suspicious_wow's blog

By suspicious_wow, history, 8 years ago, In English

Hi guys! I have modified the script and fixed some bugs of 'Friends Stalker!' and if you have the old one, please replace the code with new one.

For those who missed the last blog, 'Friends Stalker!' script will help you to know (**in real time**):

  • if your friend has submitted a code on codeforces, along with its verdict and problem name through an alert on your screen.This works on contest time too, so that you won't have to open 'friends standings' page to know how many problems your friends have successfully solved or attempted!
  • You won't have to check for system test results in every 2 minutes. You can leave script running in background and it will let you know the result of your submissions along with your friends in no delay!!
  • If you are participating in a team but team members are at different locations, you will know quickly your teammate's submissions and results.
  • You will have a record on your terminal/ command prompt of the last submissions of your friends.

So lets go quickly to installation:

  1. Make sure you have python2.7 or higher installed. Script is written python. If you write python in your terminal/cmd, it should give you the information about the python version and your OS. (take note if you have 32 or 64 bit OS).

  2. Make a folder named tool anywhere you like.

  3. Inside tool folder, make a file named codeforces.py and copy the code from here .

  4. Inside tool folder make a text file named friends.txt . Inside this file, copy-paste the handles of your friends separated by spaces .Make sure you paste correct spelling of handles as codeforces!!

  5. Through terminal/cmd, go to the tool directory and run python codeforces.py friends.txt .

  6. Voila!! You are good to go and will recieve a alert whenever your friend submits code.

Possible errors :

You might recieve an error telling easygui module is not found! So you need to install this module with command

  • Linux based users : sudo pip install easygui

  • Windows users : open cmd with administrator privilages (run as administrator). and type pip install easygui

If you still get an error telling something like 'pip not found' then :

  • Linux based users try this link

  • Windows users can try this youtube video i found link .It's an easy walkthrough to install pip.

Now install 'easygui' module! Done!!

Now if you are OK with canceling the alert through pressing enter key whenever it appears, everything is completed for you! Enjoy the script :)

But the users who have a 'lot' of friends may find annoying to cancel each alert by pressing enter! So HellKitsune suggested me to implement a massanger type notification which appears at corner and goes away automatically! I was able to find a way to implement this but unfortunately it is working for Linux based users only. (Since python-notify module is not available in windows!). I have written a script for windows too but I don't know if it is working since I have ubuntu machine. I will post the windows script also but someone has to tell me if it is working or not! So lets go to scripts for automatic close notification feature!!

  • For LINUX based OS users :(very easy!)
  1. just run the command sudo apt-get install python-notify .

  2. replace the code inside codeforces.py with code in this link

  3. run command python codeforces.py friends.txt

  4. done!! now you dont have to close alert everytime it appear.

  • For Windows users — (working as best of my knowledge)
  1. You have to download pywin32 library from here. Make sure you choose the right python version and OS (32 or 64bit) file. Installing is pretty easy since the user has given instruction below the page very clearly!!

  2. replace the code inside codeforces.py with code in this link

  3. run command python codeforces.py friends.txt.

  4. tell me if it worked or not :D (I am grateful and you are a big contributor :) )

Inside codeforces.py :

There are few changes you would want to make according to you preferences like :

  • Please make flag = True to know if notifications are successfully coming. After checkin first time,set flag = False so that you wont have to cancel bunch of pop-ups everytime you run script!

  • I have checked last 15 solutions of a user in script. You may wanna increase or decrease this.

  • I have set the script to check CF every 3 minutes. You can increase or (please don't) decrease this count. Less count will check codeforces more often and it can cause site run slow if lot of users set this less. I had set 3 minutes for testing purposes.

So with thats all done, you might have just one more question, "what happened to your last blog?"

Answer is I deleted that mistakenly ;_; I thought like comments a blog can't be deleted permanently too and will discard the current change. I am very sad about it (That blog had 80-85 upvotes!!). Well whats done is done.

Now if you find bugs or want to suggest new features, please comment me. If you want to add a new feature yourself, feel free. I have commented almost everything in the code so it is very easy to understand. If you have any trouble in installing please comment below but try googling your error first. If you have found an error but fixed it yourself, then tell others too and save them from some trouble!! I am sure this script will save some time for you.

Last but not the least, thanks to Mike and other codeforces admins for providing free API. Thank you awoo for all you help, many bugs i fixed by his help :)

Cheers!!

UPD :

FIX_1 : I have used submission id as the primary factor to distinguish between submissions (like primary key) which will fail at cases when :

pretest-passed -> Hacked (same submission id)

pretest-passed -> WA ,TLE , RTE or any wrong verdict (same submission id)

pretest-passed -> Accepted (same submission id)

I have already fixed this bug. Now I will use [Submission_id + Submission_verdict] as primary key and it wont cause anymore error! (correct me if i am wrong please).

So please don't rely on script for system case checking for now! I will update the script tomorrow after some more testing. I apologize for the inconvenience caused.

FIX_2 : GOOD NEWS!!! I have fixed the automatic-notification code for windows users. And it is working properly now!! This script will be posted tomorrow as well after some more testing. Now windows users won't have to press enter endlessly as well :)

After the next update the script will be totally bug-free (as i think for now). I suggest you guys to keep an eye on this blog because after next update the platform dependencies won't be an issue anymore and I will be adding more awesome features very quickly. Thanks and have a nice time! :)

UPD1 : Now I have used the gist to show code and made a repository at github too. Links are now updated, so make sure you have new updated script. Report please if any bugs.Thanks Kelang, It was just the thing i needed! From now, I won't update this blog anymore, you can check for updates on git. Make sure you contribute as well. ANYONE CAN CONTRIBUTE!!
If someone has some free time translate it to russian please. Thank you everyone for all support!! :)

Link to github repository : github

Full text and comments »

  • Vote: I like it
  • +43
  • Vote: I do not like it

By suspicious_wow, history, 9 years ago, In English

I am trying to solve this spoj problem related to strings and i am constantly getting time limit exceeded.here is my solution .Any help would be appreciated ! thanks :)

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it