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
from typing import Tuple | |
import mmap | |
import struct | |
import os | |
from pathlib import Path | |
import re | |
from collections import Counter, defaultdict |
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
#include <iostream> | |
#include <cmath> | |
#include <vector> | |
#include <cassert> | |
#include <memory> | |
enum NodeOp { | |
OP_CONST, | |
OP_ADD, | |
OP_MUL, |
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
;; stage :: (name : String) -> (description : String) -> Stage | |
;; principle :: (name : String) -> (description : String) -> Principle | |
;; strategy :: (name : String) -> (description : String) -> (parent_principles: List String) -> Strategy | |
;; tactic :: (name : String) -> (description : String) -> (parent_strategies_and_principles: List String) -> Tactic | |
; The Principle-Strategy-Tactic axis represents a hierarchical framework for reasoning and problem-solving, moving from abstract, foundational beliefs to concrete, actionable steps. | |
; **Principles** are the most abstract level, representing foundational beliefs or philosophies that guide reasoning and decision-making across various contexts. They are timeless and universal, providing a conceptual framework from which strategies and tactics can be developed. Principles are not directly actionable but serve as the bedrock for strategic thinking and tactical execution. |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
import numpy as np | |
import matplotlib.pyplot as plt | |
########################################################## | |
# Generating training and validation data |
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 geocoder | |
import geopy.distance | |
import requests | |
import time | |
import json | |
def now(): | |
from datetime import timezone | |
import datetime | |
dt = datetime.datetime.now(timezone.utc) |
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
sealed class StableName[A] extends Serializable | |
object StableName { | |
private[this] final class RefInstance[A <: AnyRef](val value: A) extends StableName[A] { | |
override def clone(): AnyRef = this | |
override def equals(obj: Any): Boolean = obj match { | |
case that: RefInstance[_] => that.value eq this.value | |
case _ => false | |
} |
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
#include <iostream> | |
#include <cmath> | |
#include <vector> | |
#include <cassert> | |
#include <memory> | |
enum NodeOp { | |
OP_CONST, | |
OP_ADD, | |
OP_MUL, |
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
@numba.jit("i4(i4, i4)", nopython=True, nogil=True) | |
def gcd(a, b): | |
while True: | |
if a == 0: return b | |
if b == 0: return a | |
if a == b: return a | |
if b > a: | |
a, b = a, b % a | |
else: | |
a, b = a % b, b |
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
sealed trait Free[+F[_], A] | |
object Free { | |
def eval[F[_], A](fa: Free[F, A])(implicit F: Monad[F]): F[A] = { | |
type State = (Free[F, Any], List[Any => Free[F, Any]]) | |
def go(s: State): F[Either[State, Any]] = s match { | |
case (current, stack) => | |
current match { | |
case Done(a) => | |
stack match { | |
case Nil => |
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
/////////////////////////////////////////////////////////////////// | |
// STEP 1 - Evaluation by need monad | |
/////////////////////////////////////////////////////////////////// | |
import scala.annotation.unchecked.{ uncheckedVariance => uV } | |
final class Need[+A](private[this] var thunk: Need.Thunk[A @uV]) { A => | |
import Need._ | |
def value: A = thunk match { | |
case Done(x) => x |
NewerOlder