It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
Edit: better version

Getting unique username list for a thread in Linux

for i in {1..$maxPage}; do curl -s $threadurl/page$i; done | grep "<div class=\"small_user_name\">" | sed 's/^[ \t]*<div class="small_user_name">//' | sed 's/<\/div>//' | sort | uniq

exchange
$maxPage wih the last pagenumber
$threadUrl with the url to the thread

Example: for i in {1..33}; do curl -s http://www.gog.com/en/forum/general/introducing_the_beta_release_of_the_new_gogcom_downloader/page$i; done | grep "<div class=\"small_user_name\">" | sed 's/^[ \t]*<div class="small_user_name">//' | sed 's/<\/div>//' | sort | uniq

Pseudocode:
1. Get me all pages of the thread
2. Get me all the users in those pages
3. make it pretty (no html garbage)
4. Sort and remove multiple entries

Explanation:

1. for i in {1..$maxPage}; do curl -s $threadurl/page$i; done
tells curl to get page 1 - $maxPage of the thread identified by $threadUrl

2. | grep "<div class=\"small_user_name\">"
throws away every line that doesn't include <div class=\"small_user_name\"> (thanks to hedwards for pointing it out)

3. | sed 's/^[ \t]*<div class="small_user_name">//' | sed 's/<\/div>//'
Cuts away unnecessary text in front of and after the username

4. | sort | uniq
Sorts the usernams alphabetically and removes multiple entries
Post edited September 12, 2012 by fengor
In order to avoid mulitposts, you could also only allow everybodys first post in the thread.
So you choose a number with random.org, than check if it is the first post by that person in the thread and if that person actually wants to participate. If not, than you just draw another number using random.org, until you found a valid post.

Might be faster, than first determining everybody who wants to participate, unless a lot of people are doing multiple posts.
This way everybody still has the same chance to win.
avatar
Feeenix: In order to avoid mulitposts, you could also only allow everybodys first post in the thread.
So you choose a number with random.org, than check if it is the first post by that person in the thread and if that person actually wants to participate. If not, than you just draw another number using random.org, until you found a valid post.

Might be faster, than first determining everybody who wants to participate, unless a lot of people are doing multiple posts.
This way everybody still has the same chance to win.
Very good idea. I think I'll do this.
Make sure you word your random.org using giveaways properly or that guy with "random.org" as his username might show up to make that silly joke again.
:p
Most basic method is post numbers, but that would make pepole who post more than once in a thread more likely to win.

In rare ocasions I'm making a giveaway, I write down names of participants in excel, each participant gets a random number (generated by random.org or excel function [so it doesn't matter when you post your entry)), and then I random.org the winner
Post edited September 12, 2012 by keeveek
avatar
Feeenix: In order to avoid mulitposts, you could also only allow everybodys first post in the thread.
So you choose a number with random.org, than check if it is the first post by that person in the thread and if that person actually wants to participate. If not, than you just draw another number using random.org, until you found a valid post.

Might be faster, than first determining everybody who wants to participate, unless a lot of people are doing multiple posts.
This way everybody still has the same chance to win.
You still have to eliminate any later posts and shift the results accordingly. Otherwise you can end up having multiposts being considered as they still take up space in the list.
They usually have several methods in mind and use random.org to choose the method for them ;)
Another method:
Last giveaway i cut pieces of scrap paper into equal sized rectangles. Wrote a name on each slip of paper. Some people had many slips with their names on them.. equal to the points they'd earned. Put the slips in a box. Shook it up. Pulled a name :)
Well, I think I'm going to use post numbers and if the winning post is the first post in the thread of a person that entered, it wins, if not, I'll just draw again. That way, it's not effected by multiple posts nor people who didn't enter.
avatar
hedwards: Then there's the jerks that post to say thanks for the generosity and +1, but I don't want one. Not sure what sort of monster would do that. *whistlesnonchalantly*
Alright, alright, I'm guilty! :-P
I think people put too much emphasis on "proving" that giveaways are random. When I do giveaways, sometimes I use random.org, sometimes I just pick a random number and see who's post it is, whatever. Point is, it's your giveaway, so you can do it however you want. If people don't like the way you do it, no one is forcing them to enter.

I hate it when people try to do something nice and other people try to turn it into something sinister. It's ridiculous.
avatar
thebum06: I would just go with post numbers.
This is what I do, and for WTWP, Kristy picks a number between 2 and the last post number, usually while she is in another room, so it basically the same. Before I started doing giveaways, I looked at random.org, as I didn't want the responsibility of picking the winner, and I wanted all chances to be equal.
avatar
MonstaMunch: I think people put too much emphasis on "proving" that giveaways are random. When I do giveaways, sometimes I use random.org, sometimes I just pick a random number and see who's post it is, whatever. Point is, it's your giveaway, so you can do it however you want. If people don't like the way you do it, no one is forcing them to enter.

I hate it when people try to do something nice and other people try to turn it into something sinister. It's ridiculous.
I agree, but then again, having a fake contest is an incredibly cost effective way of buying rep.
avatar
hedwards: I agree, but then again, having a fake contest is an incredibly cost effective way of buying rep.
Fake in what sense? As long as you say who wins, it should be pretty obvious that there has been a "real winner", especially if you do it a few times.
avatar
hedwards: I agree, but then again, having a fake contest is an incredibly cost effective way of buying rep.
avatar
MonstaMunch: Fake in what sense? As long as you say who wins, it should be pretty obvious that there has been a "real winner", especially if you do it a few times.
In the sense that you give it to somebody you know instead of gifting it correctly. Or you give it to an account that you control.

I doubt it's happened, but it is something which could happen. Although, I can't imagine it being worthwhile seeing as rep points are useless once you get over a hundred or so.