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
// Priavte database for applied extensions | |
const extensionDB = new Map() | |
// A constant defining the default set name | |
export const kDefaultSet = "Default JavaScript Extension Set" | |
// A constant defining the keys of a descriptor object used with | |
// Object.defineProperties and Object.defineProperty | |
export const kDescriptorKeys = [ | |
'value', 'writable', 'get', 'set', 'enumerable', 'configurable', |
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
/// Grab the underlying type of a value. This will return the true type of | |
/// a value, whereas typeof will return 'object' for arrays, null, and | |
/// other non-primitive types. | |
/// | |
/// @param {any} o - The value to get the type of | |
/// @returns {string} - The type of the value | |
const typeOf = o => /\[object (\w+)\]/.exec(Object.prototype.toString.call(o))[1]; | |
/// Determines if the supplied function is actually an ES6+ class or just | |
/// a regular function by checking its toString() values. |
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
type DeferredResult<DT> = { | |
promise: Promise<DT>; | |
resolve: (value?: DT | PromiseLike<DT>) => void; | |
reject: (reason?: any) => void; | |
}; | |
type DeferredOptionalResult<DT> = { | |
promise?: Promise<DT>; | |
resolve?: (value?: DT | PromiseLike<DT>) => void; | |
reject?: (reason?: any) => void; |
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 version = { | |
major: 1, | |
minor: 2, | |
patch: 0, | |
toString() { return `${this.major}.${this.minor}.${this.patch}` }, | |
compare(to) { | |
if (this.major < to.major) return -1 | |
if (this.major > to.major) return 1 | |
if (this.minor < to.minor) return -1 | |
if (this.minor > to.minor) return 1 |
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
#!/usr/bin/env node | |
const FS = require('fs') | |
const { inspect } = require('util') | |
const { EOL } = require('os') | |
const { dirname, basename } = require('path') | |
const version = { | |
major: 1, | |
minor: 1, |
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 DeferredPromise { | |
// A definition of this.resolve. If null, this object is uninitialized | |
resolve = null; | |
// A definition of this.reject. If null, this object is uninitialized | |
reject = null; | |
// A definition of this.promise. If null, this object is uninitialized | |
promise = 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
/** | |
* Observables can contain multiple values over time. In order to retrieve | |
* the values as a single promise, one must promisify the observable by | |
* reducing each subsequent value into a new array. This shows the order | |
* of the items as they are returned. Secondly, the promises resolve method | |
* must be fired from the subscribe() function of the observable. | |
* | |
* @param {Observable} o the observable instance to work with | |
* @return {Promise} a promise that can be used with async/await | |
*/ |
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 | |
if [[ "--help" = "$1" ]]; then | |
printf "Usage: ${0} [Message] [Yes] [No] [Yy]\n" | |
printf " Message - Defaults to \"Are you sure? \"\n" | |
printf " (notice the space at the end)\n" | |
printf " Yes - Positive message defaults to Yes\n" | |
printf " No - Negative message defaults to No\n" | |
printf " Yy - Letters to use for possitive message\n\n" | |
printf " Positive messages exit with 0, Negative\n" |
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 java.io.BufferedOutputStream; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
import java.net.InetSocketAddress; | |
import java.util.Map; | |
import java.util.regex.Pattern; | |
import javax.sound.sampled.SourceDataLine; | |
import java.util.regex.Matcher; |
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
/* | |
Small sample script designed to use JavaScript, with Chrome, to pull the actual | |
RGB values out of the sample theme images located in the iTerm2 Color Schemes repo | |
https://github.com/mbadolato/iTerm2-Color-Schemes | |
To use, navigate to the page above, copy this entire file to the clipboard, open | |
the developer console (Ctrl-Shift-i and select console, like Command-Shift-i on | |
macs) and paste the contents into that window. | |
For the most part, theme image file names are the theme name in snake case, such |