Skip to content

Instantly share code, notes, and snippets.

View funvill's full-sized avatar

Steven Smethurst funvill

View GitHub Profile
<div class="authors form">
<p>Please update your personal information before submitting a story<br />
<strong>User ID: </strong>: <em><?php echo $profile_id ; ?></em><br />
<strong>Authority</strong>: <em><?php echo $authority ; ?></em> <?php
if( $authority >= 100 ) {
echo $this->Html->link( "Admin", array('controller'=>'admin/stories', 'action'=>'index' ) ) ;
}
if( $authority >= 50 ) {
echo ', '. $this->Html->link( "Slush readers index", array('controller'=>'slusher', 'action'=>'index' ) ) ;
@funvill
funvill / gist:aca591d14fcafcb7242d
Created August 19, 2014 18:44
Two forms submission on a single page
<pre><?php
var_dump( $_REQUEST ) ;
?>
<hr >
<form action="?" method="post">
one: <input type="text" name="one"><br>
two: <input type="text" name="two">
<input type="submit" value="Submit">
{
init: function(elevators, floors) {
var buttonPressed = []; //keep track of buttons presses
// loop over floors
_.each(floors, function(floor) {
floor.on("up_button_pressed", function() {
buttonPressed.push(floor.level);
@funvill
funvill / ino
Created November 5, 2015 02:02
Trying to get Ethernet libary working on the esp8266 chipset https://github.com/esp8266/Arduino/issues/962
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
IPAddress remote(192, 168, 1, 5);
@funvill
funvill / testSPI.c
Created November 5, 2015 18:21
A Arduino sketch to test the SPI library/ports
// include the SPI library:
#include <SPI.h>
#include <inttypes.h>
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// code
int payloadLength = sprintf(outBuf, "POST %s HTTP/1.1\r\nAuthorization: Basic %s","RW1lcnNvbklEOjEy\r\nContent-Length: %u\r\n\r\n%s", SET_VALUE_URL, "RW1lcnNvbklEOjEy", strlen(thisData), thisData);
// output
POST RW1lcnNvbklEOjEy
Content-Length: %u
%s HTTP/1.1
Authorization: Basic /srvice.cgi
@funvill
funvill / SerialRS485TestTeensy.ino
Created August 15, 2017 10:01
A test using the Teensy 3.1 to Sparkfun RS485 breakout to RS485 converter
/**
* Wiring
* ------------------------------------------
* Teensy Pin 0 RX1 ==> RS485 Breakout TX-0
* Teensy Pin 1 TX1 ==> RS485 Breakout RX-1
* Teensy Pin 2 ==> RS485 Breakout RST
* Teensy GND ==> RS485 Breakout GND and G
* Teensy VIN ==> RS485 Breakout 3-5V
*
* RS485 Breakout GND => RS485 Breakout G
@echo on
set ADDRESS=google.com
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%
#include <OneWire.h>
// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library
OneWire ds(6); // on pin 10 (a 4.7K resistor is necessary)
// CopyInsertExample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "vector"
// A counter for the creation of the class Foo
int FooCounter;
class Foo