Skip to content

Instantly share code, notes, and snippets.

View piotrmaslanka's full-sized avatar

Piotr Maślanka piotrmaslanka

View GitHub Profile
@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 / gist:83fcf36b0f28b423bafc
Last active January 7, 2023 21:52
In case you fuck your SyncMaster's 2343NW EDID
If you suddently find your SyncMaster 2343 fucking at low resolution, DON'T WORRY.
Your EDID card is toast. It's the card that tells the computer what resolutions are supported.
Again, don't worry. This shit supports only VGA, and that sucks, but you can still win.
First, make sure you have a graphics control panel sophisticated enough to manually define resolutions.
When you do, whip it up. You are going to manually configure it.
Native resolution is 2048x1152, 60 Hz.
@piotrmaslanka
piotrmaslanka / smokmeteo.py
Created August 7, 2016 12:19
A script for SMOK4 (https://smok.co) to query GSM devices about current external temperature
from sai.devices import Sensor, Pathpoint, get_all_devices, slTREND
from sai.orders import acADVISE, Section
from sai.basic import ur
def find_applicable_devices():
"""
Finds devices that are applicable to be taken under QoR.
:return: list of Device objects
"""
@piotrmaslanka
piotrmaslanka / checkspam.py
Last active August 13, 2016 20:53
Runs thru your Dovecot inboxen, finds folders named "Spam" and unleashes the Fury of sa-learn --spam upon them. Best used on cron.
#!/usr/bin/python
import os
import os.path
SEARCH_DIRECTORY = '/var/vmail'
SPAM_FOLDER_NAME = '.Spam'
def analyze(path):
entries = os.listdir(path)
@piotrmaslanka
piotrmaslanka / queenofrain.py
Created February 15, 2017 22:24
smok.co: enumerate GSM BTS data + external temperature at a place
from sai.devices import Sensor, Pathpoint, get_all_devices, slTREND
from sai.orders import acADVISE, Section
from sai.basic import ur
def find_applicable_devices():
"""
Finds devices that are applicable to be taken under QoR.
:return: list of Device objects
"""
DOCKER_HOST=172.17.0.1 docker exec -it cassandra nodetool compactionstats | tail -n +3 | head -1 | awk '{ print $5/$6"% done"; }'
@piotrmaslanka
piotrmaslanka / djikstrainfix.py
Last active May 21, 2020 20:51
Implementation of Djikstra's shunting yard algorithm in Python
'''
Written by a Public Domain Fan. Means it's public domain :)
Piotr Maślanka <piotr.maslanka@henrietta.com.pl>
Targets: Python 2.7
'''
class MismatchedParenthesesException(Exception):