Skip to content

Instantly share code, notes, and snippets.

@Cactus64k
Cactus64k / tm1637.py
Last active October 25, 2020 21:56
TM1637 display driver code for micropython with I2C
from micropython import const
class TM1637:
def __init__(self, i2c, brightness=7, power=True):
self.i2c = i2c
self.power = power
self.brightness = brightness
self.DIGITS = [0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0, 0xFE, 0xF6, 0x00]
self.TM1637_DATA_CMD = const(0x02) # 0x40 data command
@Cactus64k
Cactus64k / limit-number.py
Created October 24, 2020 22:52 — forked from baybatu/limit-number.py
Limiting input number between minimum and maximum values range in Python
def limit(num, minimum=1, maximum=255):
"""Limits input 'num' between minimum and maximum values.
Default minimum value is 1 and maximum value is 255."""
return max(min(num, maximum), minimum)
@Cactus64k
Cactus64k / font.py
Created May 27, 2020 18:11
Font for PCF8814, Micropython
font8x6 = [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00], # 20 [SPACE],
[0x00, 0x00, 0x00, 0x5f, 0x00, 0x00], # 21 !
[0x00, 0x00, 0x07, 0x00, 0x07, 0x00], # 22 "
[0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14], # 23 #
[0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12], # 24 $
[0x00, 0x23, 0x13, 0x08, 0x64, 0x62], # 25 %
[0x00, 0x36, 0x49, 0x55, 0x22, 0x50], # 26 &
[0x00, 0x00, 0x05, 0x03, 0x00, 0x00], # 27 '
[0x00, 0x00, 0x1c, 0x22, 0x41, 0x00], # 28 (
@Cactus64k
Cactus64k / WebServer.py
Created May 27, 2020 18:09
Micropython class for Web server
import socket
import gc
HTTP_STATUS = """
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>ESP Web Server:{status} Status Code</title>
</head>
@Cactus64k
Cactus64k / PCF8814.py
Created May 27, 2020 18:07
Micropython class for PCF8814 display (nokia 1100)
import time
import font
class PCF8814:
pixel_width = 96
pixel_height = 65
def __init__(self, ss, rst, sck, mosi):
self.ss = ss
self.rst = rst
#!/usr/sbin/nft -f
flush ruleset
define local = {192.168.16.0/24, 127.0.0.0/8 }
define out_if = enp0s3
table nat {
chain prerouting {
type nat hook prerouting priority 0;
# Template used to create this container: /usr/share/lxc/templates/lxc-debian
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)
# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)
#lxc.net.0.type = empty
lxc.apparmor.profile = generated
@Cactus64k
Cactus64k / repo-full-copy.sh
Created July 27, 2019 17:41 — forked from AgiosAndreas/repo-full-copy.sh
Полный перенос git репозитория на другой сервер
# Клонируем исходный репозиторий без рабочего каталога (--bare)
git clone --bare https://github.com/exampleuser/old-repository.git
cd old-repository.git
# Делаем mirror-push(будут скопированы все ветки и тэги) в новый репозиторий
git push --mirror https://github.com/exampleuser/new-repository.git
cd ..
# Удаляем папку с репозиторием
conky.config = {
alignment = 'top_right',
background = false,
double_buffer = true,
border_width = 1,
cpu_avg_samples = 2,
default_color = 'white',
default_outline_color = 'white',
default_shade_color = 'white',
default_bar_height = 8,
#!/bin/bash
REMOTE=server.com
REMOTE_PATH=/mnt/backup
DATE=$(date +%F)
LOCAL_PATH="/home/cactus /etc"
LOCAL_EXCLUDE=/etc/cron.daily/backup_exclude