Skip to content

Instantly share code, notes, and snippets.

View yuanqing's full-sized avatar

Yuan Qing Lim yuanqing

View GitHub Profile
@yuanqing
yuanqing / build-figma-plugin.main.js
Created August 21, 2022 09:14
Create Figma Plugin: Run Last Plugin
const { exec } = require('child_process')
const esbuildFigmaRunLastPlugin = {
name: 'figma-run-last-plugin',
setup: async function () {
await new Promise(function (resolve, reject) {
exec(
`osascript <<'EOF'
if application "Figma" is running then
tell application "Figma"
tell application "System Events"
tell process "Figma"
set frontmost to true
click menu item "Run last plugin" of menu "Plugins" of menu bar 1
end tell
end tell
$ node index.js
ternary, true x 84,415,848 ops/sec ±2.47% (78 runs sampled)
ternary, false x 73,646,719 ops/sec ±5.86% (73 runs sampled)
&& and ||, true x 78,748,665 ops/sec ±2.80% (72 runs sampled)
&& and ||, false x 80,837,863 ops/sec ±1.84% (81 runs sampled)
Fastest is ternary, true
functional
stateless
immutable
composable
flat
simple
data
serializable
var Polyglot = require('node-polyglot');
var phrases = {
x: 'foo',
y: '%{smart_count} bar |||| %{smart_count} bars'
};
var p = new Polyglot({
locale: 'en',
phrases: phrases
@yuanqing
yuanqing / README.md
Last active September 14, 2015 16:32 — forked from necolas/README.md
Experimenting with component-based HTML/CSS naming and patterns

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name
@yuanqing
yuanqing / gist:8736cef5ca9c613f6eac
Last active September 14, 2015 16:30 — forked from fat/gist:3744369
all you probably really need
/*! normalize-all-you-really-need-tho.css v1.0.0 | MIT License */
html {
font-family: sans-serif; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
body {
margin: 0;
@yuanqing
yuanqing / loadscript.js
Last active September 13, 2015 03:42 — forked from esamattis/loadscript.js
/**
* Simple node.js style script loader for modern browsers
**/
function loadScript(src, cb) {
var script = document.createElement('script');
script.async = true;
script.src = src;
script.onerror = function() {
cb(new Error("Failed to load" + src));

CSS

  • Don't nest if you're using SCSS or LESS, or at least don't nest too much
  • BEM all the things (or use some variant of BEM)
  • Never use an id for styling purposes
  • For JS-specific classes, use .js-foo
  • Use a .text class for paragraphs/running text