Skip to content

Instantly share code, notes, and snippets.

View MarrekNozka's full-sized avatar
🤔

Marrek Nožka MarrekNozka

🤔
View GitHub Profile
@MarrekNozka
MarrekNozka / xterm-bg.sh
Created January 12, 2024 11:43 — forked from blueyed/xterm-bg.sh
Query background setting from terminal (xterm / rxvt-unicode)
#!/bin/sh
#
# Query a property from the terminal, e.g. background color.
#
# XTerm Operating System Commands
# "ESC ] Ps;Pt ST"
oldstty=$(stty -g)
# What to query?
@MarrekNozka
MarrekNozka / toolchain.sh
Last active January 12, 2023 18:45
Build STM8S toolchain
#!/bin/sh
mkdir src
cd src
sudo apt install stow
sudo apt build-dep sdcc
#sdcc-gas
git clone --depth 1 https://github.com/XaviDCR92/sdcc-gas.git
cd sdcc-gas
@MarrekNozka
MarrekNozka / URLs_and_paths.md
Last active February 11, 2022 16:18
Flask: URLs and path in request object

Flask: URLs and paths in request object

http://www.example.com/myapplication

request. variable content
path u'/π/page.html'
full_path u'/π/page.html?x=y'
script_root u'/myapplication'
base_url u'http://www.example.com/myapplication/π/page.html'
@MarrekNozka
MarrekNozka / main.c
Created April 30, 2021 07:16
TIM1 ultrasonic
// generuje na výstupu PC5 kladný impulz o délce PULSE_LEN jako spouštěcí impulz pro ultrazvukvý modul
// detekuje na pinu PC1 (TIM1_CH1) pomocí funkce input capture příchod echo pulzu z ultrazvukového modulu a měří jeho délku
// měření zpracovává neblokujícím způsobem periodicky opakuje. Výsledek vrací do proměnné capture
// pomocí proměnné/vlajky capture_flag informuje zbytek programu že byl změřen nový výsledek
#include "stm8s.h"
#include "milis.h"
#define PULSE_LEN 2 // délka spouštěcího (trigger) pulzu pro ultrazvuk
#define MEASURMENT_PERIOD 100 // perioda měření ultrazvukem (měla by být víc jak (maximální_dosah*2)/rychlost_zvuku)
void process_measurment(void);
// Vzorový projekt
#include "stm8s.h"
#include "assert.h"
#include "stdio.h"
#include "milis.h"
//#include "spse_stm8.h"
//#include "stm8_hd44780.h"
<!DOCTYPE html>
<html>
<head>
<title>Ryba</title>
<link rel="shortcut icon" href="img/logo-ico.png">
<link rel="stylesheet" href="styles.css">
<meta charset="UTF-8">
</head>
#include "stm8s.h"
#include "milis.h"
#include <stdio.h>
#define LED_PORT GPIOC
#define LED_PIN GPIO_PIN_3
#define LED_ON GPIO_WriteHigh(LED_PORT, LED_PIN);
#define LED_OFF GPIO_WriteLow(LED_PORT, LED_PIN);
#define LED_FLIP GPIO_WriteReverse(LED_PORT, LED_PIN);
@MarrekNozka
MarrekNozka / main_uart.c
Last active February 3, 2021 07:32
uart snipp
void main(void) {
UART1_DeInit();
/* UART1 configuration ------------------------------------------------------*/
/* UART1 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- UART1 Clock disabled
@MarrekNozka
MarrekNozka / example.html.j2
Last active October 23, 2020 18:15 — forked from doobeh/example.html
Checkbox WTForms Example (in Flask)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form method="post">
{{ form.hidden_tag() }}
{% for e in form.example %}
@MarrekNozka
MarrekNozka / print256colours.sh
Created January 20, 2020 17:48 — forked from HaleTom/print256colours.sh
Print a 256-colour test pattern in the terminal
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256