Skip to content

Instantly share code, notes, and snippets.

@koinzhang
koinzhang / simple-applescript.applescript
Last active June 27, 2024 13:49
Simple AppleScript
-- Show system hidden files
tell application "Finder" to quit
tell application "System Events" to do shell script "defaults write com.apple.finder AppleShowAllFiles -bool true"
tell application "Finder" to launch
-- copy file to clipboard
tell app "Finder" to set the clipboard to (POSIX file "/Users/zhangyongkang/Desktop/Markdown.md")
@marcedwards
marcedwards / displaysizes.txt
Last active November 16, 2023 06:52
iPhone, iPad, and Apple Watch display sizes
### Points and display type
PPI is points per inch below, not pixels per inch. Not all models are listed, just the first model with a new display size. Diamond, RGB Stripe and Pentile RGB refer to the subpixel patterns.
iPhone 1 = 320×480 at 163PPI sRGB IPS LCD RGB Stripe
iPhone 4 = 320×480 at 163PPI sRGB IPS LCD RGB Stripe
iPhone 5 = 320×568 at 163PPI sRGB IPS LCD RGB Stripe
iPhone 6 = 375×667 at 163PPI sRGB IPS LCD RGB Stripe
iPhone 6 Plus = 414×736 at 153.5PPI sRGB IPS LCD RGB Stripe
iPhone 7 = 375×667 at 163PPI P3 IPS LCD RGB Stripe
@KevinGutowski
KevinGutowski / progress.js
Last active November 25, 2020 11:42
Progressbar modal
let documentWindow = NSApplication.sharedApplication().mainWindow()
let mySheetWindow = NSWindow.alloc().initWithContentRect_styleMask_backing_defer(
NSMakeRect(0, 0, 300, 50),
(NSWindowStyleMaskTitled | NSWindowStyleMaskDocModalWindow),
NSBackingStoreBuffered,
true
)
let progressView = NSProgressIndicator
.alloc()
const {toArray} = require('util');
// returns a timestamp
const timeStamp = () => {
const now = new Date();
return `${'0'.concat(now.getHours()).slice(-2)}:${'0'.concat(now.getMinutes()).slice(-2)}:${'0'.concat(now.getSeconds()).slice(-2)}.${now.getMilliseconds().toString().concat('000').slice(0,3)}`;
}
// Assumes an existing text layer called 'debug_output' on the current page that's NOT in a group or artboard
// parameters: the Sketch page object, the thing (or an array of things) to log, whether or not to clear previous logs
@steven2358
steven2358 / ffmpeg.md
Last active September 10, 2024 15:11
FFmpeg cheat sheet
@demersdesigns
demersdesigns / Craft-Lists-for-Sketch.md
Last active March 11, 2021 17:34
A collection of text lists that can be imported into InVision's Craft plugin.

Sketch Image Compressor (Beta)

A Plugin for Sketch that compresses your bitmap assets, to keep filesize to a minimum.

Please note that the compression is lossless, so no pixels will be harmed by running this Plugin : )

Installation

  • Download Sketch Image Compressor & unzip it.
  • Double click Sketch Image Compressor.sketchplugin to install the Plugin.
@getflourish
getflourish / plugin.js
Last active April 12, 2016 01:22
Find & Replace Fonts in Sketch
// define the scope for the search/replace
var artboard = context.document.currentPage().currentArtboard();
var layers = artboard.children();
// this method will list all font names that are used in the scope
function listFontNames() {
@bomberstudios
bomberstudios / README.md
Last active February 16, 2022 03:13
Loading a Cocoa Framework in a Sketch Plugin

This is what Craft does:

function loadFramework(pluginRoot) {
  if (NSClassFromString('PanelsManager') == null) {
    var mocha = [Mocha sharedRuntime];
    return [mocha loadFrameworkWithName:'Panels' inDirectory:pluginRoot];
  } else {
    return true;
 }