Skip to content

Instantly share code, notes, and snippets.

View yagudaev's full-sized avatar

Michael Yagudaev yagudaev

View GitHub Profile
import { emit, on, once } from "@create-figma-plugin/utilities"
export type AsyncActionType<F extends (...args: any) => any> = F
export type SyncActionType<F extends (...args: any) => any> = (
...args: Parameters<F>
) => Promise<ReturnType<F>>
let lastCallerId = 0
let lastSubscriptionId = 0
const subscriptions = new Map<string, Function[]>()
@yagudaev
yagudaev / src_main_index.ts
Last active February 5, 2024 11:39
Firebase with Figma Storage Example
figma.ui.onmessage = async (msg, props) => {
if (originalOnMessage && isArray(msg)) {
originalOnMessage.apply(null, [msg, props])
return
}
switch (msg.type) {
case "req-read-local-storage":
await readLocalStorage(msg.data)
// figma.closePlugin()
@yagudaev
yagudaev / setPropertyFill.test.ts
Created August 9, 2022 21:48
Figma convert `gradientHandlePositions` to `transformGradient` and vice-versa
import {
convertGradientHandlesToTransform,
convertTransformToGradientHandles
} from "./setPropertyFill"
describe("convertGradientHandlesToTransform", () => {
it("identity matrix", () => {
expect(
convertGradientHandlesToTransform([
{
@yagudaev
yagudaev / tsconfig.json
Created July 22, 2022 18:58
Forgiving TSConfig for a NextJS project - Perfect for beginners to TS or prototyping
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
import HtmlWebpackInlineSourcePlugin from "@effortlessmotion/html-webpack-inline-source-plugin"
import HtmlWebpackPlugin from "html-webpack-plugin"
import path from "path"
import { fileURLToPath } from "url"
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
export default (env, argv) => ({
mode: argv.mode === "production" ? "production" : "development",
@yagudaev
yagudaev / @firebase+auth+0.19.5.patch
Last active January 16, 2022 20:21
Firebase v9 Optimization
diff --git a/node_modules/@firebase/auth/dist/esm2017/index-1679a2b2.js b/node_modules/@firebase/auth/dist/esm2017/index-1679a2b2.js
index f7425cb..ca821f2 100644
--- a/node_modules/@firebase/auth/dist/esm2017/index-1679a2b2.js
+++ b/node_modules/@firebase/auth/dist/esm2017/index-1679a2b2.js
@@ -9055,7 +9055,8 @@ class BrowserPopupRedirectResolver {
}
get _shouldInitProactively() {
// Mobile browsers and Safari need to optimistically initialize
- return _isMobileBrowser() || _isSafari() || _isIOS();
+ // return _isMobileBrowser() || _isSafari() || _isIOS();
@yagudaev
yagudaev / elasticsearch.sh
Created August 26, 2020 16:17
Install a specific version of elastic search using Homebrew
brew tap elastic/tap
# picks a specific version
cd /usr/local/Homebrew/Library/Taps/elastic/homebrew-tap
git fetch --tags
git checkout tags/v7.2.0
cd -
HOMEBREW_NO_AUTO_UPDATE=1 brew install elastic/tap/elasticsearch-full
@yagudaev
yagudaev / cypress_support_hooks.js
Last active September 16, 2021 08:46
Cypress Fetch Support Workaround - replaces fetch request with traditional XHR so cypress can track them
// cypress/support/hooks.js
// Cypress does not support listening to the fetch method
// Therefore, as a workaround we polyfill `fetch` with traditional XHR which
// are supported. See: https://github.com/cypress-io/cypress/issues/687
enableFetchWorkaround()
// private helpers
function enableFetchWorkaround() {
let polyfill
@yagudaev
yagudaev / files_controller.rb
Created January 31, 2019 09:26
For presentation
class Api::V1::FilesController < ActiveStorage::DirectUploadsController
skip_forgery_protection
end
@yagudaev
yagudaev / cypress-taking-shortcuts.js
Created January 21, 2019 20:35
Testing Your Frontend with Cypress.io Framework
// cypress/support/commands.js
Cypress.Commands.add('login', (email, password) => {
cy.request({
method: 'POST',
url: 'http://localhost:300/api/v1/users/login',
body: {
user: {
email,
password
}