Skip to content

Instantly share code, notes, and snippets.

@peterflynn
peterflynn / main.js
Created October 15, 2018 01:36
XD Plugins - part 3 finished code
/*
* Sample plugin code for Adobe XD.
*
* Visit http://adobexdplatform.com/ for API docs and more sample code.
*/
var {Rectangle, Color} = require("scenegraph");
var dialog;
@peterflynn
peterflynn / main.js
Created October 15, 2018 01:30
XD Plugins - part 2 finished code
/*
* Sample plugin code for Adobe XD.
*
* Visit http://adobexdplatform.com/ for API docs and more sample code.
*/
var {Rectangle, Color} = require("scenegraph");
function createRectangle(selection) {
var textNode = selection.items[0];
var fs = require("uxp").storage.localFileSystem;
function loadStyleguideFile(selection) {
return fs.getFileForOpening()
.then(function (file) {
console.log("User chose file: " + file);
return file.read();
})
.then(function (text) {
var json = JSON.parse(text);
@peterflynn
peterflynn / Step 1.js
Last active November 2, 2018 17:22
XD Plugin UI Examples
var dialog;
function createDialog() {
dialog = document.createElement("dialog");
dialog.innerHTML = `
<form method="dialog">
<h1>Hello, world!</h1>
<hr>
<footer>
<!-- Ok button is special: it will automatically close the dialog for us -->
@peterflynn
peterflynn / main.js
Last active October 12, 2018 20:19
XD Starter Plugin
/*
* Sample plugin code for Adobe XD.
*
* Visit http://adobexdplatform.com/ for API docs and more sample code.
*/
var {Rectangle, Color} = require("scenegraph");
function createRectangle(selection) {
// Insert a red square in the current artboard or group/container
diff --git a/Base.lproj/Main.storyboard b/Base.lproj/Main.storyboard
index 5344907..1f78691 100644
--- a/Base.lproj/Main.storyboard
+++ b/Base.lproj/Main.storyboard
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="9060" systemVersion="14F1021" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
+<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
@peterflynn
peterflynn / C++ Pointer Syntax Cheatsheet.cpp
Created September 16, 2015 20:36
C++ Pointer Syntax Cheatsheet
// If "const" is to the LEFT of "*" it applies to the object being pointed at
// If "const" is to the RIGHT of "*" it applies to the variable holding the pointer address
const T* ptr; // object is immutable
T const* ptr; // "
T* const ptr; // 'ptr' cannot be changed to point to a different address, but object is not immutable
// (i.e. the variable is const, not the thing it points to)
const T* const ptr; // object is immutable AND 'ptr' cannot be changed to point to a different address
@peterflynn
peterflynn / Objective-C syntax cheatsheet.m
Last active January 3, 2017 21:55
Objective-C syntax cheatsheet
// Can omit the whole @interface section if no private fields/properties to declare
@interface MyClass () // parens are almost always empty - used only to define a "Category" when adding mixins to existing class definition
{
int foo; // private field (not common) - access as 'foo'
} // can omit these {}s if no private fields
@property (nonatomic) int foo2; // private property - access as 'self.foo2'
// Any property (private or public) can also be accessed within the class as "_foo2" (without "self"). This bypasses the getter/setter
// methods and accesses it directly like an ivar. Since the getter/setter are usually auto-generated stubs, there's usually no behavior
// difference with this syntax.