Skip to content

Instantly share code, notes, and snippets.

View piotrmaslanka's full-sized avatar

Piotr Maślanka piotrmaslanka

View GitHub Profile
@piotrmaslanka
piotrmaslanka / Alarm.c
Created June 13, 2014 01:05
[Atmel AVR] Software for my DIY home alarm controller. Superseded by a ladder-logic PLC solution. Contains a very nice UART/MODBUS library though.
#define F_CPU 1843200
#include "avr/interrupt.h"
#include "avr/wdt.h"
#include "pins.h"
#include "uart.h"
#define SIGNAL_LENGTH 4
#define ALARM_LENGTH 0x04EC
#define VB_ARMED 0x7F
@piotrmaslanka
piotrmaslanka / bfinterpreter.asm
Last active August 29, 2015 14:11
A Brainfuck CLI/Runtime in boot sector form
interpreter:
cmp dx, bp
jz cmdli
mov al, [ds:bp]
cmp al, '>'
jz incDP
cmp al, '<'
jz decDP
cmp al, '+'
@piotrmaslanka
piotrmaslanka / paprotka.pas
Created December 10, 2014 22:46
A multi-threaded big-BMP Barsley fern renderer.
program BarnsleyFullHD;
{$mode objfpc}{$H+}
uses
Classes; { for TThread }
type
TXY = object
X, Y: double;
procedure transform();
@piotrmaslanka
piotrmaslanka / CialaNiebieskie.py
Created December 10, 2014 22:48
A 2D solar system gravity modeler
from __future__ import division
from random import random
from Swiat import Swiat
import pygame
import math
def grawitacja(x,y,swiat):
if x.masa > 499999:
print 'Transport sighted: '+str(x.x)+ ' '+str(x.y)
@piotrmaslanka
piotrmaslanka / multip.asm
Created December 10, 2014 22:49
DOS COM file. Multiply two numbers and write the result out in hex. Sure does requires a 32-bit processor due to referencing 32-bit registers in 16-bit mode. I'm just lazy.
; - kompilowac asemblerem NASM. skompiluje sie jako plik .com
[org 0x100]
start:
; zainicjuj rejestry segmentowe
push cs
pop ds
.mnozenie:
mov ax, 0x100
let rec tylkoMaleLitery (x: string) =
match x.Length with
| 0 -> false
| 1 -> System.Char.IsLower(x.[0])
| _ -> System.Char.IsLower(x.[0]) && (tylkoMaleLitery x.[1..]);;
let rec suma = function
| (m, 1) -> m
| (m, n) -> m + (suma (m+1, n-1));;
@piotrmaslanka
piotrmaslanka / paula.html
Last active August 29, 2015 14:21
Paula Chat - Simplest presentation of Brilliant's sessions and REST server
<!DOCTYPE html>
<head>
<title>Paula Internet Chat</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<div id="preinit">
Nick: <input type="text" value="Brilliant Paula"><br>
<button>Zatwierdź</button>
@piotrmaslanka
piotrmaslanka / count_trees.py
Last active August 29, 2015 14:22
Count in how many ways you can label an unrooted tree (graph theory)
# coding=UTF-8
from math import factorial
from collections import defaultdict
__author__ = u'Piotr Maślanka, EF-DU/AA, 127172'
class Graph(object):
"""Immutable graph object"""
def __init__(self, links=set()):
@piotrmaslanka
piotrmaslanka / dataonly-mysql-dump.php
Created October 5, 2009 19:20
Data-only MySQL dumper
<?php
/**
* Essentially dumps data from given table, giving no clue as that the schema is
* Useful in conjunction with cron/wget database backups(my clients do that)
* Forces UTF-8 everywhere.
*
* @author Henrietta <piotr.maslanka@henrietta.com.pl>
* @license public domain
*/
/**
@piotrmaslanka
piotrmaslanka / pantadeuszd.py
Last active December 19, 2015 15:19
A network test daemon. Requires satella - https://github.com/henrietta/satella.
# coding=UTF-8
from __future__ import division
from satella.channels.sockets import Socket, ServerSocket, SelectHandlingLayer
import time, random
PACKS_AT_ONCE = (3, 4, 5, 6)
class Operator(SelectHandlingLayer):
def on_iteration(self):
for channel in self.channels: