by lhorie · 4y ago · 0 comments
[...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)).map(a => a.join(' - '))
As of this post, California is leading, followed by other places w/ large tech hubs (Germany, UK, Canada, NY, Washington) console.table([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a))) 'US: California' '79 points'
'Canada' '48 points'
'US: Washington' '39 points'
'US: New York' '36 points'
'Germany' '35 points'
'United Kingdom' '34 points'
'US: Massachusetts' '19 points'
'Netherlands' '18 points'
'US: Colorado' '17 points'
'Sweden' '16 points'
Colorado #9? Really? '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 1Also the UK and Germany being about the same is interesting. Germany does have a slightly larger population, but of course the UK is natively English speaking.
Also, given the new(ish) move to remote work that many firms nationally have begun to embrace there is also a strong showing here of people that work in Colorado, but for firms located elsewhere. This is my personal current situation, and I work with a guy who is moving here from the midwest in a couple months to work 100% remote. It's more and more common.
Denver's also a big telecommunications and defense hub. Both industries employ armies of developers
Large US states are more populous than most countries, and the US tech industry is orders of magnitude larger than most countries'.
If US weren't broken out, it would be a huge outlier at the top and wouldn't be nearly as interesting.
I don't know of any other country that would make the chart that much more interesting by being broken up.
console.table([...document.querySelectorAll('.fatitem table .athing')].map(el => ({place: el.textContent.trim(), score: parseInt(el.nextSibling.textContent)})).sort((a, b) => b.score - a.score)) console.table([...document.querySelectorAll('.fatitem table .athing')].map(el => ({place: el.textContent.trim(), score: parseInt(el.nextSibling.textContent)})).sort((a, b) => b.score - a.score || a.place.localeCompare(b.place))) javascript:document.write('<table>' + [...document.querySelectorAll('.fatitem table .athing')].map(el => ({place: el.textContent.trim(), score: parseInt(el.nextSibling.textContent)})).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>')It works on Chrome for Android.
console.table([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.replace(/:.*/,'').trim(), parseInt(el.nextSibling.textContent.trim())]).reduce((d, [k,v]) => {d[k]=v + (d[k] || 0); return d}, {}))
I can't figure out how to sort that, though...Are you accepting PRs? If so, align=right. Thanks!
To see the sorted results: https://gabrielsroka.github.io/hnpoll.html?id=30210378
Source: https://github.com/gabrielsroka/gabrielsroka.github.io/blob/...
Makes sense, otherwise entries would contain itself.
Thank you!
Source: https://github.com/gabrielsroka/gabrielsroka.github.io/blob/...
Noob question: is there a similar way to dump it to JSON, instead of a table?
JSON.stringify([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))
JSON.stringify([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))
console.table(Object.entries([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).reduce((rv, [a,b]) => {var key = a.split(": ")[0]; rv[key] = rv[key] || 0; rv[key] += parseInt(b); return rv;}, {})).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))
'US' 959
'Canada' 114
'United Kingdom' 96
'Germany' 96
'France' 35
'Netherlands' 30
'Sweden' 30
'Poland' 24
'Brazil' 24
'Denmark' 19
'Switzerland' 18 US: California 535 / 39.51 Mil. = 13.54 / Mil.
Canada 244 / 38.01 Mil. = 6.42 / Mil.
Germany 232 / 83.24 Mil. = 2.79 / Mil.
UK 220 / 67.22 Mil. = 3.27 / Mil.
US: New York 206 / 39.52 Mil. = 5.21 / Mil.
US: Washington 199 / 7.71 Mil. = 25.81 / Mil.
US: Texas 122 / 29.15 Mil. = 4.19 / Mil.
There might even be some hidden champions in the lower absolute numbers. Sweden 74 / 10.35 Mil. = 7.15 / Mil.
Denmark 40 / 5.83 Mil. = 6.86 / Mil.
Finland 33 / 5.53 Mil. = 5.97 / Mil.
Norway 31 / 5.38 Mil. = 5.76 / Mil.
but nothing beats Vatican City 6 / 825 = 7273 / Mil.Employees there that I talked with had never noticed that for everything sourced outside Africa the outline and flag of that nation was displayed but for everything from Africa there was only an outline of Africa labeled as "Africa".
Geography is so important especially today with the ability to connect to anyone, anywhere in near real time.
The questions in the poll are so we know where the OP is from.
Happy to see both Dakotas have votes.
const totalPop = {"Oklahoma":3986639,"Nebraska":1963692,"Hawaii":1441553,"South Dakota":895376,"Tennessee":6975218,"Nevada":3143991,"New Mexico":2115877,"Iowa":3193079,"Kansas":2934582,"District of Columbia":670050,"Texas":29527941,"Missouri":6168187,"Arkansas":3025891,"Michigan":10050811,"New Hampshire":1388992,"North Carolina":10551162,"Ohio":11780017,"South Carolina":5190705,"Wyoming":578803,"California":39237836,"North Dakota":774948,"Louisiana":4624047,"Maryland":6165129,"Delaware":1003384,"Pennsylvania":12964056,"Georgia":10799566,"Oregon":4246155,"Minnesota":5707390,"Colorado":5812069,"New Jersey":9267130,"Kentucky":4509394,"Washington":7738692,"Maine":1372247,"Vermont":645570,"Idaho":1900923,"Indiana":6805985,"Montana":1104271,"New York":19835913,"Puerto Rico":3263584,"Connecticut":3605597,"Florida":21781128,"Virginia":8642274,"Massachusetts":6984723,"Illinois":12671469,"Mississippi":2949965,"Arizona":7276316,"Utah":3337975,"Wisconsin":5895908,"Alabama":5039877,"West Virginia":1782959,"Rhode Island":1095610,"Alaska":732673};
console.table(
[...document.querySelectorAll('.fatitem table .athing')]
.map(el => ({place: el.textContent.trim(), score: parseInt(el.nextSibling.textContent)}))
.filter(el => el.place.includes("US:"))
.map(el => ({...el, place: el.place.replace("US: ", "")}))
.map(el => ({...el, totalPop: totalPop[el.place]}))
.filter(el => el.totalPop != undefined)
.map(el => ({...el, density: el.score / el.totalPop}))
.sort((a, b) => b.density - a.density)
)$$('.score').map(node => [node.parentElement.parentElement.parentElement.previousSibling.innerText?.trim(), parseInt(node.innerText)]).sort(([,scoreA], [,scoreB]) => scoreB - scoreA)