Skip to content

Instantly share code, notes, and snippets.

View tmeissner's full-sized avatar
🏠
Home-Office

T. Meissner tmeissner

🏠
Home-Office
View GitHub Profile
@tmeissner
tmeissner / gist:4246604
Created December 9, 2012 19:19
Generic function to send commands over the SPI interface of an AVR uC
// 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 December 16, 2012 23:28
Python file upload
#!/usr/bin/python
import yate
import cgi
import os
form = cgi.FieldStorage()
item = form["filename"]
message = 'File uploaded'
@tmeissner
tmeissner / file_upload.html
Created December 16, 2012 23:30
HTML file upload
<!DOCTYPE html>
<html>
<head>
<title>File upload</title>
</head>
<body>
<h1>File upload</h1>
<p>
@tmeissner
tmeissner / yate.py
Created December 16, 2012 23:34
Yet another template engine: a collection of simple functions to generate HTML content (taken from 'Head first Python' and expanded)
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 March 13, 2022 02:42
Fifo implementation for AVR 8-bit controller
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 June 1, 2020 06:09
Bash script to read out the DS18B20 1wire temp sensor. You have to modprobe the w1-gpio and w1-therm modules before using it.
#!/bin/bash
THERM=$(cat $1)
CPU=$(cat /sys/class/thermal/thermal_zone0/temp)
@tmeissner
tmeissner / w1-mail.sh
Last active December 19, 2015 16:39
Spam yourself with eMails containing the temperature measured by your 1wire temperature sensor ;)
#!/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 July 21, 2013 10:27
Take a foto with the camera board and save it under name with date in it
#!/bin/bash
raspistill -t 100 -vf -hf -q 50 -o $(date +%Y-%m-%d-%T).jpg
@tmeissner
tmeissner / raspiTemp.js
Last active December 20, 2015 08:49
draw a nice chart of measured temperatures with the help of highchart.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 December 20, 2015 09:40
python cgi script to generate temperature data in JSON format
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi
import json
import re
import os
import hashlib
import base64
import datetime