Skip to content

Instantly share code, notes, and snippets.

View ulrischa's full-sized avatar

ulrischa ulrischa

View GitHub Profile
@ulrischa
ulrischa / 0_reuse_code.js
Created November 30, 2013 20:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ulrischa
ulrischa / new_gist_file.php
Created November 30, 2013 20:20
Test php
<?php
echo 'hallo';
?>
@ulrischa
ulrischa / phpflatdir.php
Last active January 4, 2016 18:40
Php flat directory tree
<?
$iterator = new RecursiveDirectoryIterator ('rootdir');
$wrapper = new RecursiveIteratorIterator ($iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($wrapper as $elem) {
echo $elem->getFilename ();
}
?>
$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 / motion.conf
Created September 5, 2020 22:07
Motion Configuration
# 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)
#!/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 / enviro_db.py
Last active April 8, 2021 06:53
Save Enviro Data to DB
import mysql.connector
def save_enviro_data_in_db(vals):
print ("save db")
try:
mydb = mysql.connector.connect(
host="",
user="",
password="",
database="",
@ulrischa
ulrischa / check_links_curl.php
Last active March 26, 2023 19:29
PHP check dead links with cirl
@ulrischa
ulrischa / neuronal_net.py
Created April 8, 2023 11:52
Neuronales Netzwerk
import numpy as np
# Eingabedaten
X = np.array([[0, 0, 1],
[0, 1, 1],
[1, 0, 1],
[1, 1, 1]])
# Erwartete Ausgabedaten
y = np.array([[0],
@ulrischa
ulrischa / did_you_mean.php
Created April 29, 2023 12:38
Did you mean
<?php
function didYouMean($query, $suggestions) {
$querySoundex = soundex($query);
$similarSuggestions = [];
foreach ($suggestions as $suggestion) {
if (soundex($suggestion) == $querySoundex) {
$similarSuggestions[] = $suggestion;
}