Skip to content

Instantly share code, notes, and snippets.

View yuanqing's full-sized avatar

Yuan Qing Lim yuanqing

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[]>()
@svallory
svallory / README.md
Created October 25, 2021 00:26
Figma Plugin Development Live Reload

Figma Plugin Development Live Reload

  1. Create a run-plugin.sh somewhere in your project
  2. Copy the code from the run-plugin.sh file in this gist
  3. Install nodemon with yarn add --dev nodemon
  4. Add a script in the scripts property of your package.json replacing PLUGIN_CODE_FOLDER by the path to the folder where your plugin code lives
    "scripts": {
    

"livereload": "nodemon --watch PLUGIN_CODE_FOLDER --exec run-plugin.sh"

@sindresorhus
sindresorhus / esm-package.md
Last active May 24, 2024 02:36
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@spjpgrd
spjpgrd / Quick List - My Sketch Plugins.md
Last active August 6, 2018 21:09
These are the plugins I can count on to get the job done. Now, since there is such a huge variety, don't feel like you have to take my word and download every single one. Even I don't have every one of these installed on my machine right now 🙃

Quick List: My Sketch Plugins

My Sketch Plugins

First, download Sketch Runner to help you install these plugins easier. It's like Spotlight (or Alfred) for Sketch.

These are the plugins I can count on to get the job done. Now, since there is such a huge variety, don't feel like you have to take my word and download every single one. Even I don't have every one of these installed on my machine right now 🙃

This was compiled for the attendees of "A Really Good Beginner Sketch Workshop for Designers" for the Columbus Web Group, but why not share the love?

Alrighty, on the with the show 🎉

@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
'use strict';
var str = 'foobarbaz';
var regexp = /bar/;
console.log(str.match(regexp)); //=> [ 'bar', index: 3, input: 'foobarbaz' ]
console.log(regexp.exec(str)); //=> [ 'bar', index: 3, input: 'foobarbaz' ]
console.log(regexp.test(str)); //=> true
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@ftrain
ftrain / actually.js
Last active November 10, 2023 01:16
A program that generates actuallies
/*
actually.js
_ _ _
__ _ __ _ __ _ __ _ ___| |_ _ _ __ _| | |_ _
/ _` |/ _` |/ _` |/ _` |/ __| __| | | |/ _` | | | | | |
| (_| | (_| | (_| | (_| | (__| |_| |_| | (_| | | | |_| |_
\__,_|\__,_|\__,_|\__,_|\___|\__|\__,_|\__,_|_|_|\__, ( )
|___/|/
*/
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results