This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hasSmoothScrollFeat = true | |
| function scrollToSmootly(container: Element, x: number, y: number) { | |
| if (hasSmoothScrollFeat) { | |
| try { | |
| container.scrollTo({behavior:"smooth", top:y, left:x}) | |
| return | |
| } catch (_) { | |
| hasSmoothScrollFeat = false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class EventEmitter<Events, K = keyof Events|symbol> { | |
| addListener(event: K, listener: (...args: any[]) => void): this; | |
| on(event: K, listener: (...args: any[]) => void): this; | |
| once(event: K, listener: (...args: any[]) => void): this; | |
| removeListener(event: K, listener: (...args: any[]) => void): this; | |
| removeAllListeners(event?: K): this; | |
| setMaxListeners(n: number): this; | |
| getMaxListeners(): number; | |
| listeners(event: K): Function[]; | |
| emit(event: K, ...args: any[]): boolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rafThrottler(callback) { | |
| let rafId = null; | |
| const flush = () => { | |
| callback(); | |
| rafId = null; | |
| }; | |
| return () => { | |
| if (rafId) { | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // return array of [r,g,b,a] from any valid color. if failed returns undefined | |
| function colorValues(color) | |
| { | |
| if (!color) | |
| return; | |
| if (color.toLowerCase() === 'transparent') | |
| return [0, 0, 0, 0]; | |
| if (color[0] === '#') | |
| { | |
| if (color.length < 7) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| cd "$(dirname "$0")" | |
| SRCDIR=$(pwd) | |
| OUTDIR=$SRCDIR/cursors | |
| mkdir -p "$OUTDIR" | |
| cd /System/Library/Frameworks/ApplicationServices.framework/Frameworks/HiServices.framework/Resources/cursors | |
| # if !(which pdf2svg); then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "content_scripts": [ | |
| { | |
| "matches": ["http://*/*", "https://*/*"], | |
| "js": ["inject.js"], | |
| "all_frames": true | |
| } | |
| ], | |
| "web_accessible_resources": [ | |
| "content.js" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sketch = context.api() | |
| var MAX_CHARS = 60 | |
| var document = sketch.selectedDocument | |
| var selection = document.selectedLayers | |
| var renamedTextLayers = false | |
| selection.iterate(function(item) { | |
| if (!item.isText) { | |
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let rafId; | |
| function scrollToElement(el, offsetTop = 0) { | |
| scrollByValue(el.getBoundingClientRect().top - offsetTop); | |
| } | |
| function scrollByValue(offsetTop = 0) { | |
| if (offsetTop !== 0) { | |
| if (rafId) { | |
| cancelAnimationFrame(rafId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on sansExt(theFileName) | |
| do shell script "file=" & theFileName & ";" & "echo ${file%.*}" | |
| end sansExt | |
| on getExt(theFileName) | |
| do shell script "file=" & theFileName & ";" & "echo ${file##*.}" | |
| end getExt | |
| on run argv | |
| set keynote_path to (item 1 of argv) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const PAGE_HEIGHT = 700; | |
| const PAGE_WIDTH = 500; | |
| const content = []; | |
| function getPngDimensions (base64) { | |
| const header = atob(base64.slice(22, 70)).slice(16, 24); | |
| const uint8 = Uint8Array.from(header, c => c.charCodeAt(0)); | |
| const dataView = new DataView(uint8.buffer); |