Skip to content

Instantly share code, notes, and snippets.

@fwextensions
fwextensions / gist:2927376
Created June 14, 2012 00:33
Code to get the number of chars and words in a text element
var r = [], t;
if (el && el.textRuns) {
t = el.textChars;
r = ["chars:", t.length,"words:", t.split(/\s+/).length];
}
r.join(" ");
@fwextensions
fwextensions / gist:4300987
Created December 15, 2012 23:42
The Adobe Fireworks JavaScript engine has an undocumented File class that has some useful features lacking in the documented Files object.
// to access a file, create a new instance of the File class by passing in
// a standard OS-style path to the constructor. I've only tested this on
// Windows, but a standard path on OS X should work, too.
var f = new File("C:\\test.txt");
// unlike the file references created by the Files object, these have some
// useful properties, like length, which is the file size in bytes
@fwextensions
fwextensions / gist:4759119
Created February 12, 2013 01:01
How to create a new layer at the top of the stack, add objects to it, and lock it.
var dom = fw.getDocumentDOM(),
currentLayerIndex = dom.currentLayerNum,
newLayerIndex;
dom.addNewLayer(null, false);
// currentLayerNum is set to the newly added layer
newLayerIndex = dom.currentLayerNum;
// put the new layer before the last layer. note that this won't work
@fwextensions
fwextensions / gist:4771622
Created February 12, 2013 17:39
How to add a rectangle the same size as the canvas
var dom = fw.getDocumentDOM();
dom.addNewRectangle({ left: 0, top: 0, right: dom.width, bottom: dom.height }, 0);
@fwextensions
fwextensions / gist:5385276
Created April 15, 2013 02:28
PEG.js grammar for the data in SVG paths
svg_path
= wsp* data:moveTo_drawTo_commandGroups? wsp*
{
var result = [];
function flatten(a){
for (var i=0,l=a.length;i<l;++i){
var o=a[i];
if (o.constructor==Array) flatten(o);
else if (o && o!=" ") result.push(o);
}
@fwextensions
fwextensions / background.js
Created November 29, 2017 20:05
Chrome event page
chrome.runtime.onStartup.addListener(() => {
var timer = null;
chrome.tabs.onUpdated.addListener(() => {
clearTimeout(timer);
timer = setTimeout(() => {
addListeners();
}, 50);
});
);
@fwextensions
fwextensions / ctrl-tab.ahk
Last active June 10, 2018 00:45
AutoHotkey script to use ctrl-tab shortcut to control tabs in Chrome with QuicKey: https://fwextensions.github.io/QuicKey/
#NoEnv ;
SetBatchLines, -1 ; Script will never sleep
ListLines Off ; Omits subsequently-executed lines from the history
#KeyHistory 0 ; Disable key history
SendMode Input ; Recommended for new scripts due to its superior speed and reliability
SetTitleMatchMode 2 ;
SetTitleMatchMode Fast ;
SetKeyDelay, -1, -1 ;
#SingleInstance force ; Skips the dialog box and replaces the old instance automatically
@fwextensions
fwextensions / test-qssense.m
Created July 24, 2018 06:30
Bodged together test of QSSense.m
#import <Cocoa/Cocoa.h>
//
// QSense.m
// QSqSense
//
// Created by Alcor on 11/22/04.
// Copyright 2004 Blacktree. All rights reserved.
//
13:30:03.402 gsUtils.js:35 gsStorage 13:30:03 syncedSettings on init: {batteryCheck: false, discardAfterSuspend: false, discardInPlaceOfSuspend: false, gsAddContextMenu: true, gsDontSuspendActiveTabs: true, …}batteryCheck: falsediscardAfterSuspend: falsediscardInPlaceOfSuspend: falsegsAddContextMenu: truegsDontSuspendActiveTabs: truegsDontSuspendAudio: truegsDontSuspendForms: truegsDontSuspendPinned: truegsIgnoreCache: falsegsNoNag: falsegsTheme: "light"gsTimeToSuspend: "60"gsUnsuspendOnFocus: falsegsWhitelist: ""onlineCheck: falsescreenCapture: "0"screenCaptureForce: falsesuspendInPlaceOfDiscard: true__proto__: Object
13:30:03.605 gsUtils.js:35 gsSession 13:30:03
------------------------------------------------
Extension initialization started. isProbablyProfileRestart: false
------------------------------------------------
13:30:03.606 gsUtils.js:35 gsSession 13:30:03 Increasing init timeout to 11mins
13:30:03.799 gsUtils.js:35 gsSession 13:30:03 sessionId: 146083
@fwextensions
fwextensions / gist:cf35acf781058a3fe24e52b3a20af2b9
Created August 27, 2018 23:19
TGS v109 log of blockhead icons
1063 "15:05:22" "response from tab" Object
15:05:22.441 gsUtils.js:35 1063 "15:05:22" "tab updated. " Object
15:05:22.441 gsUtils.js:35 1063 "15:05:22" "Setting tabFlag: unsuspendOnReloadUrl=null"
15:05:22.445 gsUtils.js:35 1063 "15:05:22" "tab updated. " Object
15:05:22.445 gsUtils.js:35 1063 "15:05:22" "Setting tabFlag: unsuspendOnReloadUrl=null"
15:05:22.446 gsUtils.js:35 1063 "15:05:22" "send message to tab" Object
15:05:22.498 gsUtils.js:35 1063 "15:05:22" "tab updated. " Object
15:05:22.498 gsUtils.js:35 1063 "15:05:22" "Setting tabFlag: unsuspendOnReloadUrl=null"
15:05:22.501 gsUtils.js:35 1063 "15:05:22" "tab updated. " Object
15:05:22.501 gsUtils.js:35 1063 "15:05:22" "Setting tabFlag: unsuspendOnReloadUrl=null"