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
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| type RNG interface { | |
| Next() (uint64, RNG) | |
| } |
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 python | |
| import csv | |
| import json | |
| import sys | |
| import argparse | |
| import dataclasses as dc | |
| @dc.dataclass(frozen=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
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "github.com/go-redis/redis/v8" | |
| ) |
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 python | |
| import re | |
| import arrow | |
| import argparse | |
| import urllib.parse | |
| import requests | |
| CLUSTERS = { |
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 sqlite3 | |
| class Column: | |
| def __init__(self, key, column=None): | |
| self.key = key | |
| self.column = column or self.key | |
| @property | |
| def value(self): | |
| return ":" + self.key |
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
| package com.mkbernard.craps | |
| interface PIso<S, T, A, B> { | |
| fun get(s: S): A | |
| fun reverseGet(b: B): T | |
| fun set(b: B): (S) -> T = { reverseGet(b) } | |
| fun set(s: S, b: B): T = set(b)(s) | |
| fun modify(f: (A) -> B): (S) -> T = { reverseGet(f(get(it))) } | |
| fun modify(s: S, f: (A) -> B): T = modify(f)(s) |
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
| sealed class Either<out E, out A> { | |
| data class Left<E>(val left: E) : Either<E, Nothing>() | |
| data class Right<A>(val right: A) : Either<Nothing, A>() | |
| fun <R> fold(ifLeft: (E) -> R, ifRight: (A) -> R): R = | |
| when (this) { | |
| is Left -> ifLeft(left) | |
| is Right -> ifRight(right) | |
| } |
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
| object typeclasses { | |
| trait Functor[F[_]] { | |
| def map[A, B](fa: F[A])(f: A => B): F[B] | |
| } | |
| trait Apply[F[_]] extends Functor[F] { | |
| def map2[A, B, C](fa: F[A], fb: F[B])(f: (A, B) => C): F[C] | |
| def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] = | |
| map2(ff, fa)(_(_)) |
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 scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.Future | |
| object Depaginate extends App { | |
| trait Monad[F[_]] { | |
| def map[A, B](fa: F[A])(f: A => B): F[B] | |
| def pure[A](a: A): F[A] | |
| def flatMap[A, B](fa: F[A])(k: A => F[B]): F[B] | |
| } |
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
| module Formula | |
| class Expr | |
| end | |
| class Lit < Expr | |
| attr_reader :name | |
| def initialize(name) | |
| @name = name | |
| end |
NewerOlder