This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib | |
// Relay on P1 that trigger washing machine start button | |
// Diagram : https://ae01.alicdn.com/kf/HTB11MlEa2Bj_uVjSZFpq6A0SXXaM.jpg | |
#include <TinyWireM.h> | |
#include "TinyRTClib.h" | |
RTC_DS1307 RTC; | |
void setup () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def pretty_print_file_size(file_size: int, use_base_2: bool = True, approximate: bool = True, suffix: str = 'B'): | |
""" | |
Output a file size as a human friendly str. | |
:param file_size: file size in bits to pretty print | |
:param use_base_2: choose between base 10 (False) or base 2 (True, default) divider | |
:param approximate: drop the float part of the result (True, default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################### | |
# to deactivate this script | |
# uncomment the following line | |
# and reboot | |
exit 0 | |
############################### | |
function clear_screen { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FROM debian:stable | |
# Install dependencies | |
apt-get update | |
apt-get install build-essential gcc g++ automake git-core autoconf make patch cmake libmysql++-dev mysql-server libtool libssl-dev binutils zlibc libc6 libbz2-dev subversion libboost-all-dev | |
# Create mangos user | |
useradd -m -d /home/mangos -c "MANGoS" -U mangos | |
su - mangos | |
cd ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#********************************************************************* | |
# Configuration | |
#********************************************************************* | |
DEF_GATEWAY="192.168.1.2" # default route | |
BCK_GATEWAY="192.168.1.1" # backup route | |
RMT_IP_1="8.8.8.8" # first remote ip to test | |
RMT_IP_2="8.8.4.4" # second remote ip to test | |
PING_TIMEOUT="15" # ping timeout in seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import csv | |
import psycopg2 | |
# Connection details: | |
dbname = 'sampledb' | |
user = 'postgres' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def brute(array): | |
""" Complexity : 1 + N * ( N + N ) = 1 + 2 * N * N ~= N ^ 2 | |
- 1 for the len(array) | |
- N for the loop(array) : | |
- N for the left sum(array) | |
- N for the right sum(array) | |
""" | |
indexes = [] | |
length = len(array) | |
for i in range(0, length): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import json | |
import logging | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
logger = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import time | |
import threading | |
class ThreadedClass(object): | |
""" Threading example class. | |
The run() method will be started and it will run in the background |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import collections | |
def dict_merge(dct: dict, merge_dct: dict): | |
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of | |
updating only top-level keys, dict_merge recurses down into dicts nested | |
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into | |
``dct``. |
NewerOlder