10 ms·
Pasting this in dev console will give you a quick and dirty rundown. It sorts locations by points. [...document.querySelectorAll('.fatitem table .athing')]
by lhorie 5y ago
Pasting this in dev console will give you a quick and dirty rundown. It sorts locations by points.
[...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)
- toqy 5y agoThis is begging for a console.table console.table([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))
- gabrielsroka 5y agoMore efficient, uses integers, and sortable in the table: 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))
- gabrielsroka 5y agowith tie breakers 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)))
- lhorie 5y agoGood call!
- runjake 5y agoNeat! Noob question: is there a similar way to dump it to JSON, instead of a table?
- chair6 5y agoJust replace console.table with JSON.stringify for the quick-and-easy dump of exactly the same data as is in the table... JSON.stringify([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))
- AntonyGarand 5y agoReplace `console.table` with `JSON.stringify`: JSON.stringify([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))
- deleted 5y ago[deleted]
- gkfasdfasdf 5y agoCurrent top 10: '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?
- deleted 5y ago[deleted]
- TulliusCicero 5y agoDenver and Boulder have a good amount of tech. A bit surprised it comes out ahead of Texas though. Also 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.
- hwc 5y agoTexas is without power at the moment.
- capableweb 5y agoThought you were joking at first, how can an entire state be without power? But seems you're right, how the hell does that happen in a first-world country? Tried to access some dashboards that are supposed to show some data, but not sure if I can't access it because I'm not in the US/Texas or if it's down as well (because they don't have power?) - https://www.ercot.com/gridmktinfo/dashboards https://www.ercot.com/gridmktinfo/dashboards - https://www.ercot.com/gridmktinfo/dashboards/gridconditions https://www.ercot.com/gridmktinfo/dashboards/gridconditions - https://www.ercot.com/gridinfo https://www.ercot.com/gridinfo Says "This request was blocked by the security rules" so I'm assuming it's the former.
- dhosek 5y ago
- mmcnl 5y agoTIL. Cool!
- newaccount74 5y agoI wanted a total for the US: 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...
- gabrielsroka 5y agoObject.entries https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- newaccount74 5y agoOh, I need to type Object.entries(x) instead of x.entries() Makes sense, otherwise entries would contain itself. Thank you!
- eyelidlessness 5y agoEntries only iterates enumerable items (unless you make something evil). None of the native types with entries in their prototype iterate over that method
- binarynate 5y agoI created a page with the current results that includes a total for the US: https://nate.org/hacker-news-location-poll https://nate.org/hacker-news-location-poll
- Larrikin 5y agoPercentage next to totals would make this perfect
- binarynate 5y agoGood idea—I just added a percentage column, as well as a row at the bottom for the total count
- gabrielsroka 5y agoIf you're on a mobile browser, paste this into the address bar: 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>')
- cardamomo 5y agoThat doesn't seem to work on Firefox for Android, sadly
- gabrielsroka 5y agoSometimes the browser will remove the leading 'javascript'. In that case, type it back in.
- gabrielsroka 5y agoIt doesn't seem to be supported. Ironic that the bookmarklet was invented by them. It works on Chrome for Android.
- zander312 5y agothis is fricking awesome!! thanks!!
- gabrielsroka 5y agoTo see the sorted results: https://gabrielsroka.github.io/hnpoll.html?id=30210378 https://gabrielsroka.github.io/hnpoll.html?id=30210378 Source: https://github.com/gabrielsroka/gabrielsroka.github.io/blob/master/hnpoll.html https://github.com/gabrielsroka/gabrielsroka.github.io/blob/...
- glassprongs 5y agoNice work
- culi 5y agoNow we need to divide the votes by the population of each place
- jeromegv 5y agoYes, hilarious to see "South Dakota" as a specific region, but Canada as a whole.
- adamrezich 5y agoI know right? East River SD and West River SD are practically different countries.
- protomyth 5y agoTruthfully, it should have been West and East Dakota, not North and South. Happy to see both Dakotas have votes.
- doodlebugging 5y agoThis reminds me of a visit to a store in the DFW area (Texas) called "World Market". They sell all kinds of things from all over the world that you would have a hard time finding anywhere else including food, furnishings, decorations, knick-knacks, gee-gaws, and other shit, etc. 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.
- geocrasher 5y agoThe answers to the poll are so the OP knows where we are from. The questions in the poll are so we know where the OP is from.
- Andrew_nenakhov 5y agoOne must adjust for the fact that it is a very late evening or deep night on the other side of the planet, and the poll might sink from the front page by the time everyone wakes up back here.
- awb 5y agoWould be interesting to see it expressed as a % of population as well to see HN density, as well as quantity.
- lolinder 5y agoI didn't get the data to do this globally, but here it is for the US (data from https://api.census.gov/data/2021/pep/population?get=POP_2021,NAME,STATE&for=state:\ https://api.census.gov/data/2021/pep/population?get=POP_2021...*): 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) )
- davidkuennen 5y agoWith US combined: 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
- bsimpson 5y agoSo you're saying I should have checked the comments before opening the console? $$('.score').map(node => [node.parentElement.parentElement.parentElement.previousSibling.innerText?.trim(), parseInt(node.innerText)]).sort(([,scoreA], [,scoreB]) => scoreB - scoreA)
- dang 5y agoWe detached this subthread from https://news.ycombinator.com/item?id=30211916 https://news.ycombinator.com/item?id=30211916.
- Archelaos 5y agoI think for a ranking the data should be normalized by population. If I calculate it for seven leading regions manually, the current numbers are as follows: 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.
- eriksjolund 5y agoNordic countries also get high 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.
- Archelaos 5y agoI had always suspected the Jesuits behind HN.