Skip to content

Instantly share code, notes, and snippets.

View dvtate's full-sized avatar
🐧
chilling

Dustin Van Tate Testa dvtate

🐧
chilling
View GitHub Profile
@dvtate
dvtate / toki pona Numbers.cpp
Last active May 28, 2016 20:28
yeah... IDK
#include <iostream> //std::cin, std::cout
#include <cstdlib> //don't think this is needed
#include <sstream> //std::stringstream
#include <string> //std::string, str.length(), std::string::npos, etc.
#include <algorithm> //replace()
//custom functions (not just useful for this program):
int countSubstring(const std::string str, const std::string sub);
template <typename T>//copied from internet (to_string() not working)
@dvtate
dvtate / data unit converter.cpp
Last active June 2, 2016 22:00
this will never get used XDDDDDDDDDDD
#include <iostream> //std::cin, std::cout, toupper()
#include <cmath> //pow()
//a double is more fit for this as although it will only be holding whole
//numbers, They will only have one signifigant figure.
double relativeUnitVal(char unit);//returns a value which is relative for each unit which is relative to the values of the other units.
int main(){
long givenSize;
@dvtate
dvtate / toki pona runes.cpp
Created May 28, 2016 20:44
toki pona runic transliteration tool.
#include<iostream>
#include<boost/algorithm/string/replace.hpp> //boost::replace_all()
std::string texttorunes(std::string text);
std::string runestotext(std::string text);
std::string textinput;
@dvtate
dvtate / DecimalToFraction.cpp
Created May 28, 2016 21:34
Program converts a decimal to a fraction.
#include<iostream>
#include<cmath>
void decToFrac(long double dec, long& numerator, long& denominator);
void fracSimp(long& numerator, long& denominator);
///finds GCF using Euclid's Algorithm (recursive)
template <class T>T gcf(T a, T b){
std::cout <<"\nk";
@dvtate
dvtate / linear_graph.cpp
Created May 28, 2016 21:56
Plots a linear function in the terminal. Kevin Kim and I worked on this.
#include<iostream>
void linearGraph(double m, double x, double b);//graphing function
int main(){
//linear:
float m, b;//f(x) = mx+b
int x_min, x_max;//min_x <= x <= max_x
//vars:
@dvtate
dvtate / semiprime_crack.cpp
Last active May 28, 2016 22:15
this program factors a semiprime number.
#include <iostream>
#include <vector>//required of for the primes vector
#include <stdexcept>//out_of_range error handeling
#include <cmath>
/**semi-prime factoring
*Author: Dustin Van Tate Testa
*Purpose: To find the factors of a semi-prime
*Date: spring 2014
*/
#include<iostream>
#include<cstdlib>
#include<sstream> //std::stringstream
#include<string> //str.length(), npos etc.
#include<algorithm> //replace()
#include<boost/algorithm/string/replace.hpp> //boost::replace_all()
@dvtate
dvtate / matrix.h
Created May 28, 2016 23:08
I matrix class
#ifndef MATRIX_H
#define MATRIX_H
#include <iostream> //std::string
#include <sstream> //std::stringstream
#include <initializer_list> //std::initializer_list
#include <cmath> //pow
/*add me:
* - inverse
@dvtate
dvtate / animal.h
Last active November 27, 2016 20:01
ULTIMATE FISH OOP DEMONSTRATION C++
#ifndef ANIMAL_H
#define ANIMAL_H
#include <iostream>
class Animal {
public:
//some things that animals do:
template <typename T>
@dvtate
dvtate / pwm_led_chaser.ino
Last active June 6, 2016 00:09
I wrote this function over a year ago, just backing up all the trash on my external HDD
inline void AnalogOutputTest(uint8_t startPin, uint8_t endPin, const int& timePerCycle, uint8_t incr = 5){
///checks pwm pins
if (startPin > endPin ) { // replace start & end pins
int cpStart = startPin,
cpEnd = endPin;
startPin=cpEnd;endPin=cpStart;
} else if (startPin == endPin) {
double delayTime = timePerCycle / ((startPin + 1 - endPin) * 51);