Допустим, вы разработчик, и вам от пользователя приходит строка user-agent с описанием того, каким браузером он пользуется.
В этой строке будет что-то типа такого:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
И вы хотите из неё узнать мажорную версию Chrome, то есть вытащить число 51. Что вы сделаете? Можно, конечно, написать свой парсер, но я уверен, многие воспользуются регулярными выражениями. Я бы воспользовался. Какое выражение сюда подходит? С виду кажется, что вот такое:
/Chrome\/(\d\d)\./g
Мы ищем слово Chrome и слэш, затем ловим в группу две цифры, после которых стоит точка. Так?
По крайней мере, мышление достаточного количества разработчиков именно таково. Зачастую программистам не хватает умения отойти от техзадания на уровень вещественной сути того, с чем они работают. На самом деле число 51 это версия. Версия будет увеличиваться со временем. «Марти, где твоё четырёхмерное воображение?» Если уже прошло 50 версий, то и следующие 50 не за горами, число станет трёхзначным, регулярка или парсер, сделанные под двухзначные числа, перестанут работать.
Трехзначная версия Chrome и Firefox приближается уже сейчас. И да, в них падает куча функций на сайтах, включая крупные корпорации: Yahoo, Bethesda, HBO и бог знает сколько сайтов поменьше. Чисто из-за цифры. Это уже назвали «Проблема сотой версии» по аналогии с «Проблемой 2000 года» (программисты записывали год двумя цифрами, 2000 стал неотличим от 1900).
К чему это я? Полезно задумываться о физическом воплощении того, что вы представляете в своей программе. Ваш код должен описывать не столько требования заказчика, сколько законы, по которым существует этот объект в реальном мире.
#dev
🇩🇰#Denmark
Danish government released violent crime conviction rates by the perpetrator's country of origin.
Data shows foreigners from MENA/Africa are more than 5x likely to commit crimes.
“Migration is a strength” is the greatest lie ever told. It is anything BUT a strength.
🇩🇰#Denmark
Danish government released violent crime conviction rates by the perpetrator's country of origin.
Data shows foreigners from MENA/Africa are more than 5x likely to commit crimes.
“Migration is a strength” is the greatest lie ever told. It is anything BUT a strength.
🇩🇰 Denmark, Faroe Islands
✨ Extreme Bridge on Suðuroy Island
Suðuroy (Far. Suðuroy — "Southern Island") is the southernmost island of the Faroe Islands archipelago. The island covers an area of 164.71 km². In 2013, the population of the island was 4,702 people.
Immerse yourself in the unique atmosphere of Suðuroy Island
✨
#Denmark
@voyage
🇩🇰#DenmarkПитер Гётше: Фармацевтическая промышленность - это организованная преступность⚠️☝️
💬 Отпускаемые по рецепту лекарства, являются третьей по значимости причиной смерти после рака и сердечных заболеваний.
2nd prize to the design for a new culture and community house in the Hamburger suburb Horner.
The proposal embraces social inclusion to create a new meeting place for its local users and is designed for disassembly with a full CLT construction. The design is based on circular principles with upcycled wood facades, focus on biodiversity in its outdoor areas, local rainwater management and more.
Architecture by Adept Architects
#arch_shovel#architecture#denmark
Denmark summoned the US ambassador over Greenland
US President Donald Trump has appointed Louisiana Governor Jeff Landry as his special envoy for Greenland. He justified this by saying that Landry understands "how important Greenland is to our national security, and he will resolutely defend the interests of our country."
Denmark, which owns Greenland, reacted with indignation to another manifestation of Trump's claims to the island. Foreign Minister Lars Loekke Rasmussen called the appointment of a special envoy "completely unacceptable." The Danish government has summoned the American ambassador in Copenhagen to protest.
#Greenland#Trump#Denmark
👂More on Trump's Ear
The Danish government has set up a “night watch” in the foreign ministry, not to keep out the wildlings and White Walkers like the Night’s Watch of Game of Thrones, but rather to monitor Donald Trump’s pronouncements and movements while Copenhagen sleeps 🛌.
The night watch starts at 5pm local time each day and at 7am a report is produced and distributed around the Danish government and relevant departments about what was said and took place, the Politiken newspaper reported 📰.
The position is understood to have been introduced in the aftermath of the diplomatic row between Copenhagen and Washington over Greenland this spring , when the US president threatened to take control of the Arctic island 🌄.
#Trump#Denmark#Greenland
👂More on Trump's Ear
🔤🔤🔤🔤🔤🔤🔤
✅Scientists from Denmark have developed a pill that replaces intense training. Researchers from a Danish university claim that the molecule, called LaKe, has the same effect on the body as a 10 km run.
💯The drug is currently being tested on mice, but chemists are convinced that it will soon be possible to conduct tests on people. Dr. Thomas Poulsen, responsible for the invention, believes that their development will help people with ailments such as heart problems live better. All you need to do is pop LaKe while continuing to chill on the couch.
A magic pill for remote workers, finally.
#Running#Denmark
MARKHEMIST
The United States is using its economic power to “assert its will" and threaten military force against friend and foe alike, a Danish intelligence agency said in a new report.
The Danish Defense Intelligence Service, in its latest annual assessment, said Washington's greater assertiveness under the Trump administration also comes as China and Russia seek to diminish Western, especially American, influence.
Perhaps most sensitive to Denmark — a NATO and European Union member country, and a U.S. ally — is growing competition between those great powers in the Arctic. U.S. President Donald Trump has expressed a desire to see Greenland, a semiautonomous and mineral-rich territory of Denmark, become part of the United States, a move opposed by Russia and much of Europe.
#Denmark#Greenland#Military
👂More on Trump's Ear
🇩🇰#Denmark / 🇬🇱#Greenland - 🇺🇸#US: Danish troops deployed to Greenland in January were reportedly prepared to destroy key airport runways and brought blood supplies, amid fears of a possible US military annexation of the island.
According to multiple reports, the explosives were intended to prevent US aircraft from landing in the event of an invasion, while the blood supplies were stockpiled to treat the wounded.
(via BBC & The Guardian)
🇺🇸#US - 🇩🇰#Denmark / 🇬🇱#Greenland: Footage showing the Danish Foreign Minister and Greenland’s Foreign Affairs Minister smoking outside the White House after a meeting with US officials Marco Rubio and J.D. Vance over Greenland’s future.
Perhaps a sign of bad news...