Skip to content

Instantly share code, notes, and snippets.

View wiesson's full-sized avatar

Arne Wiese wiesson

View GitHub Profile
@wiesson
wiesson / calc_average.py
Last active December 20, 2015 02:09
Python script to find, combine and calculate the average values of csv data for the combustion engine intern/course at the at the University of Bayreuth. Usage as follows: python calc_average.py /folder list. Next, accept with (y) yes, or deny with (n) - Make sure you made a copy of the files before!
#! /usr/bin/env python
# usage: python calc_average.py folder list
# y / n
import os, sys
from decimal import *
def csv_average(file_input, file_folder, amount):
file_name = file_input
@wiesson
wiesson / batch_dl.sh
Created July 29, 2013 20:25
batch download for consecutively numbered files
for i in {1..31}; do if [ $i -le 9 ] ; then curl -O ##LINK##0$i.pdf ; else curl -O ##LINK##$i.pdf; fi ; done
@wiesson
wiesson / reader.py
Last active December 21, 2015 06:48
Simple MTConnect sample reader
#!/usr/bin/pyton
import sys, os
import thread, threading
import requests
from lxml import objectify, etree
import dateutil.parser
from datetime import datetime, date
import time
@wiesson
wiesson / reader.py
Last active December 21, 2015 18:59
MTConnect probe reader with requests
# import requests
namespace = True
def mt_request():
url = 'http://agent.mtconnect.org/sample'
payload = { 'interval': '1000', 'count':'20' }
r = requests.get(url, params=payload, stream=True)
part = []
@wiesson
wiesson / pool.py
Last active January 4, 2019 18:58
Load *.eml files from a folder Usage: python sendmails.py --start path/to/
from multiprocessing import Pool
import os, sys
import email, smtplib
storage_folder = "data/export"
mail_server = 'server-address'
mail_username = 'mail-user'
mail_password = 'mail-password'
@wiesson
wiesson / pfusch.py
Last active January 2, 2016 02:59
mhmm
threads = []
for t in threading.enumerate():
threads.append(t.getName())
return render_template("devices/index.html", devices=g.devices, threads=threads)
return render_template("devices/index.html", devices=g.devices,
map(lambda x: x.getName(), threading.enumerate()))
@wiesson
wiesson / frontend.html
Last active August 29, 2015 13:56
XMLHttpRequest "DELETE" call to the flask backend. No jquery is required.
<button id="deleteDevice" class="btn btn-danger btn-xs"
data-link="{{ url_for('monitor.delete_device', id_device=device.id_device) }}">
<span class="glyphicon glyphicon-remove-circle"></span>
Delete Device
</button>
<script type="text/javascript">
var t = document.getElementById('deleteDevice');
t.addEventListener('click', function () {
deleteDevice(t.dataset.link);
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
# !/usr/bin/env python
import os
import argparse
from app import create_app
from flask.ext.script import Manager
parser = argparse.ArgumentParser()
parser.add_argument("go", help="runserver, test, shell")
import arrow
print(tarrow.utcnow().replace(days=-1))
# 2014-10-06T12:09:34.152402+00:00
print(tarrow.utcnow().replace(months=-1))
# 2014-09-13T12:09:34.152573+00:00
print(tarrow.utcnow().replace(months=-3))
# 2014-07-13T12:09:34.152685+00:00