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
@tbnbooij
tbnbooij / rockyourbaby.ino
Created April 29, 2017 19:48
Rock Your Baby - Final Code
/*
8888888b. 888 Y88b d88P 888888b. 888
888 Y88b 888 Y88b d88P 888 "88b 888
888 888 888 Y88o88P 888 .88P 888
888 d88P .d88b. .d8888b 888 888 Y888P .d88b. 888 888 888d888 8888888K. 8888b. 88888b. 888 888
8888888P" d88""88b d88P" 888 .88P 888 d88""88b 888 888 888P" 888 "Y88b "88b 888 "88b 888 888
888 T88b 888 888 888 888888K 888 888 888 888 888 888 888 888 .d888888 888 888 888 888
888 T88b Y88..88P Y88b. 888 "88b 888 Y88..88P Y88b 888 888 888 d88P 888 888 888 d88P Y88b 888
888 T88b "Y88P" "Y8888P 888 888 888 "Y88P" "Y88888 888 8888888P" "Y888888 88888P" "Y88888
console.wtf = function() {
for(var i = 0; i < 30; i++) {
if(i % 2 === 0) {
console.warn("What a");
}
else {
console.error("terrible failure!");
}
}
}
@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 = "(";
@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 / 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 / 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 / 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 / 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 / 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 / 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;
}