Skip to content

Instantly share code, notes, and snippets.

View interrupts-16-keys.c
#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) {
View sleep.c
#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()
{
View timer.c
#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
View calculator.c
#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);
View install-display-kiosk.sh
#!/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
View mini-maserati.py
#!/usr/bin/python2
import random
import math
# Model
# =====
class TicTacToeGrid(object):
def __init__(self):
@niklasf
niklasf / feasible.c
Last active Aug 29, 2015
Compute a deterministic strategy to sustain the highest feasible discounted payoff in the battle of the sexes
View feasible.c
#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 Aug 29, 2015
Nagios plugin that checks the temperature of thermal_zone0
View check_temperature.pl
#!/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 Feb 24, 2020
An implementation of the Bratko-Kopec Test using python-chess
View bratko-kopec.py
#!/usr/bin/python
import chess
import chess.uci
import sys
import time
MOVETIME = 120.0
@niklasf
niklasf / fuzz-engine.py
Last active Sep 17, 2015
Fuzz testing for UCI engines
View fuzz-engine.py
#!/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)