Skip to content

Instantly share code, notes, and snippets.

@thomo
thomo / env.rb
Created August 12, 2010 08:50
Environment file for cucumber + couchapp. Use test db defined in .couchapprc for feature run.
require 'rubygems'
require 'culerity'
require 'cucumber/formatter/unicode'
require 'restclient'
require 'couchrest'
def read_couchapprc
json = ""
File.open(File.join(APP_PATH, ".couchapprc")).each { |line| json << line }
JSON.parse(json)
@thomo
thomo / .couchapprc
Created August 12, 2010 20:07
Example .couchapprc (couchapp, couchdb)
{
"env": {
"default": {
"db-example": "http://user:pass@localhost:5984/myapp-dev",
"db": "http://192.168.111.1:5984/rem-dev"
},
"test": {
"db": "http://localhost:5984/rem-test"
},
"production": {
@thomo
thomo / gist:971369
Created May 13, 2011 21:45
Convert .ogg to .mp3
find . -name *.ogg | while read xxx
> do
> oggdec -o - "$xxx"| lame -h -V 4 --vbr-new - "$(dirname "$xxx")/$(basename "$xxx" .ogg).mp3"
> done
@thomo
thomo / programmer-patch.txt
Created February 12, 2012 17:50
Arduino STK500v2 Serial patch
#
# /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/programmer.txt
#
stk500v2.name=AVRISPv2/STK500v2 (serial)
stk500v2.communication=serial
stk500v2.protocol=stk500v2
@thomo
thomo / avrnetio_udpsend.ino
Created July 8, 2012 12:59
A demo of sending udp packets, using Pollin AVR NETIO board, Arduino 1.0.1, avr-netino project
//
// Environment: Pollin AVR NETIO board, Arduino 1.0.1, avr-netino (https://code.google.com/p/avr-netino/)
//
// This is a demo of sending udp packets
// 2012-07-08 <Thomas.Mohaupt@gmail.com> http://creativecommons.org/licenses/by-sa/3.0/
// Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
//
// On destination site you can receive the packets e.g. with
// nc -4ul 7777
//
@thomo
thomo / VerifyStaticCallTest.java
Created October 19, 2012 03:29
Unittest to verify that static method is called - PowerMock, Mockito, TestNG
package abc;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import java.awt.Component;
import javax.swing.JOptionPane;
import org.powermock.api.mockito.PowerMockito;
@thomo
thomo / gist:4070617
Created November 14, 2012 06:14
Coding Horror: do while with goto instead of break
Function(parameters){
Boolean found = false;
do{
for(counter){
such etwas in einem Array
if(bedingung) {
found = true;
goto do_end
}
}
@thomo
thomo / avrnetio_udpreceive.ino
Last active December 10, 2015 01:34
This is a demo of receiving udp packets with an avr-netio board, Arduino and avr-netino.
//
// Environment:
// * Pollin AVR NETIO board,
// * Arduino 1.0.3,
// * avr-netino (https://code.google.com/p/avr-netino/)
//
// This is a demo of receiving udp packets
//
// 2012-12-22 <Thomas.Mohaupt@gmail.com> http://creativecommons.org/licenses/by-sa/3.0/
// Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
@thomo
thomo / tcpip.cpp
Created December 22, 2012 14:29
Patched tcpip.cpp file from avr-netino (http://code.google.com/p/avr-netino/) version avr-netino-19Jan2012.zip - add support of receiving udp packets
// IP, Arp, UDP and TCP functions.
// Author: Guido Socher
// Copyright: GPL V2
//
// The TCP implementation uses some size optimisations which are valid
// only if all data can be sent in one single packet. This is however
// not a big limitation for a microcontroller as you will anyhow use
// small web-pages. The web server must send the entire web page in one
// packet. The client "web browser" as implemented here can also receive
// large pages.
#!/usr/bin/env python
import socket
# Set the socket parameters
# avr-netio ip address
host = "10.0.0.52"
# avr-netio port
port = 7777
addr = (host,port)