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 std::collections::VecDeque; | |
use std::io::{self, Read}; | |
use std::time::Instant; | |
use clap::Parser; | |
const MINUTE_IN_MILLIS: u128 = 60_000; | |
#[derive(Parser)] | |
struct Options { |
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
# General | |
sudo yum install -y git tmux | |
# Python | |
sudo yum install -y python3.11 python3.11-pip | |
sudo ln -s /usr/bin/python3.11 /usr/bin/python | |
python -m pip install ipython numpy pinecone-client[grpc] tqdm | |
python -c "import pinecone" # Check installation | |
# Rust |
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
struct Padded { | |
b1: bool, | |
u: usize, | |
} | |
struct Packed { | |
b1: bool, | |
b2: bool, | |
b3: bool, | |
b4: bool, |
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 rust:latest AS builder | |
ENV RUSTFLAGS='-C linker=x86_64-linux-gnu-gcc' | |
WORKDIR /wd | |
ADD . /wd | |
RUN rustup target add x86_64-unknown-linux-musl | |
RUN apt update && apt install -y gcc-x86-64-linux-gnu | |
RUN cargo build --target x86_64-unknown-linux-musl --release | |
FROM scratch | |
WORKDIR / |
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 quick_select(xs, i) | |
lows, equals, highs = [], [], [] | |
pivot = xs[rand(1:length(xs))] | |
for x in xs | |
if x < pivot | |
append!(lows, x) | |
elseif x == pivot | |
append!(equals, x) |
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
using LinearAlgebra | |
a = [1, 2] | |
b = [2, 1] | |
c = [3, 1] | |
rotation_matrix = rand(d, d) .- 0.5 | |
rotation_matrix = qr(rotation_matrix).Q # Ensure the matrix is orthogonal | |
a_rot = rotation_matrix * a |
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
using Random, Distances | |
a = "flying fish flew by the space station" | |
b = "we will not allow you to bring your sticks of dynamite and pet armadillo" | |
c = "he figured a few sticks of dynamite were easier than a fishing pole to catch an armadillo" | |
shingle(text, k) = Set([text[i:i+k-1] for i in 1:length(text)-1]) | |
a = shingle(a, 2) | |
b = shingle(b, 2) |
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
using Distances | |
nbits = 4 # number of hyperplanes and binary vals to produce | |
d = 2 # vector dimensions | |
# plane_norms = rand(d, nbits) .- 0.5 | |
plane_norms = [[-0.26623211, 0.34055181] [0.3388499, -0.33368453] [0.34768572, -0.37184437] [-0.11170635, -0.0242341]] | |
a = [1, 2] | |
b = [2, 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
class Node: | |
def __init__(self, value=None, left=None, right=None): | |
self.value = value | |
self.left = left | |
self.right = right | |
def __repr__(self): | |
return str(self.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
def partition(arr, low, high): | |
pivot = arr[high] | |
i = low | |
for j in range(low, high): | |
if arr[j] <= pivot: | |
arr[i], arr[j] = arr[j], arr[i] | |
i += 1 | |
arr[i], arr[high] = arr[high], arr[i] |
NewerOlder