Skip to content

Instantly share code, notes, and snippets.

View RinatValiullov's full-sized avatar
👷‍♂️
Looking for a job

Rinat Valiullov RinatValiullov

👷‍♂️
Looking for a job
View GitHub Profile
@Jack-Works
Jack-Works / 2018.js
Last active March 1, 2024 02:23
cRAzY eSnEXt (*all* proposals mixed in)
#! Aaaaaaaaaaa this is JS!!!
// https://github.com/tc39/proposal-hashbang
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics
// Enjoy!!!
// Created at Nov 23, 2018
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
@vipinrana
vipinrana / timing.js
Last active November 27, 2020 06:51
measuring different execution time in node js
const {performance} = require('perf_hooks');
// using hrtime API
const hrBefore = process.hrtime();
setTimeout(function () {
const hrAfter = process.hrtime(hrBefore);
console.log(`Using hrtime ${hrAfter[0] * 1e3 + hrAfter[1] / 1e6}ms`);
@zerkalica
zerkalica / readme.md
Last active December 5, 2023 13:21
Заметки о tsconfig

Признаки хорошо настроенного tsconfig

Все нижеперечисленное справедливо в основном для монорепы. В проектах, где используются алиасы в импортах между либами и все зависимости в инклудах, алгоритмы упрощаются и кол-во проблем должно быть меньше.

Надо проверять работу и в vscode и в webstorm, т.к. у последнего, поверх алгоритма tsserver, накладываются свои алгоритмы автоимпортов модулей. То, что работает в webstorm, может не работать в других ide, которые полагаются только на tsserver.

tsconfig считается настроенным, если:

  1. Проходит сборка через tsc --build для либ и webpack для приложух
  2. Чекаются типы в ide и tsc --noEmit, в том числе, в файлах, которые не попадают в сборку: тесты, storybook-файлы
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active March 18, 2024 14:57
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?

@Nooshu
Nooshu / test-page-script.js
Created February 23, 2020 03:36
Simple sample script to test the font load modificaion technique
// Test Page: https://keen-northcutt-3190bd.netlify.com/standard-load.html
// Paste below into the WPT Inject Script textarea.
(function(){
var montserratBold = new FontFace('montserratbold_italic', 'url(fonts/montserrat-bolditalic-webfont.woff2)', {
display: 'swap', // test the page using 'swap'
weight: '700'
});
document.fonts.add(montserratBold);
@Nooshu
Nooshu / simplified-wpt-font-injection.js
Created February 23, 2020 03:32
Simplified script for injecting fonts into WebPageTest
(function(){
// this will trigger a font load
var customFont1 = new FontFace('custom font name', 'url([FONT_URL_HERE])', {
display: 'block', // display setting to test here
weight: '700' // font-weight
// other font properties here
});
// IMPORTANT: add the font to the document
document.fonts.add(customFont1);
@Nooshu
Nooshu / wpt-font-injection.js
Created February 20, 2020 00:25
Modify `font-display` settings via WPT script injection
(function(){
// create our custom link tag for the stylesheet
var url = "https://www.example.com/static/app.css"; // IMPORTANT: this is the CSS that contains your @font-face rules
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.type = "text/css";
link.rel = "stylesheet"
link.href = url;
// append the stylesheet to the head

Summary: .global (/g) and .sticky (/y)

/g /y /yg
.exec() at .lI or later at .lI same as /y
.test() at .lI or later at .lI same as /y
.replace() ignores & resets .lI at .lI /g w/o gaps
.replaceAll() ignores .lI TypeError /g w/o gaps
.search() no effect no effect no effect
.match() Array of group 0 captures like .exec() /g w/o gaps
{
"suggest.noselect": false,
"coc.preferences.formatOnSaveFiletypes": [
"javascript",
"typescript",
"typescriptreact",
"json",
"javascriptreact",
"typescript.tsx",
"graphql"