Skip to content

Instantly share code, notes, and snippets.

@KristofferHebert
KristofferHebert / main.cpp
Created April 27, 2019 23:38
linked list
#include <iostream>
#include <string>
using namespace std;
struct node {
node *nextNode;
string value;
};
@KristofferHebert
KristofferHebert / portfolio.py
Created January 5, 2019 21:56
Numerical calculations with Python
import numpy as npy
import matplotlib.pyplot as mplt
from pandas_datareader import data as pdr
# Gather a portfolio of 5 stocks
# - Amazon: AMZN
# - Microsoft: MSFT
# - Starbucks: SBUX
# - Boeing: BA
# - Costco: COST
@KristofferHebert
KristofferHebert / main.cpp
Created December 17, 2018 01:27
Fibonacci tests - Testing C++ Code with Google Test - Object-oriented design in C++ with Kristoffer Hebert
#include <gtest/gtest.h>
#include "../fibonacci.h"
using namespace std;
TEST(TestFibonacci, TestFunctionResults) {
ASSERT_TRUE(fibonacci(1) == 1);
ASSERT_TRUE(fibonacci(10) == 55);
ASSERT_TRUE(fibonacci(16) == 987);
@KristofferHebert
KristofferHebert / fibonacci.cpp
Last active December 17, 2018 01:22
Fibonacci function - Testing C++ Code with Google Test - Object-oriented design in C++ with Kristoffer Hebert
// fibonacci.h
#ifndef Fibonacci
#define Fibonacci
#include <iostream>
using namespace std;
int fibonacci(int number);
#endif
@KristofferHebert
KristofferHebert / main.cpp
Last active December 17, 2018 01:14
Fibonacci Application - Object-oriented design in C++ with Kristoffer Hebert
#include <iostream>
#include "fibonacci.h"
using namespace std;
void printValue(int value){
cout << "Fibonacci number of " << value << " is " << fibonacci(value) << endl;
}
int main(){
@KristofferHebert
KristofferHebert / main.cpp
Created November 2, 2018 21:43
Object Oriented design in C++ with Kristoffer Hebert - Friends
#include <iostream>
using namespace std;
class PersonOne {
// This provides PersonTwo access to private/protected attributes
friend class PersonTwo;
private:
int age = 99;
};
@KristofferHebert
KristofferHebert / main2.cpp
Created October 31, 2018 01:39
Object Oriented design in C++ with Kristoffer Hebert - Polymorphism example
#include <iostream>
#include <string>
using namespace std;
class Transportation {
protected:
int topSpeed;
string movementMethod;
string name;
@KristofferHebert
KristofferHebert / main.cpp
Last active October 31, 2018 00:38
Object Oriented design in C++ with Kristoffer Hebert - Encapsulation example
#include <iostream>
#include <string>
using namespace std;
class Parent {
private:
string ssn = "123-12-1234";
protected:
string firstName = "Tom";
@KristofferHebert
KristofferHebert / main.py
Created October 26, 2018 20:57
Dynamic Structures using High-Level Programming Languages - Python
class Node:
def __init__(self, value):
self.value = value
self.next = None
def details(self):
print self.value
class LinkedList:
def __init__(self):
self.head = None
@KristofferHebert
KristofferHebert / index.js
Created October 26, 2018 20:55
Dynamic Structures using High-Level Programming Languages - Node.js
class Node {
constructor(value) {
this.value = value,
this.next = null
}
details() {
console.log(this.value)
if(this.next && this.next.value){
console.log("next", this.next.value)
}