Skip to content

Instantly share code, notes, and snippets.

@MrTrick
MrTrick / gist:1940376
Created February 29, 2012 12:04
Simple OPC client - that doesn't work.
using System;
using System.Collections.Generic;
using System.Text;
using Softing.OPCToolbox;
using Softing.OPCToolbox.Client;
namespace opc_simple
{
class Program
{
@MrTrick
MrTrick / opc_array.cs
Created February 29, 2012 22:52
Simple OPC DA Client to read/write arrays
//-----------------------------------------------------------------------------
// |
// Mindbleach Engineering, Australia |
// |
// Copyright (c) 2012 Mindbleach Engineering |
// All Rights Reserved |
// |
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// OPC DA Array Client |
@MrTrick
MrTrick / gist:3295006
Created August 8, 2012 13:26
Expected behaviour for splat routes
<?
/**
* My_Router: Routing splats, more edge cases
*/
public function testRoutingMoreSplats() {
$router = new My_Router();
$router->on('route',array($this, 'onRoute'));
$router->route('foo/*bar', 'foo');
$this->assertTrue( $router('foo/bar/baz') );
[minion@dev subversion-1.7.7]$ make
------ making all in apr
make[1]: Entering directory `/tmp/subversion-1.7.7/apr'
make[2]: Entering directory `/tmp/subversion-1.7.7/apr'
/bin/sh /libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I./include -I/tmp/subversion-1.7.7/apr/include/arch/unix -I./include/arch/unix -I/tmp/subversion-1.7.7/apr/include/arch/unix -I/tmp/subversion-1.7.7/apr/include -o passwd/apr_getpass.lo -c passwd/apr_getpass.c && touch passwd/apr_getpass.lo
/bin/sh: /libtool: No such file or directory
make[2]: *** [passwd/apr_getpass.lo] Error 127
make[2]: Leaving directory `/tmp/subversion-1.7.7/apr'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/subversion-1.7.7/apr'
@MrTrick
MrTrick / firefly.asm
Created October 30, 2012 13:57
Code for the Widget's Firefly Application
;**********************************************************************
; *
; Filename: firefly.asm *
; Date: 2007-11-22 *
; File Version: 1.0a *
; Author: MrTrick *
; Description: This file provides relocatable code for managing *
; the logic of a group of fireflies, where all the *
; fireflies will 'flash' regularly, and slowly become*
; irregularly synchronised with each other. *
@MrTrick
MrTrick / Model snippet - validate.php
Created November 2, 2012 04:40
Backbone save issue
/**
* Validate the given attributes according to the '$validation' rules and '$access_control' policies.
* Return any errors in a map by attribute.
* If no errors are found, the response will be empty.
*
* By default, missing attributes are not considered to be an error.
*
* Options:
* - missing : If set, return errors for missing attributes that have a rule 'required'=>true
*

s = 16 : number of slots n = 256 : max number of nodes id : 8-bit id, unique to each node k : The number of cycles it takes to detect another transmission

Slots start at fixed, even intervals.

[#0               |#1               |   ...   |#F               ]
@MrTrick
MrTrick / button.c
Created November 18, 2012 14:22
1 Button debouncing library
/*
* button.c
*
* Created: 18/11/2012 12:42:18 AM
* Author: MrTrick
*/
/************************************************************************/
/* SYSTEM INCLUDES */
/************************************************************************/
@MrTrick
MrTrick / gist:4110724
Created November 19, 2012 13:46
ATMEGA328P Timer2 notes - for setting up RTC tick source
PRTIM2 bit in ”Minimizing Power Consumption” on page 41 must be written to zero to enable Timer/Counter2
module.
Timer has storage registers;
- TCNT2 counting register
- OCR2A output compare register A
- OCR2B output compare register B
(OCR2A/B compared to TCNT2, can drive waveform generator)
Control registers;
@MrTrick
MrTrick / ISR A.c
Created December 10, 2012 13:49
Dodgy ticker This very frustrating Heisenbug is incrementing the clock twice as fast as it should, except when I put in debugging code or try to step through it with the in-circuit debugger. I've managed to reliably reproduce the buggy behaviour: * B increments the minute_hand variable every 10 seconds, as it's supposed to. (period shortened for…
//This code is called every second.
//It should increment the minute_hand variable every 10 seconds and update which LED is lit.
//It's incrementing minute_hand and updating the LED every FIVE seconds.
// volatile unsigned char minute_hand;
// volatile unsigned char hour_hand;
// volatile unsigned short seconds;
/**
* TICK! Once every second, regardless of anything else that happens.
* (Even while sleeping)