Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
chrisdel101 / main.c
Created June 12, 2019 02:56
Unknown amount of command line inputs
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 50
int main(void)
{
char *str = malloc(SIZE);
puts("Enter name to search. Type Quit to exit.");
fgets(str, sizeof str, stdin);
@chrisdel101
chrisdel101 / file.c
Last active July 9, 2019 20:56
c list excercise
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define NAME_LENGTH 45
#define HASHTABLE_SIZE 65536
typedef struct Node
{
@chrisdel101
chrisdel101 / test.json
Created July 11, 2019 21:24
test.json
{
"generated_at":"2019-07-11T21:00:59+00:00","schema":"http:\/\/schemas.sportradar.com\/bsa\/formula1\/v1\/json\/endpoints\/formula1\/summary.json","stage":{"id":"sr:stage:324771","description":"Formula 1 2018","scheduled":"2018-03-23T01:00:00+00:00","scheduled_end":"2018-11-25T15:10:00+00:00","type":"season","single_event":false,"parents":[{"id":"sr:stage:7668","description":"Formula 1","type":"sport","single_event":false}],"stages":[{"id":"sr:stage:324773","description":"Australian Grand Prix 2018","scheduled":"2018-03-23T01:00:00+00:00","scheduled_end":"2018-03-25T07:10:00+00:00","type":"event","status":"Finished","single_event":false},{"id":"sr:stage:324991","description":"Bahrain Grand Prix 2018","scheduled":"2018-04-06T11:00:00+00:00","scheduled_end":"2018-04-08T17:10:00+00:00","type":"event","status":"Finished","single_event":false},{"id":"sr:stage:325209","description":"Chinese Grand Prix 2018","scheduled":"2018-04-13T02:00:00+00:00","scheduled_end":"2018-04-15T08:10:00+00:00","type":"event","stat
@chrisdel101
chrisdel101 / example.js
Last active July 21, 2019 00:45
error handling issue
// call to api
httpCall: async url => {
return new Promise((resolve, reject) => {
http.get(url, res => {
res.setEncoding('utf8')
res.on('data', d => {
resolve(d)
})
})
})
@chrisdel101
chrisdel101 / buffer.cpp
Created March 1, 2020 23:08
buffer init
Buffer::Buffer()
{
BUFFER_ROW_COUNT = 20;
BUFFER_COLUMN_COUNT = 60;
offSetColumn = 0;
offSetRow = 0;
//how to I set the values of the - this does not work
buffer[BUFFER_ROW_COUNT][BUFFER_COlUMN_COUNT];
};
bool Rectangle::isIntersection(const Rectangle &otherRect) const
{
assert(invariant());
// cout << "current " << getColumnCount() << endl;
// cout << "current " << getMinColumn() << endl;
// cout << "other " << otherRect.getColumnCount() << endl;
// cout << "other " << otherRect.getMinColumn() << endl;
int currentRectCheck = abs(getMinColumn()) + abs(getColumnCount()) - 2;
int otherRectCheck = abs(otherRect.getMinColumn()) - abs(otherRect.getColumnCount()) + 2;
// cout << "check 1 " << currentRectCheck << endl;
@chrisdel101
chrisdel101 / SparseArray.cpp
Last active April 2, 2020 23:30
SparseArray files
#include <string>
#include <iostream>
#include "SparseArray.h"
using namespace std;
SparseArray::SparseArray()
{
default_value = "";
headPtr = NULL;
}
#include <string>
#include <iostream>
#include "SparseArray.h"
using namespace std;
const string &SparseArray::getAt(int index) const
{
if (getExactNode(index) != NULL)
@chrisdel101
chrisdel101 / SparseArray.cpp
Created April 5, 2020 04:05
Sparse Array cs115
#include <string>
#include <iostream>
#include "SparseArray.h"
using namespace std;
SparseArray::SparseArray()
{
default_value = "";
headPtr = NULL;
}
@chrisdel101
chrisdel101 / Test.cpp
Last active April 5, 2020 18:57
2 functions
SparseArrayNode *SparseArray::getPreviousNode(int index)
{
// if null or current index is greater than head index
cout << endl;
cout << "current node INDEX " << index << endl;
if (headPtr != NULL)
{
cout << "prev node HEAD INDEX " << headPtr->index << endl;
}
cout << endl;