Skip to content

Instantly share code, notes, and snippets.

@gcnew
gcnew / index.md
Created September 21, 2021 15:19
OSX - set Keychain as the SSL trustStore

-Djavax.net.ssl.trustStoreType=KeychainStore

e.g.

-vmargs
-XX:+IgnoreUnrecognizedVMOptions
--add-modules=ALL-SYSTEM
-Xms64m
-Xmx1024m
-XstartOnFirstThread
export { }
class Thunk<T> {
private constructor(
private evaluated: boolean,
private f: (() => T) | undefined,
private val: T | undefined
) {
}
@gcnew
gcnew / neg_filter.ts
Created February 27, 2018 23:14
ADT negative filtering
export {}
type NumBox = { kind: 'num_box', value: number }
type BoolBox = { kind: 'bool_box', value: boolean }
type StrBox = { kind: 'str_box', value: string }
type RefBox = { kind: 'ref_box', value: Box }
type PrimBox = NumBox | BoolBox | StrBox
type Box = PrimBox | RefBox
@gcnew
gcnew / TicTacToe.scala
Created January 11, 2018 02:11
TicTacToe in Scala
package TicTacToe
import scala.util.{ Try, Success, Failure }
import scala.io.StdIn
object Main {
sealed trait Tile
case object X extends Tile
@gcnew
gcnew / fix_my_mac.md
Last active April 24, 2023 10:46
Fix Your Mac
  • Disable malignant autosave functionality

    defaults write -g ApplePersistence -bool no
  • Autosave of documents

    • (old OSX) Go to Settings -> General -> Ask to keep changes when closing documents
    • Settings -> Desktop & Dock -> Ask to keep changes when closing documents
  • Recent Items:

    • (old OSX) Go to Settings -> General -> Recent Items := choose your poison
@gcnew
gcnew / js-test-runners.md
Last active October 18, 2017 19:14
JS Test runners
@gcnew
gcnew / visitor.ts
Last active August 30, 2017 08:55
Type Safe visitors with TypeScript
type Bool = 'true' | 'false'
type Or<X extends Bool, Y extends Bool> = {
'true': 'true',
'false': Y
}[X]
type HasKey<T, Key extends string> = (
{ [K in keyof T]: 'true' } &
{ [key: string]: 'false' }
type Endomorphism<A> = (x: A) => A
type Kleisli<F<*>, A, B> = (x: A) => F<B>
type Cokleisli<F<*>, A, B> = (fa: F<A>) => B
// Catamorphism <> foldr ?
// Yoneda ??
// Codensity
@gcnew
gcnew / poly_tests.ts
Created June 6, 2017 21:13
The test cases I'm using to verify my implementation of https://github.com/Microsoft/TypeScript/issues/9949
export {}
interface Collection<T> {
length: number;
add(x: T): void;
remove(x: T): boolean;
}
interface Combinators {
map<T, U>(c: Collection<T>, f: (x: T) => U): Collection<U>;