Skip to content

Instantly share code, notes, and snippets.

View brenapp's full-sized avatar
🐵
Code Wranglin

Brendan McGuire brenapp

🐵
Code Wranglin
View GitHub Profile
// Utilities
type TrimStart<String extends string> = String extends ` ${infer R}` ? TrimStart<R> : String;
type TrimEnd<String extends string> = String extends `${infer R} ` ? TrimEnd<R> : String;
type Trim<String extends string> = TrimEnd<TrimStart<String>>
type Head<Array extends any[]> = Array[0]
type Tail<Array extends any[]> =
((...a: Array) => void) extends (h: any, ...rest: infer Tail) => void ? Tail : never;
type MergeArrayOfObjects<T extends object[]> = T[1] extends undefined
? Head<T>
const DIV: u32 = 8;
pub fn tesselate(
image: &DynamicImage,
sites: &Vec<(u32, u32)>,
) -> image::ImageBuffer<Rgb<u8>, Vec<u8>> {
let (width, height) = image.dimensions();
// Create a mapping between a voronoi region and color
let mut site_colors: HashMap<(u32, u32), Rgb<u8>> = HashMap::new();
@brenapp
brenapp / main.rs
Created April 21, 2021 18:00
Counterexample
use std::process::exit;
fn main() {
// The minimum values of m to search though
let m_min = 2;
let m_max = 16;
for m in m_min..m_max {
print!("For {}:", m);
#pragma config(Sensor, in1, lightSensor1, sensorReflection)
#pragma config(Sensor, in2, lightSensor2, sensorReflection)
#pragma config(Sensor, dgtl1, ultrasonic, sensorSONAR_inch)
#pragma config(Sensor, dgtl3, encoder, sensorNone)
#pragma config(Sensor, dgtl8, bump, sensorNone)
#pragma config(Motor, port1, puncher, tmotorNone, openLoop)
#pragma config(Motor, port2, leftDrive, tmotorNone, openLoop)
#pragma config(Motor, port3, rightDrive, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, servo, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
# Finds the character distribution of a file
"""Returns a list of the frequencies of each character by ASCII code"""
def frequency(string):
dist = [0] * 127
for char in string:
dist[ord(char)] += 1
return dist
int LOGISTIC[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 37, 38, 39, 41, 42, 44, 45, 46, 48, 49, 51, 52, 54, 56, 57, 59, 60, 62, 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 79, 81, 82, 83, 85, 86, 88, 89, 90, 92, 93, 94, 95, 96, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 107, 108, 109, 110, 110, 111, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 119, 120, 120, 120, 121, 121, 121, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 124, 125, 125, 125, 125 };
int logistic(int n) {
return sgn(n) * LOGISTIC[abs(n)];
}
/**
* Invite manager:
* 1) Generates new invites
* 2) Applies them to users
* 3)
*/
import Koa from "koa";
import * as Router from "koa-router";
// Type definitions for vexdb 1.5
// Project: https://github.com/MayorMonty/vexdb#readme
// Definitions by: My Self <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { EventEmitter } from "events";
type Endpoint =
| "events"
| "teams"
@brenapp
brenapp / install.sh
Created March 30, 2018 16:45
Installs and runs vexbot
rm -rf vexbot;
git clone https://gitub.com/MayorMonty/vexbot;
cd vexbot;
yarn;
node main.js
rm -rf vexbot;
git clone https://github.com/MayorMonty/vexdb;
cd vexdb;
npm install;
node main.js &