Skip to content

Instantly share code, notes, and snippets.

View maksimr's full-sized avatar
🎯
Focusing

Maksim Ryzhikov maksimr

🎯
Focusing
View GitHub Profile
// @ts-check
main();
/**
* @returns {Promise<void>}
*/
async function main() {
/**@type {{version?: string; output?: string; help?: boolean}}*/
const options = {};
<#
.SYNOPSIS
# Runs Gradle Wrapper from any project's subdirectory
#>
function gradlew {
$Local:currentDir = Get-Location
$Local:gradlew = $null
$Local:dirStack = @()
while ($null -ne $currentDir) {
$dirStack += $currentDir
@maksimr
maksimr / index.ts
Created October 3, 2024 12:59
SortedMap on JavaScript
async function main() {
const myMap = createSortedMap<number, string>([], ([leftKey], [rightKey]) => {
return leftKey - rightKey;
});
myMap.set(2, 'b');
myMap.set(1, 'a');
myMap.set(3, 'c');
const assert = require('assert');
@maksimr
maksimr / index.js
Last active September 23, 2024 09:43
count lines in nodejs
//@ts-check
async function main() {
const assert = require('assert');
(/**@type {[number, string][]}*/([
[0, ''],
[1, ' '],
[1, '1'],
[1, '\n'],
[1, '\r'],
@maksimr
maksimr / index.mjs
Last active June 6, 2024 08:24
rxjs-1
// @ts-check
import { Observable, of, from, reduce, mergeMap } from 'rxjs'
type IObjectNode = { value: number };
const arr1 = new Observable<IObjectNode[]>(subscriber => {
setInterval(() => {
subscriber.next([
createObjectNode(),
async function fetchZip(url, outDir) {
const os = require('os');
const path = require('path');
const fs = require('fs');
const AdmZip = require("adm-zip");
const pipeline = require('stream/promises').pipeline;
const zipName = path.basename(url);
const zipFilePath = path.join(os.tmpdir(), zipName);
const response = await fetch(url);
async function main() {
const fs = require('fs/promises');
const os = require('os');
const path = require('path');
const promisify = require('util').promisify;
const babelParentDir = path.resolve(__dirname, '..', 'packages');
const babelParserDir = path.join(babelParentDir, 'babel-parser')
const babelPackageName = '@packages/babel-parser';
const babelOutDir = 'lib';
const fs = require('node:fs/promises');
const assert = require('node:assert/strict');
const windowNewlineRegexp = /\r/g;
function replaceWindowsLineEndings(str) {
return str.replace(windowNewlineRegexp, '');
}
function getSnapshotPath(filename) {
@maksimr
maksimr / nix-on-macos-catalina.md
Created January 24, 2024 18:35 — forked from chriselsner/nix-on-macos-catalina.md
Nix on macOS Catalina

Nix on macOS Catalina

I'm writing this gist for my own records but it might help someone else too.

Installing Nix

Support for Catalina has improved a lot since the update was first rolled out.

Note: See the NixOS manual for discussion of the --darwin-use-unencrypted-nix-store-volume option.

@maksimr
maksimr / index.ts
Last active January 5, 2024 09:12
ansicolor typescript
function ansicolor(str: string, colour:
| 0 // all attributes off
| 1 // bold on
| 4 // underline on
| 5 // blink on
| 21 // bold off
| 24 // underline off
| 25 // blink off
| 30 // bloack foreground
| 31 // red foreground