Skip to content

Instantly share code, notes, and snippets.

View KevinGutowski's full-sized avatar

Kevin Gutowski KevinGutowski

View GitHub Profile
@KevinGutowski
KevinGutowski / fixphotos.py
Created September 13, 2021 03:37
Update Facebook Photos Export with EXIF data
import os,json,pyexiv2
from datetime import datetime
keypath = 'fbexport/'
path_to_album= keypath+'posts/album/'
json_files = [pos_json for pos_json in os.listdir(path_to_album) if pos_json.endswith('.json')]
for album_json in json_files:
with open(path_to_album+album_json) as f:
@KevinGutowski
KevinGutowski / nameCardsInDeck.lua
Created July 26, 2021 18:56
Name all cards in a deck
function onLoad()
deck = getObjectFromGUID("72a19d")
cards = deck.getObjects()
pos = deck.getPosition()
for index,card in ipairs(cards) do
-- We need to wait each time we pull out a card
-- The amount we wait is increased for each pull
-- Need to handle the last card since the deck doesn't exist at that point
Wait.frames(function()
@KevinGutowski
KevinGutowski / pixels.js
Created July 20, 2021 02:08
Get pixel data from image layer at coordinates
let selection = context.selection[0]
let data = selection.image().data()
let imageRep = NSBitmapImageRep.imageRepWithData(data)
let color = imageRep.colorAtX_y(1,2)
console.log(MSColor.colorWithNSColor(color).CSSAttributeString())
@KevinGutowski
KevinGutowski / getVariantMetadata.js
Last active June 28, 2021 10:01
Get structured names of a ComponentSetNode [Figma API]
// {
// properties: [string],
// property1: { name: string, variants: [string] },
// property2: { name: string, variants: [string] },
// ...
// }
function getVariantMetaData(componetSet) {
let variants = componetSet.children
@KevinGutowski
KevinGutowski / create.js
Created June 8, 2021 06:23
Create Variants Automatically
let selection:FrameNode = figma.currentPage.selection[0]
for (let i=400;i<selection.children.length;i++){
console.log("hello")
createComponentsForChild(selection.children[i],i)
}
function createComponentsForChild(child:FrameNode,index) {
console.log(child)
let glyphs = figma.currentPage.findAll(n=>n.name==child.name)
let components:Array<ComponentNode> = []
@KevinGutowski
KevinGutowski / readTempURLs.js
Created June 8, 2021 03:15
SF Symbols -> Sketch
let sketch = require('sketch')
let ShapePath = sketch.ShapePath
let doc = sketch.getSelectedDocument()
let selectedArtboard = doc.selectedLayers.layers[0]
let pasteboard = NSPasteboard.generalPasteboard()
let items = pasteboard.pasteboardItems()
let urls = pasteboard.readObjectsForClasses_options([NSURL.class()],nil)
for (let i=0;i<urls.count();i++) {
@KevinGutowski
KevinGutowski / read.js
Created May 20, 2021 01:47
Read/Write Sketch objects from the pasteboard
let sketch = require('sketch')
let pasteboard = NSPasteboard.generalPasteboard()
let pboardManager = MSPasteboardManager.applicationPasteboardManager()
let pboardLayers = pboardManager.readPasteboardLayersFromPasteboard_colorSpace_options_convertColorSpace(pasteboard,context.document.colorSpace(),nil,false)
let layerArray = pboardLayers.layers().layers()
let nativeLayers = []
for (let i=0; i<layerArray.count(); i++) {
nativeLayers.push(layerArray[i])
}
@KevinGutowski
KevinGutowski / collectFiles.js
Created May 11, 2021 17:30
Sketch Logs/Crash Files
let path = NSHomeDirectory() + '/Library/Logs/DiagnosticReports/'
let fileManager = NSFileManager.defaultManager()
let files = fileManager.contentsOfDirectoryAtPath_error(path,nil)
let fileNames = []
for (let i=0; i<files.count();i++) {
fileNames.push(files[i])
}
let dateFormatter = NSDateFormatter.alloc().init()
dateFormatter.dateStyle = NSDateFormatterMediumStyle
@KevinGutowski
KevinGutowski / getCrashes.js
Last active May 5, 2021 04:02
Get Sketch Crash Log FilePaths
let path = NSHomeDirectory() + '/Library/Logs/DiagnosticReports/'
let fileManager = NSFileManager.defaultManager()
let files = fileManager.contentsOfDirectoryAtPath_error(path,nil)
let fileNames = []
for (let i=0; i<files.count();i++) {
fileNames.push(files[i])
}
let dateFormatter = NSDateFormatter.alloc().init()
dateFormatter.dateStyle = NSDateFormatterMediumStyle
@KevinGutowski
KevinGutowski / Integration as summation
Created April 5, 2021 23:21
Example MathML output from KaTeX
<!--
Integration as summation
GS LaTeX Code
$$$
\int_a^bf(x)dx = lim_{n\to\infty}\sum_{r=1}^nhf(a+rh)
$$$
$$$
\text{where} \quad h=\frac{b-a}{n}