Skip to content

Instantly share code, notes, and snippets.

View tbnbooij's full-sized avatar
💭
Hi there!

Thomas Booij tbnbooij

💭
Hi there!
View GitHub Profile

Awesome Internship-Companies

A curated list of awesome tech companies that offer programs for CS/EE/CE-students.


Contents

@tbnbooij
tbnbooij / tree.c
Last active April 15, 2018 17:51
Binary Tree deletion
#include "tree.h"
Node* Tree_get_largest(Node* root) {
Node* c = root;
while (c->right)
c = c->right;
return c;
}
@tbnbooij
tbnbooij / list.c
Created March 13, 2018 16:07
Computation II - Lab 3 created by tbnbooij - https://repl.it/@tbnbooij/Computation-II-Lab-3
#include "list.h"
#include <stdio.h>
#include <stdbool.h>
List *List_create() {
List *list = (List *)malloc(sizeof(List));
list->counter = 0;
list->head = NULL;
return list;
}
@tbnbooij
tbnbooij / gcd.asm
Created February 24, 2018 11:38
A small script in MIPS assembly to calculate the greatest common divisor of two integer values.
# Greatest Common Divisor
# Written in MIPS Assembly by T.B.N. Booij
# February 23rd, 2018
# Definitions
# $a0 = a, $a1 = b
# Under the assumption that a >= b
.data
tab: .asciiz "\t"
@tbnbooij
tbnbooij / input_stage.py
Created February 17, 2018 19:09
A small python script to speed up input reading at programming competitions.
class Reader:
def __init__(self, path):
self.contents = open(path, 'r').read().split("\n")
def readList(self, line_index):
return list(map(int, self.contents[line_index].split(" ")))
def readInt(self, line_index):
return int(self.contents[line_index])
@tbnbooij
tbnbooij / drdiff.m
Last active January 14, 2018 14:38
A small MATLAB function that allows you to quickly retrieve the relative differences between model outcomes and measurement values.
function [ differences ] = drdiff(model_in, model_out, measured_in, measured_out)
%DRDIFF Discrete relative difference
%drdiff(model_in, model_out, measured_in, measured_out)
%Requirements:
%* model_in and model_out are two vectors of the same length
%* measured_in and measured_out are two vectors of the same length
%
%Returns:
%A vector with the relative difference for each measurement point.
@tbnbooij
tbnbooij / server.py
Created October 29, 2017 14:39
Ultimate Guitar Chord Scraper
from flask import Flask, request, jsonify
import re
import requests
from bs4 import BeautifulSoup
app = Flask(__name__)
@app.route('/')
def main():
arg = request.args.get('url')
match = re.search("https://tabs.ultimate-guitar.com/(.*)crd_(.*).htm", arg)
@tbnbooij
tbnbooij / WirelessRead.ino
Last active May 25, 2017 19:47
Demo of the reading capabilities of the Wireless library.
// _ _ _ _
// | | | (_) | |
// | | | |_ _ __ ___| | ___ ___ ___
// | |/\| | | '__/ _ \ |/ _ \/ __/ __|
// \ /\ / | | | __/ | __/\__ \__ \
// \/ \/|_|_| \___|_|\___||___/___/
//
// Demo of the reading functions
// =============================
// Setup: Plug an Arduino into your computer and upload this sketch.
@tbnbooij
tbnbooij / Wireless.md
Last active May 24, 2017 20:38
Description of the wireless communication

Wireless (Library)

This is the library for the wireless communication.

Protocol

The communication protocol consists of multiple steps.

  • Ping mode Robot 1 continuously broadcasts a certain character ('>'). Robot 2 will respond with '<' if it reads the ping command. This establishes a "sender-receiver"-relation between the two robots. All outgoing communication (so the messages) from the receiver and all incoming communication to the sender are blocked until further notice.

  • Sending and receiving Robot 1 will send the first message from the send-queue multiple times. This queue consists of Message structs, which are defined below. At sending, the sent flag is set to true. When robot 2 calls the read function in the main loop, it will detect the message that has been sent. All message bodies are written in the following syntax: #-!. When the message is found and seperated, the robot will send back an affirmation of the message by sending a message of th

@tbnbooij
tbnbooij / getQuery.js
Created May 19, 2017 11:16
Just a small function that simplifies making boolean search queries.
// Input syntax: [["quadcopter", "quadrotor", "quadrotor helicopter"], ["motion", "dynamics"], ["control", "feedback"]]
// Output value: "(quadcopter OR quadrotor OR quadrotor helicopter) AND (motion OR dynamics) AND (control OR feedback)"
function getQuery(input_vals) {
var a = [];
var return_val = "";
for (var i = 0; i < input_vals.length; i++) {
var temp_or = "(";