Skip to content

Instantly share code, notes, and snippets.

🏠
Home-Office

T. Meissner tmeissner

🏠
Home-Office
View GitHub Profile
@tmeissner
tmeissner / gist:4246604
Created Dec 9, 2012
Generic function to send commands over the SPI interface of an AVR uC
View gist:4246604
// defines for all commands and the max length of spi messages
#define CHIPERASE "\xc7\x94\x80\x9a"
#define SPILENGTH 32
// array to receive data
unsigned char spi_rxdata[SPILENGTH];
// transfer a byte on spi
static unsigned char spi_transfer (unsigned char c) {
SPDR = c;
@tmeissner
tmeissner / file_upload.py
Created Dec 16, 2012
Python file upload
View file_upload.py
#!/usr/bin/python
import yate
import cgi
import os
form = cgi.FieldStorage()
item = form["filename"]
message = 'File uploaded'
View file_upload.html
<!DOCTYPE html>
<html>
<head>
<title>File upload</title>
</head>
<body>
<h1>File upload</h1>
<p>
@tmeissner
tmeissner / yate.py
Created Dec 16, 2012
Yet another template engine: a collection of simple functions to generate HTML content (taken from 'Head first Python' and expanded)
View yate.py
def start_response(resp="text/html"):
return('Content-type: ' + resp + '\n\n')
def html_header(title="default"):
return("""
<head>
<meta charset="utf-8" />
<title>""" + title + """</title>
</head>"""
)
@tmeissner
tmeissner / avr_fifo.c
Last active Dec 19, 2015
Fifo implementation for AVR 8-bit controller
View avr_fifo.c
struct fifo {
uint8_t size; /* size of buffer in bytes */
uint8_t read; /* read pointer */
uint8_t write; /* write pointer */
unsigned char buffer[]; /* fifo ring buffer */
};
/* define a FIFO type for 'size' bytes */
#define MK_FIFO(size) \
struct fifo_ ## size { \
@tmeissner
tmeissner / w1-therm.sh
Last active Jun 1, 2020
Bash script to read out the DS18B20 1wire temp sensor. You have to modprobe the w1-gpio and w1-therm modules before using it.
View w1-therm.sh
#!/bin/bash
THERM=$(cat $1)
CPU=$(cat /sys/class/thermal/thermal_zone0/temp)
@tmeissner
tmeissner / w1-mail.sh
Last active Dec 19, 2015
Spam yourself with eMails containing the temperature measured by your 1wire temperature sensor ;)
View w1-mail.sh
#!/bin/bash
read -r BLA
TEMP=$(echo $BLA | sed "s/.*\([0-9][0-9].[0-9][0-9][0-9]\)/\1/")
echo $TEMP | mail -s "Temperatur" $1
@tmeissner
tmeissner / raspifoto.sh
Created Jul 21, 2013
Take a foto with the camera board and save it under name with date in it
View raspifoto.sh
#!/bin/bash
raspistill -t 100 -vf -hf -q 50 -o $(date +%Y-%m-%d-%T).jpg
@tmeissner
tmeissner / raspiTemp.js
Last active Dec 20, 2015
draw a nice chart of measured temperatures with the help of highchart.js
View raspiTemp.js
// variable to en-/disable debug
// set to 1 to enable debug log
if (DEBUG === undefined) {
var DEBUG = 0;
}
// wrap all in anonymous function to get out of global scope
(function () {
@tmeissner
tmeissner / raspiweb.py
Last active Dec 20, 2015
python cgi script to generate temperature data in JSON format
View raspiweb.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi
import json
import re
import os
import hashlib
import base64
import datetime
You can’t perform that action at this time.