Skip to content

Instantly share code, notes, and snippets.

View malja's full-sized avatar

Jan Malčák malja

View GitHub Profile
@malja
malja / check_bank_account_number.php
Last active July 17, 2023 18:23
Validace čísla bankovního účtu pro Českou republiku v PHP.
<?php
/**
* Funkce pro kontrolu čísla bankovního účtu v ČR.
* @param $number string Řetězec obsahující číslo bankovního účtu ve formátu:
* [prefix]-základní část/kód bank.
* Prefix je volitelná část obsahující až šest čísel. Od
* základní části je oddělen pomlčnou.
* Základní část se skládá ze dvou až deseti čísel.
* Poslední částí je kód banky. Ten je složen ze čtyř čísel
@malja
malja / default.css
Created January 3, 2018 11:56
PPS test HTML část
body {
/* Nutné kvůli height 100vh*/
display: flex;
flex-direction: column;
/* Asi nepotřebné */
width: 100%;
/* Margin je na main */
margin: 0px;
@malja
malja / 2d_graph.py
Created January 3, 2018 13:23
PPS test grafy
import matplotlib.pyplot as plt
ekg_data = []
fpg_data = []
with open("./zadani/ekg.txt") as file:
for line in file:
ekg_data.append( float(line.replace("\n", "").replace("o", "0").replace(",", ".")) )
with open("./zadani/fpg.txt") as file:
@malja
malja / file_exists_access.cpp
Last active May 28, 2018 20:27
Three methods for checking if file exists in C++.
#include <string>
#include <unistd.h>
// Funkce bere za parametr jméno souboru
bool fileExists(const std::string &file_name) {
// Pokud soubor existuje
if ( access( file_name.c_str(), F_OK ) != -1 ) {
// Vrátí true
return true;
// V opačném případě
@malja
malja / sdl2_screenshot.cpp
Last active April 11, 2024 08:51
Create screenshot in SDL2
// Save screenshot
// file: Filename for created screenshot
// renderer: pointer to SDL_Renderer
bool saveScreenshot(const std::string &file, SDL_Renderer *renderer ) {
// Used temporary variables
SDL_Rect _viewport;
SDL_Surface *_surface = NULL;
// Get viewport size
SDL_RenderGetViewport( renderer, &_viewport);
@malja
malja / style.css
Created September 5, 2018 19:38
PHP class for creating pretty HTML table from PHP array
/************************************************************************\
|
| CSS Theme
| =========
|
| This is a default CSS theme for tabletizer class.
|
\************************************************************************/
table.tabletizer {
@malja
malja / minercraft_server_status.php
Created September 5, 2018 20:04
PHP class for getting minecraft server status - number of players, MOTD, version and ping
<?php
class ServerStatus {
/*private $motd;
private $address;
private $ip;
private $port;
private $version;
private $players;
private $max_players;
@malja
malja / runtime.php
Created September 6, 2018 07:03
PHP class for measuring function execution time
<?php
/***********************************************************************\
|
| RunTime Class
| =============
| Class to measuring the execution time of function or method.
|
| Author: malja <github.com/malja>
| Version: 1.0
| Created: 26. 8. 2013
@malja
malja / README.md
Last active May 12, 2023 09:03
MSP430FR50431 millis() implementation

Implementation of millis() function froom Arduino on MSP430FR50431 processor

This gits implements function millis() known from Arduino ecosystem. What it does is that it counts number of milliseconds since the program started. It uses timer TA3, set to UP mode with custom TA3CCR0 value.

When user runs function millis(), it returns value from the counter.

Timer TA3

This timer is set to UP mode. It means that the timer counts up to the value stored in TA3CCR0 register.

@malja
malja / i2c_master.c
Last active September 2, 2021 12:18
MSP430FR50431 I2C master with interruptions
#include <i2c_master.h>
// BIT_SET is macro for REGISTER |= (BIT)
// BIT_CLEAR is macro for REGISTER &= ~(BIT)
//
#include <macros.h>
#include <driverlib.h>
#include <config.h>
#include <string.h>
#include <clock.h>