// jQuery
$(document).ready(function() {
// code
})
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
| # Create a promise: | |
| myCoolPromise = new Promise (resolve, reject) -> | |
| # do a thing | |
| success = true | |
| if success | |
| resolve 'stuff worked' | |
| else | |
| reject Error 'it broke' |
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
| if Utils.isDesktop() is true | |
| HTMLPreviewBackground = new Layer | |
| backgroundColor: "#2d383e" | |
| HTMLPreview = Screen | |
| Screen = new Layer | |
| width: 750 | |
| height: 1334 | |
| clip: true |
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
| <script> | |
| // A minimal polyfill for copying text to clipboard that works most of the time in most capable browsers. | |
| // Note that: | |
| // - You may not need this. `navigator.clipboard.writeText()` works directly in all modern browsers as of 2020. | |
| // - In Edge, this may call `resolve()` even if copying failed. | |
| // - In Safari, this may fail if there is nothing selected on the page. | |
| // See https://github.com/lgarron/clipboard-polyfill for a more robust solution. | |
| // | |
| // License for this Gist: public domain / Unlicense | |
| function writeText(str) { |
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
| import fetch, { | |
| Response } from 'node-fetch'; | |
| import qs from 'querystring'; | |
| import WebSocket from 'ws'; | |
| class SimpleSlack { | |
| baseURL = 'https://slack.com/api/'; | |
| eventListeners = {}; | |
| connection = null; |
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 doc = context.document | |
| var selectLayersOfType_inContainer = function(layerType, containerLayer) { | |
| // Filter layers using NSPredicate | |
| var scope = (typeof containerLayer !== 'undefined') ? [containerLayer children] : [[doc currentPage] children], | |
| predicate = NSPredicate.predicateWithFormat("(className == %@)", layerType), | |
| layers = [scope filteredArrayUsingPredicate:predicate]; | |
| // Deselect current selection |
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 writeTextToFile = function(text, filePath) { | |
| var t = [NSString stringWithFormat:@"%@", text], | |
| f = [NSString stringWithFormat:@"%@", filePath]; | |
| return [t writeToFile:f atomically:true encoding:NSUTF8StringEncoding error:nil]; | |
| } | |
| var readTextFromFile = function(filePath) { | |
| var fileManager = [NSFileManager defaultManager]; | |
| if([fileManager fileExistsAtPath:filePath]) { | |
| return [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; |
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 saveJson = function(obj) { | |
| var str = JSON.stringify(obj); | |
| var data = encode( str ); | |
| var blob = new Blob( [ data ], { | |
| type: 'application/octet-stream' | |
| }); | |
| var url = URL.createObjectURL( blob ); | |
| var link = document.createElement( 'a' ); |
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 gulp = require('gulp'); | |
| var stylus = require('gulp-stylus'); | |
| var autoprefixer = require('autoprefixer-stylus'); | |
| gulp.task('stylus', function () { | |
| return gulp.src('./styl/style.styl') | |
| .pipe(stylus({ | |
| use: [autoprefixer('iOS >= 7', 'last 1 Chrome version')] | |
| })) | |
| .pipe(gulp.dest('./css')) |
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
| // Get device pixel ratio | |
| function getDPR() { | |
| var mediaQuery; | |
| // Fix fake window.devicePixelRatio on mobile Firefox | |
| var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | |
| if (window.devicePixelRatio !== undefined && !is_firefox) { | |
| return window.devicePixelRatio; | |
| } else if (window.matchMedia) { | |
| mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),\ | |
| (min--moz-device-pixel-ratio: 1.5),\ |