Skip to content

Instantly share code, notes, and snippets.

Avatar
🐹
Working from home

Alex Kanunnikov lifeart

🐹
Working from home
View GitHub Profile
@lifeart
lifeart / readme.md
Last active Nov 22, 2022
material ui @mui imports transforment
View readme.md

To run:

npx jscodeshift ./src -t ./shifter.ts --extensions=tsx --parser=tsx -p

Not covered cases:

import capitalize from '@mui/utils/capitalize’;
@lifeart
lifeart / instrument-test-build.js
Created Nov 21, 2022
Instrument vite build using nyc
View instrument-test-build.js
// @ts-check
const fs = require('fs');
const path = require('path');
const os = require('os');
var { spawn } = require('child_process');
const systemCpuCores = os.cpus();
const pathToArtifacts = path.join(__dirname, '..', 'build', 'assets');
const processes = systemCpuCores.length > 1 ? systemCpuCores.length - 1 : 1;
@lifeart
lifeart / index.js
Created Feb 7, 2022
v2 addon migrator
View index.js
import path from 'path';
import os from 'os';
import fs from 'fs-extra';
// https://github.com/embroider-build/embroider/blob/main/PORTING-ADDONS-TO-V2.md
async function migrate(entry) {
const { default: walkSync } = await import('walk-sync');
const files = () => walkSync(entry, {
ignore: [
'.git',
View launch.json
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"resolveSourceMapLocations": null,
"sourceMaps": true,
View controllers.application\.js
import Controller from '@ember/controller';
import { htmlSafe } from '@ember/template';
export default class ApplicationController extends Controller {
appName = htmlSafe('Ember <br> Twiddle');
}
@lifeart
lifeart / index.js
Created Dec 2, 2021
Ember-auto-import chunk recorder (in-repo-addon)
View index.js
'use strict';
// eslint-disable-next-line node/no-extraneous-require
const { MergeTrees } = require('broccoli-merge-trees');
// eslint-disable-next-line node/no-extraneous-require
const Plugin = require('broccoli-plugin');
const fs = require('fs');
const path = require('path');
class ChunksWriter extends Plugin {
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { getOwner } from '@ember/application';
import { cached } from 'tracked-toolbox';
import { scheduleOnce } from '@ember/runloop';
const Observers = [];
class BasicObserver {
tags = [];
cb = null;
View example.js
async function request() {
const PromiseState = new WeakMap();
const resolveTimers = new Array(10).fill(null).map(() => Math.random() * 10000);
const rejectTImers = new Array(10).fill(null).map(() => Math.random() * 10000);
const promiseArgs = resolveTimers.map((_, i) => [resolveTimers[i], rejectTImers[i]]);
let promises = promiseArgs.map(([resolveTimeout, rejectTimeout]) => {
@lifeart
lifeart / readme.md
Created Nov 10, 2021
Template autotracking
View readme.md

Let's assume we have autotracking chain implementation. In general, we could be able to mark "accessed" properties, we could introduce "addToChain" function with 2 arguments,

1.) object (context) 2.) property we trying to access (on object)

like:

View debug.json
{
"version":"0.1.0",
"configurations":[
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",