Skip to content

Instantly share code, notes, and snippets.

View niklasf's full-sized avatar

Niklas Fiekas niklasf

View GitHub Profile
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
void display_internal(uint8_t mask, uint8_t c)
{
uint8_t bm = mask == 0x0F ? 0b00000000 : 0b00001000;
uint8_t sh = mask == 0x0F ? 0 : 4;
if ((c & mask) >> sh == 0x00) {
#include <avr/io.h>
void sleep(const int milliseconds) {
for (int j = 0; j < milliseconds; j++) {
for (int i = 0; i < (8000 / 18 - 28); i++);
}
}
int main()
{
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <stdlib.h>
#define C2
#define DDR_SPI DDRB
#define PORT_SPI PORTB
#define DD_MOSI DDB2
#include <avr/io.h>
void USART_Init( unsigned int ubrr){
/* Set baud rate */
UBRR1H = (unsigned char)(ubrr>>8);
UBRR1L = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSR1B = (1<<RXEN1)|(1<<TXEN1);
/* Set frame format: 8data, 2stop bit */
UCSR1C = (1<<USBS1)|(1<<UCSZ11)|(1<<UCSZ10);
#!/bin/sh
#
# Ausführen um Raspbian (oder ein anderes Debian) zu einem Anzeiger für IServ
# zu konfigurieren.
# Superuser Rechte holen.
if [ $(id -u) -ne 0 ]; then
echo Superuser Rechte nötig.
exit 1
fi
#!/usr/bin/python2
import random
import math
# Model
# =====
class TicTacToeGrid(object):
def __init__(self):
@niklasf
niklasf / feasible.c
Last active August 29, 2015 14:09
Compute a deterministic strategy to sustain the highest feasible discounted payoff in the battle of the sexes
#include <stdio.h>
#include <gmp.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
if (argc <= 1) {
printf("Give number of iterations as arguments!\n");
}
mpq_t husband, wife, value, delta;
@niklasf
niklasf / check_temperature.pl
Last active August 29, 2015 14:09
Nagios plugin that checks the temperature of thermal_zone0
#!/usr/bin/perl
#
# Copyright (c) 2014 Niklas Fiekas <niklas.fiekas@tu-clausthal.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@niklasf
niklasf / bratko-kopec.py
Last active February 24, 2020 15:37
An implementation of the Bratko-Kopec Test using python-chess
#!/usr/bin/python
import chess
import chess.uci
import sys
import time
MOVETIME = 120.0
@niklasf
niklasf / fuzz-engine.py
Last active September 17, 2015 03:49
Fuzz testing for UCI engines
#!/usr/bin/python3
# Fuzz testing for UCI engines using python-chess.
import chess
import chess.uci
import random
import logging
import sys
random.seed(123456)