News for hackers. Stuff that matters.
Re:Poll: Where do you live? by wongarsu on Friday February 04, 2022 @03:45PM (#30212911)
As percent of total responses, as of right now:

    'US: California', '10.87%'
    'Canada', '5.79%'
    'United Kingdom', '4.51%'
    'US: Washington', '4.45%'
    'Germany', '4.45%'
    'US: New York', '4.32%'
    'US: Colorado', '2.10%'
    'US: Texas', '1.97%'
    'US: Massachusetts', '1.84%'
    'France', '1.78%'
The US in total makes up 49% of responses so far (even though it is nearly 10pm in most of Europe)

Edit: quick and dirty one-liner to get the full table with relative values:

    data = [...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)); total = data.map(a => parseInt(a[1])-1).reduce((a,b) => a+b, 0); console.table(data.map(a => [a[0], ((parseInt(a[1])-1)/total*100).toFixed(2) + "%"])); us = data.filter(a => a[0].startsWith("US:")).map(a => parseInt(a[1])-1).reduce((a,b) => a+b, 0); `US makes up ${(us/total*100).toFixed(2)}% of ${total} responses`
Edit2: made one-liner even dirtier to account for counts starting at 1
Re:Poll: Where do you live? by lhorie on Friday February 04, 2022 @04:59PM (#30213908)
Be mindful that the dataset is 1-indexed (i.e. zero votes equal a score of 1), so your script is probably a bit skewed towards non-US.
Re:Poll: Where do you live? by wongarsu on Friday February 04, 2022 @05:08PM (#30214012)
Good catch. Accounting for that brings the US up from currently 50.2% to 52.8%. It also brings California up from 11.75% to 12.86%. I updated my code above to account for that (having to fight the urge to refactor it to be more sensible)
Re:Poll: Where do you live? by young_unixer on Friday February 04, 2022 @04:42PM (#30213715)
It would be cool to see it relative to the population of the country.
Re:Poll: Where do you live? by e12e on Friday February 04, 2022 @08:32PM (#30216110)
Is there are reasonable way to do this on a mobile browser?
Re:Poll: Where do you live? by wongarsu on Friday February 04, 2022 @08:45PM (#30216193)
Maybe rewriting it as a bookmarklet that displays the results on the page?

Anyways, here's the current result in a pastebin: https://pastebin.com/fR89qMKk

Re:Poll: Where do you live? by gabrielsroka on Sunday February 06, 2022 @04:34PM (#30237242)
I posted these:

https://news.ycombinator.com/item?id=30213991

https://news.ycombinator.com/item?id=30215244

Edit (this version subtracts 1 to see the real score and pops open in a new window):

  javascript:open().document.write('<meta name=viewport content="width=device-width, initial-scale=1.0"><table>' + [...document.querySelectorAll('.fatitem table .athing')].map(el => ({place: el.textContent.trim(), score: parseInt(el.nextSibling.textContent) - 1})).sort((a, b) => b.score - a.score || a.place.localeCompare(b.place)).map(e => `<tr><td>${e.place}<td align=right>${e.score}`).join('') + '</table>')
Re:Poll: Where do you live? by e12e on Saturday February 05, 2022 @06:14PM (#30227349)
Good tip, thank you. Bookmarklets work as normal(?) on Firefox on Android, and can be invoked via the address bar on Chrome:

https://paul.kinlan.me/use-bookmarklets-on-chrome-on-android...

A random intro to bookmarklets: https://betterprogramming.pub/are-bookmarklets-still-useful-...

Re:Poll: Where do you live? by icco on Sunday February 06, 2022 @09:30PM (#30239514)
TIL about console.table. Thanks for sharing!