Skip to content

Instantly share code, notes, and snippets.

View darrenmothersele's full-sized avatar
🏠
Working from home

Darren Mothersele darrenmothersele

🏠
Working from home
View GitHub Profile
@darrenmothersele
darrenmothersele / JS: Example Drupal Behavior.js
Created April 12, 2013 09:21
JS: Example Drupal Behavior
(function ($) {
Drupal.behaviors.exampleModule = {
attach: function (context, settings) {
$('.example', context).click(function () {
$(this).next('ul').toggle('show');
});
}
};
@darrenmothersele
darrenmothersele / JYMCUExample.ino
Created October 8, 2013 14:40
A simple Arduino sketch that just passed data between the Arduino's hardware serial port and a Bluetooth device connected as a software serial device on pins 10 and 11.
#include <SoftwareSerial.h>
#define BT_TX 10
#define BT_RX 11
SoftwareSerial BluetoothSerial(BT_TX, BT_RX);
void setup(){
Serial.begin(9600);
BluetoothSerial.begin(9600);
}
@darrenmothersele
darrenmothersele / UDPLED.ino
Created October 8, 2013 16:35
A simple sketch to demonstrate control of LED pixels via UDP.
#include <EtherCard.h>
#include <IPAddress.h>
#include "FastSPI_LED2.h"
#define NUM_LEDS 8
#define DATA_PIN 6
CRGB pixels[NUM_LEDS];
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
@darrenmothersele
darrenmothersele / Walker.h
Last active February 27, 2019 21:52
Translation of I.1 from Nature of Code to openFrameworks
#ifndef mySketch_Walker_h
#define mySketch_Walker_h
class Walker {
int x;
int y;
public:
Walker() {
x = ofGetWidth() / 2;
scale 0.4
rotate time / 800, time / 800, time / 1000
spread = ((frame / 10) % 10) - 5
move -2*spread,-2*spread,-2*spread
3 times ->
move 0,0,spread
pushMatrix
3 times ->
move 0,spread,0
pushMatrix
background 0
animationStyle paintOver
noFill
strokeSize 10
scale 6
rotate 0,((time / 2000) % (Math.PI * 2)) - Math.PI,0
stroke 255,255,0,100
ball
rotate 1,- 2 * ((time / 2000) % (Math.PI * 2)) - Math.PI,0
stroke 255,0,0,100
@darrenmothersele
darrenmothersele / gist:7186705
Created October 27, 2013 19:18
colour cycles
background 0
animationStyle paintOver
noFill
strokeSize 10
scale 6
rotate ((time / 2000) % (Math.PI * 2)),((time / 2000) % (Math.PI * 2)) - Math.PI,0
stroke 255,(time % 255),255
ball
rotate 1,- 2 * ((time / 2000) % (Math.PI * 2)) - Math.PI,0
stroke 255,(time % 255),0
background 0
twoPI = Math.PI * 2
animationStyle paintOver
noFill
strokeSize 10
scale 20 + 5 * (sin((time / 1000) % twoPI))
rotate ((time / 2000) % (Math.PI * 2)),((time / 2000) % (Math.PI * 2)) - Math.PI,0
stroke 255,(time % 255),255
//stroke black
ball
noFill
background 0
strokeSize (time / 1000) % 10
scale 6
rotate 0,time / 10000,0
stroke 255,0,0,75
peg
10 times ->
rotate 0, - time / 100000, 0
strokeSize (time / 100) % 10
@darrenmothersele
darrenmothersele / gist:7597016
Created November 22, 2013 09:06
Sending base64 encoded data via HTTP in C++ using openFrameworks and Poco Net Libraries
// The main openFrameworks include
#include "ofMain.h"
// Poco is included in openFrameworks 0.8.0
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Base64Encoder.h"
#include "Poco/Net/HTMLForm.h"
#include "Poco/Net/StringPartSource.h"
#include "Poco/StreamCopier.h"