Skip to content

Instantly share code, notes, and snippets.

View TracyYXChen's full-sized avatar
🎧
Focusing

TracyYXChen

🎧
Focusing
View GitHub Profile
@msievers
msievers / ungroup_grouped_objects_in_fabricjs.js
Last active October 14, 2022 12:46
Ungroup programatically grouped objects in fabric.js (simply past this code into the "execute" tab of fabricjs kitchensink demo)
// clear canvas
canvas.clear();
// add red rectangl
canvas.add(new fabric.Rect({
width: 50, height: 50, left: 50, top: 50, fill: 'rgb(255,0,0)'
}));
canvas.add(new fabric.Rect({
width: 50, height: 50, left: 110, top: 50, fill: 'rgb(255,0,0)'
@tracker1
tracker1 / 01-directory-structure.md
Last active June 17, 2024 15:54
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@emmiep
emmiep / puppeteer-demo1.js
Created March 3, 2018 15:29
Use puppeteer to get coordinates of an element
const Puppeteer = require('puppeteer');
(async () => {
const browser = await Puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
const header = await page.$('h1');
const rect = await page.evaluate((header) => {
const {top, left, bottom, right} = header.getBoundingClientRect();