<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"><title>Andrey’s Writing</title><subtitle>Articles and notes on everything</subtitle><link href="https://andreyromanov.com/writing/feed.xml" rel="self"/><link href="https://andreyromanov.com"/><updated>Sun, 27 Oct 2024 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/feed.xml</id><author><name>Andrey Romanov</name><email>me@andrew-r.ru</email></author><entry><title>Date and time formatting in browser</title><link href="https://andreyromanov.com/writing/2019-03-11-date-time-formatting-in-browser/"/><updated>Mon, 11 Mar 2019 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/2019-03-11-date-time-formatting-in-browser/</id><content type="html">&lt;p&gt;Don’t use third-party libraries to manually format dates and time in browser. Correct format depends on user’s locale: russians use to see 11.03.2019, whereas englishmen use to see 3/11/2019.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat&quot;&gt;DateTimeFormat&lt;/a&gt; from native Intl API automatically formats date and time according to user’s locale. And, by the way, recently Intl API was extended with &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat&quot;&gt;RelativeTimeFormat&lt;/a&gt;, which allows formatting time like “X minutes ago”.&lt;/p&gt;</content></entry><entry><title>Learning English with cartoons</title><link href="https://andreyromanov.com/writing/2019-09-10-learning-english-with-cartoons/"/><updated>Tue, 10 Sep 2019 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/2019-09-10-learning-english-with-cartoons/</id><content type="html">&lt;p&gt;Viorel Sfetea shared an &lt;a href=&quot;https://viorel.me/2019/thoughts-on-learning-english/&quot;&gt;interesting story&lt;/a&gt; about learning English. He has grown up in post-communist Romania. Despite he studied English and French in school, now he speaks only English.&lt;/p&gt; &lt;p&gt;The secret is cable TV that he has got in a childhood: all TV shows and movies at the time came with the original sound (and subtitles at the best). He spent 4 to 6 hours a day watching cartoons, and that is how he has learned English, he claims.&lt;/p&gt; &lt;p&gt;This story convinces me once again that studying formal grammar is inefficient. Much more efficient way is to immerse yourself in the language environment: read books, listen to songs, watch films, et cetera.&lt;/p&gt;</content></entry><entry><title>Reducing workweek</title><link href="https://andreyromanov.com/writing/2019-09-22-reducing-workweek/"/><updated>Sun, 22 Sep 2019 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/2019-09-22-reducing-workweek/</id><content type="html">&lt;blockquote&gt; &lt;p&gt;We have to work not 12 hours, and head.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;I wonder why programmers strive to increase their salary instead of reducing the workweek. In the current state of the market, salaries cover much more than basic needs, so part of a salary could be easily traded for some free time.&lt;/p&gt; &lt;p&gt;Why would you want to reduce the workweek? There are rumors that only 5—6 hours of the standard 8-hour workday are spent productively. How remaining 2—3 hours are spent? I bet you know better. The most suffering group is office workers. Remote workers who are not required to track their time have a better position. They can just make the necessary work and get to their business without waiting for the workday to end.&lt;/p&gt; &lt;p&gt;There is a way to test drive reduced workweek without changing your employer. You can negotiate reducing workday or workweek at the expense of vacation. I used vacation days to try 4-day workweek for around 2 months. Recommend it!&lt;/p&gt;</content></entry><entry><title>DNS-level advertisement blocking</title><link href="https://andreyromanov.com/writing/2019-12-01-dns-adblock/"/><updated>Sun, 01 Dec 2019 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/2019-12-01-dns-adblock/</id><content type="html">&lt;p class=&quot;subtitle&quot;&gt;Blocking advertisement and trackers at the network level instead of browser is an insanely elegant idea. Such way trackers can’t know which sites you visit, and advertising scripts are not downloaded, which decreases overall network load and increases sites loading speed.&lt;/p&gt; &lt;p&gt;I know two products that implement this approach: &lt;a href=&quot;https://pi-hole.net/&quot;&gt;Pi-hole&lt;/a&gt; and &lt;a href=&quot;https://nextdns.io/&quot;&gt;NextDNS&lt;/a&gt;. Pi-hole is an open-source solution which requires non-trivial manual setup, but it gives you total privacy and control. NextDNS is basically Pi-hole as a Service, it’s setup is much easier, but you can’t know if it doesn’t sell logs of your DNS queries.&lt;/p&gt; &lt;p&gt;Both solutions provide beautiful dashboards with statistics, from which you can discover interesting insights. For example, you can finally learn what services does your phone talk to in background.&lt;/p&gt;</content></entry><entry><title>Global .gitignore</title><link href="https://andreyromanov.com/writing/2020-01-14-global-gitignore/"/><updated>Tue, 14 Jan 2020 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/2020-01-14-global-gitignore/</id><content type="html">&lt;p&gt;Developers often put environment-specific stuff in their project’s .gitignore:&lt;/p&gt; &lt;pre&gt;&lt;code&gt;.idea node_modules dist .DS_Store .vscode &lt;/code&gt;&lt;/pre&gt; &lt;p&gt;Only 2 of 5 entries are directly related to the project specifics (node_modules and dist). The more developers are on the project, the more noise appears in it’s .gitignore.&lt;/p&gt; &lt;p&gt;From my point of view, a good practice is creating personal global .gitignore with all your environment-specific exclusions such as &lt;abbr class=&quot;caps&quot; title=&quot;Integrated development environment&quot;&gt;IDE&lt;/abbr&gt; settings or &lt;abbr class=&quot;caps&quot; title=&quot;Operating system&quot;&gt;OS&lt;/abbr&gt; generated files:&lt;/p&gt; &lt;pre&gt;&lt;code&gt;$ git config --global core.excludesfile ~/.gitignore_global &lt;/code&gt;&lt;/pre&gt; &lt;p&gt;Do it once and forget about accidentally committing files that should be ignored and adding them to local .gitignore every time you start a new project.&lt;/p&gt; &lt;p&gt;If your teammate adds to .gitignore something that relates to his development environment and not to the project, ask him to create a global .gitignore with that stuff — it will benefit not only your’s project, but all other projects that they work on.&lt;/p&gt;</content></entry><entry><title>You don’t need arrow keys</title><link href="https://andreyromanov.com/writing/2024-10-21-goodbye-keyboard-arrows/"/><updated>Mon, 21 Oct 2024 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/2024-10-21-goodbye-keyboard-arrows/</id><content type="html">&lt;p&gt;A simple and effective lifehack by Nikita Prokopov: remap your arrow keys to &lt;kbd&gt;Caps Lock&lt;/kbd&gt; + &lt;kbd&gt;I&lt;/kbd&gt;/&lt;kbd&gt;J&lt;/kbd&gt;/&lt;kbd&gt;K&lt;/kbd&gt;/&lt;kbd&gt;L&lt;/kbd&gt; so that you don’t drag your hand around all the time.&lt;/p&gt; &lt;p&gt;Having worked with remapped arrow keys for more than five years, there’s no way I’ll get back to using standard keyboard layout.&lt;/p&gt; &lt;p&gt;Try it yourself: &lt;a href=&quot;http://tonsky.me/blog/cursor-keys&quot;&gt;tonsky.me/blog/cursor-keys&lt;/a&gt;&lt;/p&gt;</content></entry><entry><title>How to detect browser crashes</title><link href="https://andreyromanov.com/writing/monitoring-browser-crashes/"/><updated>Sun, 27 Oct 2024 00:00:00 GMT</updated><id>https://andreyromanov.com/writing/monitoring-browser-crashes/</id><content type="html">&lt;p&gt;One of my colleagues recently asked if anyone knew a way to monitor browser crashes. I didn’t know and was curious to find out.&lt;/p&gt; &lt;p&gt;Detecting browser crashes is a tricky problem, because all the code running on your site stops abruptly when it crashes, so you can’t detect the crash itself. Even if you could, another problem is sending a report to your error tracking endpoint.&lt;/p&gt; &lt;p&gt;Long story short, there is an experimental &lt;a href=&quot;https://w3c.github.io/reporting&quot;&gt;Reporting API&lt;/a&gt; which enables tracking browser crashes, various policy violations (such as Content Security Policy, Document Policy, Permissions Policy), deprecated feature usage, and user-agent interventions.&lt;/p&gt; &lt;p&gt;The Reporting API provides two main ways of tracking reports:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Using &lt;code&gt;ReportingObserver&lt;/code&gt;, which captures client-side warnings and allows you to respond to them in real-time; since it’s a client-side API, it doesn’t track browser crashes and other issues such as CSP violations.&lt;/li&gt; &lt;li&gt;Using the &lt;code&gt;Reporting-Endpoints&lt;/code&gt; HTTP header, which specifies the endpoints to which the browser will automatically send collected reports; it supports all report types, including browser crashes.&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;There is &lt;a href=&quot;https://developer.chrome.com/docs/capabilities/web-apis/reporting-api&quot;&gt;a good introduction to the Reporting API&lt;/a&gt; on the Chrome for Developers portal.&lt;/p&gt; &lt;p&gt;Note that the API is not yet stable, the spec is an editor’s draft, and it’s not fully implemented in all baseline browsers. Despite these limitations, it remains an invaluable tool, with companies like Figma &lt;a href=&quot;https://neugierig.org/software/blog/2023/01/browser-crashes.html&quot;&gt;already integrating it into their workflows&lt;/a&gt;.&lt;/p&gt;</content></entry></feed>