Skip to content

Instantly share code, notes, and snippets.

View LukeFinch's full-sized avatar

Luke Finch LukeFinch

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Arrow_1_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<rect id="_x3C_BG_x3E_" fill="none" width="24" height="24"/>
<g id="_x3C_Path_x3E_">
<path d="M5.68,23.96c-0.49,0-0.97-0.2-1.32-0.6c-0.64-0.73-0.57-1.83,0.16-2.47L14.66,12L4.52,3.11C3.8,2.47,3.72,1.36,4.36,0.64
C5-0.09,6.1-0.16,6.83,0.48L19.97,12L6.83,23.52C6.5,23.81,6.09,23.96,5.68,23.96z"/>
</g>
</svg>
var kinoJoined = false
client.on('join', (channel, username, self) => {
if(username == 'kinotheproducer'){
kinoJoined = true
}
})
client.on('message', (channel, userstate, message, self) => {
if (self) return
const arrayOfDads = ['lcfinch','kinotheproducer','iplayforcharity']
client.on('message', (channel, userstate, message, self) => {
if (self) return
if (
arrayOfDads.indexOf(userstate.username) > -1){
client.say(channel, 'Hey Dad')
arrayOfDads.splice(arrayOfDads.indexOf(userstate.username))
}
}
const developerColorNames = [
"shadowColor",
"labelColor",
"secondaryLabelColor",
"tertiaryLabelColor",
"quaternaryLabelColor",
"systemRedColor",
"systemGreenColor",
"systemBlueColor",
"systemOrangeColor",
@LukeFinch
LukeFinch / NewsKit - Set Ink Colours.js
Created May 2, 2020 16:38
A Sketch script for NewsKit libraries that updates the colours of text styles by inheriting them from ink styles in the system
var sketch = require("sketch");
var SharedStyle = require('sketch/dom').SharedStyle
var Style = require('sketch/dom').Style
var document =sketch.getSelectedDocument()
function getSharedStyles(type) {
var myStyles = []
if (sketch.version.sketch < 52) {
var styles = (type == 0) ? MSDocument.currentDocument().documentData().layerStyles().objects() : MSDocument.currentDocument().documentData().layerTextStyles().objects();
} else {
@LukeFinch
LukeFinch / SketchStyles-Figma.js
Last active June 5, 2020 10:17
Extract TextStyles from Sketch document and output into a Figma friendly format
var sketch = require('sketch')
var Document = require('sketch/dom').Document
var document = Document.getSelectedDocument()
var texts = []
var paints = []
var output = {}
//Sketch's document.getTextStyles() doesn't return all the info.
{
"gradientDark010": "linear-gradient(90deg, rgba(48, 49, 49, 0) 0%, rgba(48, 49, 49, 1) 100%)",
"gradientLight010": "linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%)",
"overlayDark010": "rgba(48, 49, 49, 0.2)",
"overlayDark020": "rgba(48, 49, 49, 0.4)",
"overlayDark030": "rgba(48, 49, 49, 0.6)",
"overlayDark040": "rgba(48, 49, 49, 0.8)",
"overlayDark110": "rgba(48, 49, 49, 0.2)",
"overlayDark120": "rgba(48, 49, 49, 0.4)",
"overlayDark130": "rgba(48, 49, 49, 0.6)",
@LukeFinch
LukeFinch / SketchPlugin-Text-Crop.js
Created July 2, 2020 13:17
Sketch Script to crop text to remove whitespace on the line.
var doc = context.document
var Text = require('sketch/dom').Text
var page = MSDocument.currentDocument().currentPage();
var fontFamilies = ['Monaco','Helvetica-Black']
fontFamilies.forEach(fam => {console.log(getCropsForFontFamily(fam))})
@LukeFinch
LukeFinch / Split Categories.js
Created July 6, 2020 15:26
Add a line break between categories in a JSON string.
function splitWords(s) {
var re, match, output = [];
// re = /[A-Z]?[a-z]+/g
re = /([A-Za-z]?)([a-z]+)/g;
match = re.exec(s);
while (match) {
output.push([match[1].toUpperCase(), match[2]].join(""));
match = re.exec(s);
}
let sel = context.selection
sel.forEach(layer => {
layer.frame = layer.parentArtboard().frame()
if(layer.class() == 'MSTextLayer'){
let txt = layer.stringValue()
layer.stringValue = 'T'
layer.frame().y = layer.frame().y() - (layer.pathInFrame().bounds().origin.y - layer.frame().y())
layer.stringValue = txt
}