Skip to content

Instantly share code, notes, and snippets.

@ulrischa
ulrischa / enviro_db.py
Last active Apr 8, 2021
Save Enviro Data to DB
View enviro_db.py
import mysql.connector
def save_enviro_data_in_db(vals):
print ("save db")
try:
mydb = mysql.connector.connect(
host="",
user="",
password="",
database="",
View email_n.py
#!/usr/bin/python
import yagmail
import sys
#initializing the server connection
yag = yagmail.SMTP(user='sender@sender', password='xxx')
#sending the email
yag.send(to='to@to', subject='Motion detected', contents=['Motion', sys.argv[1]])
print("Email sent successfully")
@ulrischa
ulrischa / motion.conf
Created Sep 5, 2020
Motion Configuration
View motion.conf
# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 4.1.1
# Documentation: /usr/share/doc/motion/motion_guide.html
############################################################
# Daemon
############################################################
# Start in daemon (background) mode and release terminal (default: off)
View upload_image.php
$target_dir = "pic/";
$target_file = $target_dir . 'ndvi.jpg';
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
@ulrischa
ulrischa / phpflatdir.php
Last active Jan 4, 2016
Php flat directory tree
View phpflatdir.php
<?
$iterator = new RecursiveDirectoryIterator ('rootdir');
$wrapper = new RecursiveIteratorIterator ($iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($wrapper as $elem) {
echo $elem->getFilename ();
}
?>
@ulrischa
ulrischa / 0_reuse_code.js
Created Nov 30, 2013
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console