Skip to content

Instantly share code, notes, and snippets.

void strcat_realloc(char** buff, char* str, intmax_t str_len, intmax_t* buff_size, intmax_t* buff_pos)
{
assert(buff != NULL);
assert(str != NULL);
assert(buff_size != NULL);
assert(buff_pos != NULL);
if(*buff_size - *buff_pos - 1 > str_len)
{
strcat(*buff, str);
int alloc_snprintf(char** out, const char* template, ...)
{
va_list list;
va_start(list, template);
int len = vsnprintf(NULL, 0, template, list);
va_end(list);
char* new_string = malloc((size_t)len + 1);
assert(new_string != NULL);
#!/bin/bash
REMOTE=server.com
REMOTE_PATH=/mnt/backup
DATE=$(date +%F)
LOCAL_PATH="/home/cactus /etc"
LOCAL_EXCLUDE=/etc/cron.daily/backup_exclude
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,
@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 ..
# Удаляем папку с репозиторием
# 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
#!/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;
@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
@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 / 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 (