Skip to content

Instantly share code, notes, and snippets.

View speters's full-sized avatar

Sönke J. Peters speters

View GitHub Profile
@speters
speters / pramod.ranade.c
Last active December 31, 2021 02:44 — forked from tmpvar/pramod.ranade.c
See "Linear motion control without the math" by Pramod Ranade in http://www.nxtbook.com/nxtbooks/cmp/esd0409/index.php?startid=23 (Embedded System Design Vol 22, #4, April 2009) and http://picprog.strongedge.net/step_prof/step-profile.html
/*
step.c
Program to verify new algorithm for linear acceleration.
Author: Pramod Ranade <[email protected]>
*/
#include <stdio.h>
#if defined(_WIN32) || defined(_WIN64)
#include <io.h>
#endif
@speters
speters / hd44780sim.serialwombat.c
Last active December 23, 2015 05:09
jbroadwell tried to simulate an hd44780 lcd in http://www.microchip.com/forums/m227487.aspx This is the indented code posted therein.
/*
* hd44780 simulator
* from
* http://www.microchip.com/forums/m227487-print.aspx
* 2/2007 by jbroadwell
*/
#define FIRST_NIBBLE 0
#define SECOND_NIBBLE 1
#define DDRAM_SIZE 128
typedef struct hd44780_n
@speters
speters / ihexcrc.py
Last active September 4, 2024 14:01
ihex crc recalculatorCalculates the checksums of lines in an ihex/intel hex file. Useful for patching a hex file.
#!/usr/bin/env python
#
# Intel HEX file CRC recalculator
# ihexcrc.py FILEWITHDAMAGEDCRC.HEX > NEWFILE.HEX
#
# See http://goodfet.sourceforge.net/dist/intelhex.py
# for a more elaborate version
#
from binascii import hexlify, unhexlify
import sys
@speters
speters / Digital_Feed_2e.ino
Last active December 28, 2015 20:59
Elektronische Leitspindel für eine Drehmaschine mit dem Arduino Mega2560.Version 1a von http://www.chipmaker.ru/files/file/9787/ Urspungsthema in http://www.chipmaker.ru/topic/97701/
#include <avr/pgmspace.h>
// ***** LCD *****
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
char LCD_Row_1[17];
char LCD_Row_2[17];
@speters
speters / xmasraffle.sh
Created December 19, 2013 11:17
Proof of concept for a now closed bug
ENTRYURL='http://go.stayfriends.de/***/xmasRaffle'
COOKIEFILE='cookies.txt'
USER_AGENT="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0"
wget -U "${USER_AGENT}" --spider -S --keep-session-cookies --save-cookies=$COOKIEFILE $ENTRYURL
COOKIEHEADER=`awk -v ORS='' 'BEGIN {print "Cookie: "} /stayfriends/{print $6"="$7"; " } ' < $COOKIEFILE `
# local test against nc -l 8080
@speters
speters / screenshot.js
Created December 19, 2013 13:24
Simple PhantomJS screenshot script
#!/usr/local/bin/phantomjs
var page = require('webpage').create();
var system = require('system');
var t, address;
if (system.args.length === 1) {
console.log('Usage: screenshot.js <some URL>');
phantom.exit();
}
@speters
speters / mailcatch.py
Last active March 14, 2016 16:05
A simple utility to forward mailcatch.com temporary mailboxes via SMTP
#! /usr/bin/env python
import urllib2
from xml.dom import minidom, Node
from sys import argv
import smtplib
import ConfigParser, os
config = ConfigParser.SafeConfigParser({'smtphost': 'localhost', 'smtpuser':'', 'smtppass':'', 'forwardto':''})
config.read(['/etc/smtpclient.ini', os.path.expanduser('~/.smtpclient.ini')])

Keybase proof

I hereby claim:

  • I am speters on github.
  • I am soenke (https://keybase.io/soenke) on keybase.
  • I have a public key whose fingerprint is D33D 153A A5D3 937E 8D99 907F EFC4 178C F358 FDCA

To claim this, I am signing this object:

@speters
speters / post-commit
Created September 10, 2015 18:44
git post-commit hook script to copy a subdirectory of the repo to another folder
#!/bin/sh
# copy a subdirectory of a repository to another location after commit
DESTINATIONDIR=/usr/share/arduino/libraries
# subdirectory in repo to copy:
CHECKOUTSUBDIR=TMRpcm
mkdir /tmp/bla
unset GIT_INDEX_FILE
GIT_WORK_TREE=${DESTINATIONDIR} git checkout -f -- ${CHECKOUTSUBDIR}
@speters
speters / xfiles.h
Created September 17, 2015 13:16
C macro to for binary file inclusion
/* Copyright (c) 2008 Carlos Lamas
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright