Skip to content

Instantly share code, notes, and snippets.

View studentIvan's full-sized avatar
🎯
Focusing

Ivan Maslov | JavaScript & Web Performance Enthusiast studentIvan

🎯
Focusing
View GitHub Profile
@studentIvan
studentIvan / dynamic.ts
Created February 4, 2025 17:13
Simple replace next/dynamic with this function to silent the Application Error. Tested on next 15.1.6
import nextDynamic, { DynamicOptions, Loader } from "next/dynamic";
/**
* This is a dynamic function patch for next/dynamic.
* This function will try to load the chunk again after a cooldown time.
* It also allows to show null instead of the fullscreen "Application Error".
*
* @see https://github.com/vercel/next.js/issues/38507
* @see https://github.com/vercel/next.js/issues/56484
* @see https://github.com/vercel/next.js/issues/63918
@studentIvan
studentIvan / config.mjs
Created November 25, 2024 12:09
Пишу своего бота для борьбы со спамом в telegram, вот текущий список стоп-слов, которые использую для бана, возможно кому-то поможет
export const inclusionsForSpam = [...new Set([
"опыт работы",
"набираем людей",
"людей в команду",
"набираю людей",
"игровая платформа",
"шанс выигрыша",
"шанс выйгрыша",
"уровень доxода",
"денег заработать",
@studentIvan
studentIvan / server.ts
Created October 10, 2023 23:53
Example next.js custom server with headers taken from the page meta tags to solve the problem https://github.com/vercel/next.js/issues/50914
import { createServer, type IncomingMessage, type ServerResponse } from "http";
import { StringDecoder } from "string_decoder";
import { parse } from "url";
import next from "next";
import nextConfig from "../next.config";
const decoder = new StringDecoder("utf-8");
@studentIvan
studentIvan / start.applescript
Created June 21, 2021 13:59
Helpful developer's bash applescript (osascript) to open the tab with the specific url inside the google chrome new or reloaded. It may check the app running on the same port also and re-use this tab.
-- using example:
-- sleep 10 && osascript start.applescript "http://local.${PROJECT_DOMAIN}.com:8080" 8080 &
-- yarn start
on run argv
tell application "Google Chrome"
activate
set targetURL to (item 1 of argv)
-- I know I can parse it but I'm too lazy...
set targetPort to (item 2 of argv)
@studentIvan
studentIvan / pcss-plugin-variables-rename.js
Created June 17, 2021 12:28
Postcss plugin variables rename
/* eslint-disable no-plusplus */
/* eslint-disable func-names */
/* eslint-disable no-restricted-syntax */
const fs = require('fs');
const path = require('path');
/** load the existing json map with access to write and read */
const variablesMapJSON = path.join(__dirname, '/variables-map.json');
/**
@studentIvan
studentIvan / number-to-price.js
Created December 11, 2020 18:58
Price format super fast function by @studentIvan (Ivan Maslov)
/** [E]UR, [S]EK, [G]PB, [P]LN, [D]KK, NOK, CHF, [U]SD, [CA]D */
const defaultNumberToPriceFn = function numberToPrice(n, c) {
let smb = c || this.currency;
if (smb[0] === 'E') { smb = '€'; }
else if (smb[0] === 'U' || (smb[0] === 'C' && smb[1] === 'A')) { smb = '$'; }
else if (smb[0] === 'S' || smb[0] === 'D') { smb = 'kr'; }
else if (smb[0] === 'G') { smb = '£'; }
else if (smb[0] === 'P') { smb = 'zł'; }
const nR = Math.round(+(n || 0) * 100) / 100;
const nStr = nR.toString();
@studentIvan
studentIvan / mobile.preact.config.js
Last active May 18, 2020 18:22
Preact 8 with CLI configuration example. (the default configuration passed with --config is a web.preact.config.js)
/* eslint-disable */
import path from 'path';
import fs from 'fs';
import webpack from 'webpack';
import HtmlWebpackInlineSVGPlugin from 'html-webpack-inline-svg-plugin';
import SVGSpritemapPlugin from 'svg-spritemap-webpack-plugin';
// import { WebpackBundleSizeAnalyzerPlugin } from 'webpack-bundle-size-analyzer';
import packageData from '../../package.json';
import pathsResolveConfig from './paths.resolve.config';
import appPackageData from '../../../mobile-app/package.json';
@studentIvan
studentIvan / mobile.preact.config.js
Created May 18, 2020 18:19
Preact 8 with CLI configuration example.
/* eslint-disable */
import path from 'path';
import fs from 'fs';
import webpack from 'webpack';
import HtmlWebpackInlineSVGPlugin from 'html-webpack-inline-svg-plugin';
import SVGSpritemapPlugin from 'svg-spritemap-webpack-plugin';
// import { WebpackBundleSizeAnalyzerPlugin } from 'webpack-bundle-size-analyzer';
import packageData from '../../package.json';
import pathsResolveConfig from './paths.resolve.config';
import appPackageData from '../../../mobile-app/package.json';
@studentIvan
studentIvan / instructions.txt
Last active May 21, 2020 18:36
Fast solution to replace the node-spdy package using with the express.js on the node v12. Development purposes only!
1. npm uninstall spdy
2. npm install http2-proxy finalhandler
3. replace the code
import spdy from 'spdy';
spdy.createServer(HTTP2_OPTIONS, app).listen(HTTP2_PORT, (error) => { ...
with
@studentIvan
studentIvan / cloudSettings
Last active May 12, 2020 11:51
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-05-12T11:51:27.444Z","extensionVersion":"v3.4.3"}