Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
gustavorv86 / samba-server-for-xiaomi-cameras.md
Last active July 11, 2023 08:17
How to configure a low-cost NAS server for a Xiaomi MI Home Security Camera

Samba Server configuration for Xiaomi MI Home Security Camera

This manual explains how to set up a low-cost NAS server to store videos from a Xiaomi camera, model MI Security Camera.

You can use a development board Linux based such as Raspberry PI or similar, an old PC, Barebone etc.

NAS Server Configuration

Install samba.

@gustavorv86
gustavorv86 / debian-12-bookworm-sources.list
Last active July 11, 2023 08:16
Debian 12 Bookworm full repositories
deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
@gustavorv86
gustavorv86 / dd-wrapper.sh
Last active June 23, 2023 15:18
dd (disk dump) wrapper. Prevents you from mistakenly writing to your computer's devices. Allows you to write only to the last removable connected device.
#!/bin/bash
BLACKLIST_DEVICES="/dev/sda /dev/sdb /dev/sdc /dev/sdd"
DD_BIN="/usr/bin/dd"
main() {
for arg in $@; do
for dev in $BLACKLIST_DEVICES; do
if [[ "$arg" == *"$dev"* ]]; then
@gustavorv86
gustavorv86 / split_string.c
Last active February 6, 2023 08:21
Split a string (char*) by a character in C/C++
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void string_split(char * string, char sep, char *** r_array_string, int * r_size) {
int i, k, len, size;
char ** array_string;
// Number of substrings
@gustavorv86
gustavorv86 / exos-bash.py
Created April 29, 2021 08:26
Execute a BASH shell on EXOS Extreme Switches (aka ExtremeXOS)
#!/usr/bin/env python
#
# On EXOS shell create exos-bash.py.
#
# EXOS> edit script exos-bash.py
#
# Copy this entire content to exos-bash.py file.
#
##################################
@gustavorv86
gustavorv86 / logger.py
Last active January 4, 2023 09:44
Python3 logging example
import logging
import os
LOG_ENVIRON = "LOGLEVEL"
LOG_LEVEL_DEFAULT = logging.INFO
LOG_FILE = "/tmp/myapplication.log"
LOG_FORMAT = '%(asctime)-15s [%(levelname)s] %(message)s'
LOG_NAME = "myapplication"
@gustavorv86
gustavorv86 / iptables.conf
Last active September 7, 2022 12:05
Default iptables configuration.
#!/bin/bash
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
@gustavorv86
gustavorv86 / attributes.py
Created April 16, 2022 10:37
Difference between Class Attributes and Instance Attributes in Python.
#!/usr/bin/env python3
class MyPersonClass:
# Class attributes
count_instances = 0
def __init__(self, name: str, surname: str, years: int):
MyPersonClass.count_instances += 1
@gustavorv86
gustavorv86 / signal-receiver.py
Last active April 16, 2022 10:23
Handling Linux process signals in Python
#!/usr/bin/env python3
import os
import signal
import sys
import time
PROCESS_PID_FILE = "process.pid"
_finish = False
@gustavorv86
gustavorv86 / argparse_example.py
Last active February 4, 2022 07:58
Python Argparse example
#!/usr/bin/env python3
import argparse
import sys
if __name__ == "__main__":
"""
Running examples: