Skip to content

Instantly share code, notes, and snippets.

View sampottinger's full-sized avatar

A Samuel Pottinger sampottinger

View GitHub Profile
@sampottinger
sampottinger / leopold.ino
Created May 5, 2012 16:21
Leopold the Lizard Logic
/**
* Name: leopold.ino
* Desc: Logic for running Leopold the Lizard
* Auth: Jessica Ebert, Sam Pottinger, DJ Sutton
**/
#include <Servo.h>
#define NECK_SERVO_PIN 5
#define MAIN_LOOP_DELAY 15
@sampottinger
sampottinger / ClassA.java
Created June 16, 2012 21:31
Java public method inheritance
public class ClassA {
public void test()
{
System.out.println("Testing...");
sayHi();
}
public void sayHi()
@sampottinger
sampottinger / cell.py
Created November 12, 2012 04:39
Cell
import Queue as queue
NORTH = 0
EAST = 1
SOUTH = 2
WEST = 3
class Cell:
#Walls are defined clockwise, [N,E,S,W], with 1 being a wall and 0 the lack of
@sampottinger
sampottinger / f4.py
Created November 21, 2012 01:11
Mysterious function...
import math
def F4(n):
if n == 0.0:
return 1.0
else:
part = (0.5 * (F4(n - 1.0)))**2.0
return math.sqrt(part + (1.0 - math.sqrt(1.0 - part))**2.0)
n = float(raw_input("Type in your value: ")) # Here's where I'm inputting the value
function retrieveUserInput()
{
var output = new Object();
output.heifer = { type: "heifer", grazing: {}, nongrazing: {} };
output.bred_heifer = { type: "bred_heifer", grazing: {}, nongrazing: {} };
output.springer = { type: "springer", grazing: {}, nongrazing: {} };
output.first_calf_heifer = { type: "first_calf_heifer", grazing: {}, nongrazing: {} };
output.dry = { type: "dry", grazing: {}, nongrazing: {} };
output.lactating = { type: "lactating", grazing: {}, nongrazing: {} };

LJSimpleRegisterLookup

LJSimpleRegisterLookup provides a web-based GUI for our device MODBUS maps.
LJSimpleRegisterLookup is released under the GNU GPL v2 license.

Overview for the project (tl;dr)

Although we don’t have user research to verify this intuition, it seems like users will want a MODBUS map for their device instead of a listing across all models. Thus, Simple Register Lookup provides a device drop-down menu that then displays MODBUS maps in a searchable / paginated table (http://www.datatables.net/). In addition to this embeddable front-end, a programmatic API is also available using simple HTTP GET requests on URLs following the pattern http://ljsimpleregisterlookup.herokuapp.com/lookup/U3.json. This JSON format is flattened for the GUI but we may want to support CSV in the future (like http://ljsimpleregisterlookup.herokuapp.com/lookup/U3.csv). The back-end is written in Flask (Python, http://flask.pocoo.org/) and runs on Heroku (http://www.heroku.com/). The front-end uses jQuery (htt

@sampottinger
sampottinger / mathtest.js
Last active December 11, 2015 01:49
Simple routine to run a list of tests on mathematical functions where each test checks the return value for equality against a known value using a list of predefined parameters. Requires http://www.diveintojavascript.com/projects/javascript-sprintf. Released under GNU GPL.
function addAll(a, b, c)
{
return a + b + c;
}
function multiplyAll(a, b, c)
{
return a * b * c;
}
@sampottinger
sampottinger / quick_sort.py
Created February 5, 2013 07:18
Crude implementation in QuickSort
def swap(target, i, j):
temp = target[i]
target[i] = target[j]
target[j] = temp
def quick_sort(target, low_index, high_index):
orig_low_index = low_index
orig_high_index = high_index
sub_array_size = high_index - low_index
pivot_index = low_index + sub_array_size / 2
@sampottinger
sampottinger / orrery_web_control_example.ino
Last active December 12, 2015 12:09
Example of what the Orrery Web Control logic might look like on an Arduino.
#include <Ethernet.h>
#include <HTTPClient.h>
#include <OrreryWebControl.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF }; // MAC address for the ethernet controller.
OrreryWebControl webController;
void setup()
{
Ethernet.begin(mac);
@sampottinger
sampottinger / split_array.c
Last active December 14, 2015 09:09
Shows how to slice arrays in C
void slice_array(int * dest, int * source, int start_index, int end_index)
{
memcpy(dest, source+start_index, (end_index-start_index)*sizeof(int));
}