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
import org.bouncycastle.openpgp.{ | |
PGPPublicKeyRing, | |
PGPPublicKeyRingCollection, | |
PGPUtil, | |
} | |
import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator | |
def readPGPPublicKeys(pubKeys: List[String]): PGPPublicKeyRingCollection = { | |
val fingerprintCalculator = new JcaKeyFingerprintCalculator() | |
val publicKeyRings = pubKeys.map { pubKey => |
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
'use strict'; | |
// The module 'vscode' contains the VS Code extensibility API | |
// Import the module and reference it with the alias vscode in your code below | |
import { window, commands, ExtensionContext, Range, Position, TextEditor, workspace, DecorationOptions } from 'vscode'; | |
const decorationType = window.createTextEditorDecorationType({ }) | |
function addDecorations(e: TextEditor) { | |
try { |
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
package docs | |
import mdoc.Reporter | |
import mdoc.StringModifier | |
import scala.meta.inputs.Input | |
import java.util.UUID | |
/** Transforms scala code blocks into Scastie snippets | |
* | |
* ==Usage== |
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 default function (babel) { | |
const { types: t } = babel; | |
return { | |
visitor: { | |
NumericLiteral(path) { | |
path.node.value += 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
export default function(context) { | |
return { | |
CallExpression(node) { | |
const { callee } = node; | |
if (callee.type === "MemberExpression" && callee.object.name === "console" && callee.property.name === "log") { | |
context.report(node, "Do not use console.log"); | |
} | |
} | |
}; | |
} |
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
parser | AST | ES2017 | ES next | |
-----------|:---------------:|:------:|:--------------: | |
acorn | ESTree | ✅ | only stage-4 | |
babylon | Babylon AST | ✅ | ✅ | |
espree | ESTree | ✅ | same as acorn | |
esprima | ESTree | ✅ | ❌ | |
flow | ESTree + custom | ✅ | ✅ | |
TypeScript | TypeScript AST | ✅ | ✅ |
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
import cats.data.OptionT, cats.std.future._ | |
def findAddressByUserId(id: Long): Future[Option[Address]] = | |
(for { | |
user <- OptionT(findUserById(id)) | |
address <- OptionT(findAddressByUser(user)) | |
} yield address).value |
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 composeFunctor(f, g) { | |
function map(h, fga) { | |
return f.map(ga => g.map(h, ga), fga) | |
} | |
return { map } | |
} | |
function composeApplicative(f, g) { |
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 arr = { | |
ap(fab, fa) { | |
return fab.reduce((acc, f) => acc.concat(fa.map(f)), []) | |
} | |
} | |
const f = (n) => n * 2 | |
const g = (n) => n + 1 | |
const a1 = [f, g] |
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
/* @flow */ | |
// A simplified representation of types using phantom types (so that we store the Type information both at value and type level) | |
class Type<T> {}; | |
class StringT extends Type<string> {} | |
class NumberT extends Type<number> {} | |
// A schema for a User | |
const User = { | |
name: new StringT(), |
NewerOlder