Skip to content

Instantly share code, notes, and snippets.

View raytiley's full-sized avatar

Ray Tiley raytiley

View GitHub Profile
@raytiley
raytiley / transcodeMP4.php
Created February 11, 2011 16:38
Transcodes files in a directory to mp4 using handbrakeCLI.
<?php
//Setup Content drives and Destination path
$contentPaths = array("/Volumes/VS400/", "/Volumes/SXServer/", "/Volumes/SXSafe/");
$destinationPath = "/Volumes/VODContent/mp4/";
$transcodeCommand = "HandBrakeCLI --preset \"iPhone & iPod Touch\" --width 320 --vb 500 --two-pass --turbo --optimize ";
//pid class used to determine if script is already running.
class pid {
@raytiley
raytiley / vod-table.php
Created January 11, 2012 21:20
A simple php script for printing a html table of links to On Demand Programming from Cablecast Servers
<?php
/*
This script prints an html table of all shows that are availalbe for VOD on the server
The shows must have valid event dates that are in the past
*/
//SETUP
date_default_timezone_set('America/New_York'); //Probably doesn't really matter. A few hours shouldn't make a difference
$serverAddress = "http://pittsfieldtv.dyndns.org/"; //This will be where you can publically log onto front door. Rembember to leave off trailing slash
$channelID = 1; //One will work for most stations unless you've deleted channels in the past
//END SETUP
@raytiley
raytiley / gist:2037893
Created March 14, 2012 17:02
Hashing first 100MB of a file
//Grab a SHA1 of the first 100MB file
LogToolbox.TraceMessage(string.Format("{0}: Generating SHA1: {1}", m_Parent.CMName, file.Key));
using (HashAlgorithm sha = new SHA1CryptoServiceProvider())
{
FileStream fs = null;
try
{
int bytesToSHA = 1024 * 1024 * 100; //100MB
byte[] first100MB = new byte[bytesToSHA];
fs = new FileStream(file.Key, FileMode.Open, FileAccess.Read);
@raytiley
raytiley / RDAProxy.js
Created April 20, 2012 20:05
A simple Carousel RDA Proxy that can turn tags on and off
var http = require('http');
var net = require('net');
var url = require('url');
//Config Settings
var HOST = 'demo.trms.com';
var PORT = 56906;
var USERNAME = 'Admin';
var PASSWORD = 'demotrms';
@raytiley
raytiley / routesController.js
Created April 22, 2012 21:04
Design Phase 4 - Routes Controller Example
// api/routes?start=300 main st boston&end=550 elm st boston&cost_table=popularity&route_type=cycle
app.get('api/routes', function(req,res){
//Parse Request for parameters
var start = req.params.start,
end = req.params.end,
costTable = req.params.cost_table,
routeType = req.params.route_type;
//Geocode Start and End
geoCoder.geocode([start,end], function(geoCodedResponse){
@raytiley
raytiley / ReportValidator.js
Created April 22, 2012 21:13
Design Phase 4 - Report Validator Module
//Anything not exported would be private and not accessible from the loaded module.
var privateVariable = 'I would be hidden';
//Public Method
//Returns JSON object of invalid properties and error descriptions
exports.validateReport = function(report) {
var errors = undefined;
//Return an object of propertyName : errorMessages for all invalid fields
@raytiley
raytiley / GeoCodingService.js
Created April 22, 2012 21:24
Design Phase 4 - GeoCoding Module
//Anything not exported would be private and not accessible from the loaded module.
var privateVariable = 'I would be hidden';
//Public Method
//Async geocodes array of search strings and calls callback with array of response when finished
exports.geocode = function(searchArray, callback(responseArray)) {
// Asynchronously geocode search array then execute callback
}
@raytiley
raytiley / ReportsRepository.js
Created April 22, 2012 21:44
Design Phase 4 - Report Validator Module
exports.createReport = function(report, callback(err, data)) {
//Persist the report object to database
//Update cost tables if needed
//Execute callback
}
exports.updateReport = function(report, callback(err, data)) {
//Update report object in database
//Update cost tables if needed
//Execute callback
@raytiley
raytiley / RoutingService
Created April 22, 2012 22:04
Design Phase 4 - Routing Service Module
exports.getRoute = function(startLat, startLon, endLat, endLon, routeType, costTable, callback(err, data)) {
//Return GeoJson route from pgRouting
//Execute callback
}
exports.updateCost = function(lat, lon, costTable, costDelta) {
//Update the cost of closest edge in costTable by costDelta
//Execute callback
}
@raytiley
raytiley / ReportResolver.js
Created April 22, 2012 22:44
Design Phase 4 - Report Resolver Module
//Include required modules and setup some variables
var reportsRepo = require('ReportsRepository'),
routingServ = require('RoutingService'),
TIMEOUT = 1000 * 60 * 5; // 5 minutes
setTimeout(function(){
//Lookup all unresolved reports that should be resolved due to current time
reportsRepo.getUnresolvedTimeReports(function(err, data){
//Itterate through each report
for(report in data) {