Get list of badges on this site that nobody received yet

8

Make a code that gets list of badges that nobody received yet (for example, by using this website API for badges), and output the sorted list of such badges, with new line after each.

Example output (may be smaller, depending on when you do this challenge):

Archaeologist
Caucus
Constituent
Copy Editor
Deputy
Electorate
Epic
Generalist
Hacker
Legendary
Marshal
Outspoken
Research Assistant
Sheriff
Steward
Strunk & White
Tenacious
Unsung Hero

Smallest code wins.

Konrad Borowski

Posted 2014-01-04T12:11:28.280

Reputation: 11 185

nice idea, also suspect [data.se] could do it (no answers on that so far) in fact maybe the web query is doing a SQL query at heart... – vzn – 2014-03-25T17:59:23.280

Answers

8

JavaScript with jQuery (loaded onto SE sites by default), 58

$('.badge',$('.badge-count:not(:has(*))').parent()).text()

Must be run on https://codegolf.stackexchange.com/help/badges. ;)

Strictly conforming output, 116 chars:

[].join.call($('.badge',$('.badge-count:not(:has(*))').parent()).map(function(){return $(this).text()}).sort(),'\n')

Screenshot of console output (click to enlarge):

screenshot of console output

Doorknob

Posted 2014-01-04T12:11:28.280

Reputation: 68 138

Is using external libs allowed? – Szymon Toda – 2014-01-04T14:21:23.323

3@Ultra jQuery is loaded onto SE sites by default. – Doorknob – 2014-01-04T14:36:45.480

6

Bash, 173 characters

curl "https://api.stackexchange.com/2.1/badges?page="{0..50}"&pagesize=100&order=desc&sort=type&site=codegolf"|gunzip|grep -Po '{"name".*?award_count":0.*?}'|cut -d'"' -f 4

Though you could probably shave some characters off by using url shortening.

WARNING: Note that running this script a couple of times will result in this:

{"error_name":"throttle_violation","error_message":"too many requests from this IP, more requests available in 84495 seconds","error_id":502}

Output for codegolf.SE:

code-golf
Informed
Research Assistant
Caucus
Constituent
Outspoken
Deputy
Vox Populi
Excavator
Analytical
Self-Learner
Hacker
Beta
Legendary
Electorate
Investor
Tenacious
Unsung Hero

EDIT: tweaked it a bit.

Thom Wiggers

Posted 2014-01-04T12:11:28.280

Reputation: 191

Bash - huehuehue. PS is /dev/null really needed here? – Szymon Toda – 2014-01-04T14:20:54.697

You can use curl instead of wget -O-. – Konrad Borowski – 2014-01-04T15:03:17.853

Hmm I thought that I had removed the /dev/null which I had for testing. – Thom Wiggers – 2014-01-04T20:36:46.383

1

PHP - 92 86 characters

<?=html_entity_decode(substr(file_get_contents("http://tinyurl.com/q9zlwfr"),12937,190));

Inspired by Victor's solution. Very volatile.

Konrad Borowski

Posted 2014-01-04T12:11:28.280

Reputation: 11 185

0

Java - 280 267 260

class A{public static void main(String[]z)throws Exception{String s="";int y;java.io.InputStream x=new java.net.URL("http://tinyurl.com/q9zlwfr").openStream();while((y=x.read())!=-1)s+=(char)y;System.out.println(s.substring(12937,13126).replace("amp;",""));}}

Victor Stafusa

Posted 2014-01-04T12:11:28.280

Reputation: 8 612

1That seems... volatile. If Stack Exchange team would make almost any change to their website (or if my question would be modified), it would return the wrong list. Besides, the list may be not up to date. – Konrad Borowski – 2014-01-04T18:52:38.493

Why is the class name so long? Why is the argument to main's name so long? Why is there unnecessary whitespace after InputStream? – Doorknob – 2014-01-04T18:52:43.493

@DoorknobofSnow Well noted. These one slipped when I was converting the ungolfed version to a golfed one. – Victor Stafusa – 2014-01-04T18:55:29.880

@xfix Yeah, very volatile. That was intentional. – Victor Stafusa – 2014-01-04T19:10:29.203

I'm tempted to edit the question by one letter just to troll you :-D – Doorknob – 2014-01-04T19:14:18.547

@DoorknobofSnow :-D – Victor Stafusa – 2014-01-04T19:20:08.050