Skip to content

Instantly share code, notes, and snippets.

View mattneary's full-sized avatar

Matt Neary mattneary

View GitHub Profile
@mattneary
mattneary / app.coffee
Created June 9, 2013 01:48
Recursive Functions of Symbolic Expressions
# Elementary List Functions
cons = (a, b) -> (option) -> switch option
when true then a
else b
nil = null
atom = (x) -> typeof(x) != 'function'
car = (x) -> x(true)
cdr = (x) -> x(false)
# Functions on Recursive Pairs
#pragma config(Motor, motorA, leftMotor, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, motorB, rightMotor, tmotorNXT, PIDControl, encoder)
#pragma config(Sensor, S4, colorSensor, sensorCOLORFULL)
#include "Simple Car Header.c"
/*
___________________________________
| |
| /========================\ |
| | AUTOMATED PERIOD DIAGRAM | |
@mattneary
mattneary / fetch.js
Created May 30, 2013 00:21
Band Video Fetcher
var http = require('http'),
fs = require('fs');
var req = http.request({
mathod: 'GET',
host: 'brightcove03-f.akamaihd.net',
path: '/2012rebroadcastHD_dci_live@55848?videoId=2407134469001&lineUpId=&pubId=27638699&playerId=1684416337001&affiliateId=&v=2.11.3&fp=MAC%2011,7,700,203&r=SLZWK&g=RYSHXMKECKNV&seek=251.097',
port: '80'
}, function(resp) {
resp.pipe(fs.createWriteStream(__dirname + '/movie.flv'));
@mattneary
mattneary / hook.js
Created March 19, 2013 18:37
Github Service Hook
var http = require('http');
var exec = require('child_process').exec;
var repo = "https://github.com/mattneary/Watterson-Dresses.git";
http.createServer(function(req, res) {
exec("rm -rf /home/ec2-user/sites/Watterson-Dresses", function(err, stdout, stderr) {
if( err ) {
res.writeHead(400);
res.end("error: "+JSON.stringify(err))
return;
@mattneary
mattneary / index.js
Last active December 15, 2015 03:09
ec2 server file
var net = require('net');
var httpProxy = require('http-proxy');
var sites = [{
domain: "bwhs.me",
path: __dirname + "/sites/Watterson-Dresses/server.js",
port: 3001
}];
var options = {
@mattneary
mattneary / prime.hs
Last active December 11, 2015 06:39
Haskell Array-based isPrime
module Main where
grid range = [[i,j] | i <- range, j <- range] -- construct grid of number pairs
multiplicationTable grid = map (\l -> foldl (*) 1 l) grid -- multiply said pairs
isPrime number = not $ any (==number) $ (multiplicationTable . grid) [2 .. number] -- check for presence in table
main = print $ map (\p -> (fst p, (isPrime . fst) p)) [(i, b) | i <- [1 .. 100], b <- [True]] -- map all numbers to primeness
@mattneary
mattneary / main.c
Created January 10, 2013 22:29
Robot-C
#pragma config(Sensor, S1, IR, sensorI2CCustom)
//#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop)
//#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop, reversed)
/*
TO-DO
- find real value of timeEnd
- find motor strengths
- find left and right motors
*/
@mattneary
mattneary / index.js
Created January 8, 2013 02:02
Wavelength-To-RGB
var color = function(wavelength) {
var bounds = [380, 440, 490, 510, 580, 645, 780];
var pairs = ["BR", "BG", "GB", "GR", "RG", "R"]
var colorGen = function(combo, borders, wl) {
var RGB = {R:0,G:0,B:0};
RGB[combo[0]] = 255;
RGB[combo[1]] = 255 * (borders[1] - wl)/(borders[1] - borders[0]);
return RGB;
};
var residuals = bounds.map(function(bound){return bound-wavelength}).map(Math.abs);
@mattneary
mattneary / index.js
Created December 18, 2012 00:08 — forked from anonymous/index.js
var Queue = function(parts) {
var index = 0;
this.read = function() {
var part = parts[index];
index++;
return part;
};
this.next = function() {
var thiz = this;
@mattneary
mattneary / index.html
Created December 11, 2012 00:33
Simple JS Chat displaying Prototypes
<!-- Socket.io Library Include -->
<script src="https://raw.github.com/LearnBoost/socket.io-client/master/dist/socket.io.min.js"></script>
<!-- Page Structure -->
<ol id="messages"></ol>
<input type="text" id="message">
<input type="button" id="send" value="Send">
<!-- Styling -->
<style>
.msg_to, .msg_from {
list-style: none;