Skip to content

Instantly share code, notes, and snippets.

@jezman
jezman / send_image.py
Last active September 9, 2016 06:52
The script for motion app. Executed when a picture is saved. Script send image to telegram and move files to folder.
#!/usr/bin/env python
import requests
import sys
import os
import datetime
import shutil
hours = ('09', '10', '11', '12', '13', '14', '15', '16', '17', '18')
days = ('6', '7')
@jezman
jezman / sensor_status.py
Created September 8, 2016 11:10
The script for motion app. Executed when a motion frame is detected. Writes the sensor status.
#!/usr/bin/env python
import RPi.GPIO as GPIO
from time import sleep
pir_sensor = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(pir_sensor, GPIO.IN)
@jezman
jezman / dht11.py
Last active September 10, 2016 08:11
RaspberryPi + DHT11 + PostgreSQL
#!/usr/bin/env python
import Adafruit_DHT
import psycopg2
from time import strftime
DHT_MODEL = 11
GPIO = 4
humidity, temperature = Adafruit_DHT.read_retry(DHT_MODEL, GPIO)
@jezman
jezman / switch.py
Last active September 9, 2016 08:27
RaspberryPi relay switch. 0 - NC, 1 - NO
#!/usr/bin/env python
import RPi.GPIO as GPIO
import sys
PIN = 4
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.OUT)
@jezman
jezman / brightness.py
Created September 8, 2016 13:20
RapberryPi lcd + pwm
#!/usr/bin/env python
from time import strftime, sleep
import RPi.GPIO as GPIO
pwm_pin = 18
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(pwm_pin, GPIO.OUT)
@jezman
jezman / dht11.rb
Created September 8, 2016 13:35
DHT11 + QuadDisplay
#!/usr/bin/env ruby
require 'dht-sensor-ffi'
require 'rpi_gpio'
PIN = 7
DHT_MODEL = 11 # 11 or 22
RPi::GPIO.set_numbering :board
RPi::GPIO.set_warnings(false)
@jezman
jezman / volume.py
Last active September 11, 2016 10:19
RaspberryPi + HC-SR04(x3)
#!/usr/bin/env python
import RPi.GPIO as GPIO
from time import sleep, time
BEEP_PIN = 16
TRIG_X = 18
ECHO_X = 22
TRIG_Y = 17
@jezman
jezman / zabbix_backup.sh
Created September 8, 2016 14:21
Zabbix backup
#!/bin/bash
DAY=`date +%Y-%m-%d`
DIR=/home/zabbix/backup/Zabbix_$DAY
set_date()
{
DT=`date "+%y-%m-%d %H:%M:%S"`
}
@jezman
jezman / temperature.py
Created September 10, 2016 08:47
RaspberryPi + LCD + OWM
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Adafruit_CharLCD as LCD
import psycopg2
from pyowm import OWM
from time import sleep
# В ПОМЕЩЕНИИ
msg_in_room = ('\x42 \xA8\x4F\x4D\x45\xE2\x45\x48\xA5\xA5')
@jezman
jezman / geo_ip.py
Created February 7, 2017 07:36
GeoIP DB by Pentestit
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from requests import get
from sys import argv
ip = argv[1]
r = get('https://ip.pentestit.ru/json.php?ip=' + ip)
data = r.json()