Skip to content

Instantly share code, notes, and snippets.

@LukeFinch
LukeFinch / rotate-center.js
Created January 6, 2021 11:15
figma plugin to rotate selection around the center of itself.
let angle = 45
let theta = angle * (Math.PI/180) //radians
let sel = figma.currentPage.selection[0]
//cx,cy is the center of the node
let cx = sel.x + sel.width/2
let cy = sel.y + sel.height/2
let newx = Math.cos(theta) * sel.x + sel.y * Math.sin(theta) - cy * Math.sin(theta) - cx * Math.cos(theta) + cx
let newy = - Math.sin(theta) * sel.x + cx * Math.sin(theta) + sel.y * Math.cos(theta) - cy * Math.cos(theta) + cy
@jagrosh
jagrosh / Github Webhook Tutorial.md
Last active July 21, 2024 06:29
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@dchowitz
dchowitz / es6-debugging-in-vscode.md
Last active August 30, 2023 06:23
Debugging ES6 in VS Code

Debugging ES6 in VS Code

My current editor of choice for all things related to Javascript and Node is VS Code, which I highly recommend. The other day I needed to hunt down a bug in one of my tests written in ES6, which at time of writing is not fully supported in Node. Shortly after, I found myself down the rabbit hole of debugging in VS Code and realized this isn't as straightforward as I thought initially. This short post summarizes the steps I took to make debugging ES6 in VS Code frictionless.

What doesn't work

My first approach was a launch configuration in launch.json mimicking tape -r babel-register ./path/to/testfile.js with babel configured to create inline sourcemaps in my package.json. The debugging started but breakpoints and stepping through the code in VS Code were a complete mess. Apparently, ad-hoc transpilation via babel-require-hook and inline sourcemaps do not work in VS Code. The same result for attaching (instead of launch) to `babel-node

@tobiasstrebitzer
tobiasstrebitzer / bower.json
Created June 30, 2015 03:24
Polymer 1.0 Global Variables Behavior
{
"name": "polymer-globals-behavior",
"dependencies": {
"polymer": "Polymer/polymer#~1.0.5"
}
}
@olmokramer
olmokramer / css-color-regex
Last active December 9, 2023 12:52
Regex for CSS colors: hex, rgb(a), hsl(a)
/(#([0-9a-f]{3}){1,2}|(rgba|hsla)\(\d{1,3}%?(,\s?\d{1,3}%?){2},\s?(1|0?\.\d+)\)|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?\)){2})/i
@soarez
soarez / deploy.bash
Last active September 23, 2019 16:15
#!/bin/bash
function deploy {
# Update the rsync target on the server
rsync \
-av \
--delete \
--delete-excluded \
$rsync_ignore_list_param \
$rsync_source/ $target:$rsync_target
@tracker1
tracker1 / 01-directory-structure.md
Last active July 17, 2024 07:09
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
@koenbok
koenbok / server.command
Created August 2, 2014 11:48
Web Server for Framer
#!/usr/bin/env python
"""
Copyright (c) 2014 Koen Bok / Podium BV / framerjs.com
Small web server script that you can drop in and run from every Framer Studio
project to serve it to the browser over http. This is great if you want to avoid
same origin policy errors in the browser, but also nice to preview it on another
device connected to the same network.
@jemgold
jemgold / app.coffee
Created July 30, 2014 12:32
class-based Framer prototypes
# An example with classes building components.
# This stuff is a little fiddly to get set up,
# but once it's working it's great - you can just
# add new instances of the components, and each
# components holds references to all of its
# children. You can set defaults & states for each
# component separately.
#
# (try clicking on the post author, and then on each
# of the comments on a post)
@elliottkember
elliottkember / AppStateMachine.coffee
Last active August 9, 2018 14:32
A simple application framework for Framer
EventEmitter = (require?("./EventEmitter") || Framer).EventEmitter
class AppStateMachine extends EventEmitter
constructor: ->
@states = []
# Start the state machine with the document's hash, or the given route
start: (name) ->
@go if document.location.hash then document.location.hash[1..-1] else name