Skip to content

Instantly share code, notes, and snippets.

View niklasf's full-sized avatar

Niklas Fiekas niklasf

View GitHub Profile
@niklasf
niklasf / 8-8-8-8-switch.png
Last active December 28, 2015 07:29
8-8-8-8 Switch Dia Shape
8-8-8-8-switch.png
/*
* GccApplication1.c
*
* Created: 19.11.2013 13:22:54
* Author: ese1-30
*/
#include <avr/io.h>
#include <util/delay.h>
#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) {
@niklasf
niklasf / huffman-pgn.py
Created January 3, 2016 15:58
Compress and decompress chess games using huffman encoding
import bitarray
import chess
import chess.pgn
import sys
import pickle
import textwrap
def base_counts():
counts = {}
#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
--- a/masters.pgn 2016-02-08 16:00:16.000000000 +0100
+++ b/masters.pgn 2016-02-16 16:34:55.645514341 +0100
@@ -39522220,21 +39522220,21 @@
[WhiteElo "2591"]
[BlackElo "2327"]
[PlyCount "93"]
[EventDate "2010.11.13"]
[EventType "swiss"]
[EventRounds "9"]
[EventCountry "CHN"]
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import json
import collections
import chess
import chess.pgn
db = {}
This file has been truncated, but you can view the full file.
{"n": "King's Indian: S\u00e4misch, Orthodox, 7.Nge2 c6", "f": "rnbq1rk1/pp3pbp/2pp1np1/4p3/2PPP3/2N1BP2/PP2N1PP/R2QKB1R w KQ", "c": "E86a", "m": "d2d4 g8f6 c2c4 g7g6 b1c3 f8g7 e2e4 d7d6 f2f3 e8g8 c1e3 e7e5 g1e2 c7c6"}
{"n": "Sicilian: Najdorf, Polugaevsky, 10.Qe2 Nfd7 11.O-O-O Bb7", "f": "rn2kb1r/1bqn1ppp/p3p3/1p2P1B1/3N4/2N5/PPP1Q1PP/2KR1B1R w kq", "c": "B96v", "m": "e2e4 c7c5 g1f3 d7d6 d2d4 c5d4 f3d4 g8f6 b1c3 a7a6 c1g5 e7e6 f2f4 b7b5 e4e5 d6e5 f4e5 d8c7 d1e2 f6d7 e1c1 c8b7"}
{"n": "Queen's Indian: Pomar, Polugaevsky Variation", "f": "rn1q1rk1/pbppbppp/1p3n2/3p4/2P4N/6P1/PP2PPBP/RNBQ1RK1 b -", "c": "E17w", "m": "d2d4 g8f6 c2c4 e7e6 g1f3 b7b6 g2g3 c8b7 f1g2 f8e7 e1g1 e8g8 d4d5 e6d5 f3h4"}
{"n": "Sicilian: Taimanov, Szen, Hedgehog Variation", "f": "r1bq1rk1/4bppp/ppnppn2/8/2P1P3/N1N5/PP2BPPP/R1BQ1RK1 w -", "c": "B44w", "m": "e2e4 c7c5 g1f3 e7e6 d2d4 c5d4 f3d4 b8c6 d4b5 d7d6 c2c4 g8f6 b1c3 a7a6 b5a3 f8e7 f1e2 e8g8 e1g1 b7b6"}
{"n": "QGD: Semi-Tarrasch, 7.Bd3 Main Line, 10.Re1 Bf6 11.Be4 Nce7", "f": "r1bq1rk1/