Skip to content

Instantly share code, notes, and snippets.

@peterflynn
peterflynn / Useful GitHub bookmarklets
Last active August 30, 2023 06:54
GitHub comment thread bookmarklets
To use: create a new bookmark and paste into the URL field.
In Chrome, you can paste the full multiline code as shown below.
In other browsers, you may need to minify the code into one line first.
@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 / bookmarklet.js
Last active February 13, 2019 16:10
Bookmarklet to expand all collapsed comments in a GitHub pull request (places where it says "discussed an outdated diff")
// DEPRECATED: See "Expand All Comments" at https://gist.github.com/peterflynn/ace5dd3d7a8ec645cd42 for
// a more up to date, maintained version of this.
// Original bookmarklet from this gist (does not work anymore):
// javascript:(function() { $(".outdated-diff-comment-container").addClass("open"); }());
// Newer, working version (from link above as of Jan 2017):
// javascript:(function() { document.querySelectorAll(".outdated-diff-comment-container").forEach(function(n) {n.classList.add("open")}) }());
@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
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 / 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