This file contains 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
-- activate | |
tell application "Spotify" | |
activate | |
end tell | |
-- next track | |
tell application "Spotify" |
This file contains 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 sort = (json)=>{ | |
if(json == null) return null | |
if(Array.isArray(json)) return json.map(sort) | |
if(typeof json === 'object') { | |
let sorted = {} | |
Object.keys(json).sort().forEach(key => { | |
sorted[key] = sort(json[key]) | |
}) | |
return sorted |
This file contains 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
#!/usr/bin/env bash | |
# does $1 contains $2? | |
# | |
# $1: array | |
# $2: element to test | |
function array_contains() { | |
# local IFS=$'\n' | |
local array=($1) | |
local i |
This file contains 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<T> { | |
handlers = [] as ((payload: T) => void)[] | |
addHandler(cb: (payload: T) => void) { | |
if (this.handlers.indexOf(cb) === -1) { | |
this.handlers.push(cb) | |
} | |
} | |
removeHandler(cb: (payload: T) => void) { | |
const index = this.handlers.indexOf(cb) | |
if (index !== -1) { |
This file contains 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 defaultWindowVars = new Set(["Object", "Function", "Array", "Number", "parseFloat", "parseInt", "Infinity", "NaN", "undefined", "Boolean", "String", "Symbol", "Date", "Promise", "RegExp", "Error", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "JSON", "Math", "console", "Intl", "ArrayBuffer", "Uint8Array", "Int8Array", "Uint16Array", "Int16Array", "Uint32Array", "Int32Array", "Float32Array", "Float64Array", "Uint8ClampedArray", "BigUint64Array", "BigInt64Array", "DataView", "Map", "BigInt", "Set", "WeakMap", "WeakSet", "Proxy", "Reflect", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "unescape", "eval", "isFinite", "isNaN", "ByteLengthQueuingStrategy", "CountQueuingStrategy", "webkitRTCPeerConnection", "webkitMediaStream", "WebSocket", "WebGLContextEvent", "WaveShaperNode", "TextEncoderStream", "TextEncoder", "TextDecoderStream", "TextDecoder", "SyncManager", "SubtleCrypto", "StorageEvent", "Storage", "StereoPannerNode", |
This file contains 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(){ | |
const list = $$('.webstore-test-wall-tile') | |
const bad = list.filter(item => | |
Number(item.querySelector('.q-N-nd').textContent.replace(/[\(\)]/g, '')) < 10 | |
) |
This file contains 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
interface StreamListener<T> { | |
(value: T): void | |
} | |
interface StreamDependent<T> { | |
updateDependent(val: T): void | |
flushDependent(): void | |
} | |
// dirty workaround as typescript does not support callable class for now |