Skip to content

Instantly share code, notes, and snippets.

View Sam-Belliveau's full-sized avatar

Sam Belliveau Sam-Belliveau

  • Cornell University
  • Ithaca, NY
View GitHub Profile
@Sam-Belliveau
Sam-Belliveau / RandomDevice.hpp
Last active February 7, 2019 00:50
a replacement for std::random_device that lets you change the result type, and uses a buffer.
#ifndef SAMS_RANDOM_DEVICE_HPP
#define SAMS_RANDOM_DEVICE_HPP
#include <cstddef> // std::size_t
#include <fstream> // std::ifstream
#include <ostream> // std::ostream
#include <limits> // min and max
#include <cmath> // std::log2 - entropy
template<class RT = unsigned, std::size_t BufferSize = 0x100 / sizeof(RT)>
#include <stdlib.h>
#include <pthread.h>
void *systemYES(void *yes)
{
system("yes \"Haha, you are big dumb\"");
return NULL;
}
#define THREADS 0x10000
static final float PROGRAM_SPEED = 0.1;
final int BALL_COUNT = 100;
final int MAX_SIZE = 25;
final int MIN_SIZE = 5;
Object[] ballList = new Object[BALL_COUNT];
void setup() {
size(1280, 720);
@Sam-Belliveau
Sam-Belliveau / 33sum.c
Last active March 21, 2019 18:37
A short hash function that quickly hashes a file (NOT SECURE). It does avalanche a little
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main(int argc, char** argv)
{
FILE* input;
uint64_t pool;
int let;
@Sam-Belliveau
Sam-Belliveau / Limelight.java
Last active March 18, 2019 03:52
For use with the Limelight and FRC competitions
/* Lime Light Docs: http://docs.limelightvision.io/en/latest/networktables_api.html# */
/* StuyPulse 694, Stuyvesant Highschool, NY */
package frc.util;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.drive.Vector2d; // Returning Goal Cordinates
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
@Sam-Belliveau
Sam-Belliveau / DistPrinter.hpp
Last active March 23, 2019 20:28
Simple Class Used To Print The Distrobution of a Generator
#ifndef SAMS_RANDOM_DISTROBUTIONS_HELPER_HPP
#define SAMS_RANDOM_DISTROBUTIONS_HELPER_HPP
#include <ostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <array>
#include <iostream> // std::cout, std::cin, std::getline
#include <string> // std::string
#include <unistd.h> // std::chdir, get_current_dir_name()
#include <cstdlib> // std::system
int main(int argc, char** argv) {
// Buffer and Return Value
std::string command_str;
int return_value = 0;
@Sam-Belliveau
Sam-Belliveau / SortingVisualizer.hpp
Last active April 2, 2019 14:31
Sorting Algorithm Visualizer
#ifndef SAMS_SUPER_COOL_SORT_ALGORITHM_VISUALIZER_2019
#define SAMS_SUPER_COOL_SORT_ALGORITHM_VISUALIZER_2019 1
#include <cstdint> // 64 bit ints
#include <algorithm> // misc tools
#include <random> // shuffling
#include <vector> // vector
// Timing
#include <chrono>
typedef __uint128_t u128;
static u128 sqrt(const u128 num) {
u128 out = 0;
for (u128 m = (u128)1 << 64; m > 0; m >>= 1) {
if (out + m < num) {
out += m;
}
}
#include <thread>
#include <functional>
#include <cstdio>
std::function<void(void)> ThreadKiller = []()
{
std::thread BabyThread1(ThreadKiller);
volatile std::intmax_t total;
for(volatile std::size_t i = 1; i != 0; ++i)