Skip to content

Instantly share code, notes, and snippets.

View cfaulkingham's full-sized avatar

Colin Faulkingham cfaulkingham

View GitHub Profile
// Original xmlhttpRequest using the Greasemonkey object.
//
GM_xmlhttpRequest({
'method': 'GET',
'url': url,
'onload': function (xhr) {
parseGetLength(queueIdx, xhr.responseText);
}
});
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET',url,true);
httpRequest.setRequestHeader("Method", "GET " + url + " HTTP/1.1");
httpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpRequest.send(null);
// Register the callback to parseGetLength() when the request is done.
httpRequest.onreadystatechange = function() {
@cfaulkingham
cfaulkingham / expandCollapse.js
Created June 15, 2010 17:52
expandCollapse() code from Scripoting News
function expandCollapse(id){
var imgId = 'img_'+ id;
if(document.getElementById(id).className == 'hide'){
document.getElementById(id).className='show';
// This will allow the window to scroll to the expanded text
//
window.location.href = "#"+id;
document.getElementById(imgId).src='http://scripting.com/mktree/minus.gif';
}
else{
# Colin Faulkingham 10/5/2010
# Below is the replacement code fixes a XSS vulnerability with Apache Server errors using CGI::Application::Plus
; sub _run_runmode # __STEP must be 2 or 3 to run this
{ my ($s, $RM, @args) = @_
; $s->__STEP < 2 && croak qq(Too early to call this method)
; $s->__STEP > 3 && croak qq(Too late to call this method)
; defined $RM && length $RM || croak qq(No run mode passed)
; $s->runmode = $RM # switch RM allowed just from here
; my $rm = $s->run_modes
@cfaulkingham
cfaulkingham / server.js
Created June 30, 2011 15:48
This example shows how to setup up a web server on port 8000 and fetch 10 results from a mysql database and outputing the results in html
// Hacked together from http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/
// Colin Faulkingham
// This example shows how to setup up a web server on port 8000
// and fetch 10 results from a mysql database and outputting those results to HTML
//
// Version 2.0
// I cleaned up the code to be more readable.
@cfaulkingham
cfaulkingham / LoadImage.java
Created July 5, 2011 20:18
Used to convert an Jpeg image into values that my Drawbot can read.
/*
* Colin Faulkingham Drawbot Image Processing Code 2011
*
*/
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
@cfaulkingham
cfaulkingham / mysql_to_couchdb.js
Created July 21, 2011 18:14
This is a script to convert a MySQL table to a CouchDB database.
/*
Copyright (C) 2011 Colin Faulkingham, http://3a2d29.com/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@cfaulkingham
cfaulkingham / db.js
Created July 21, 2011 18:16
This is the configuration file for mysql_to_couchdb.js
settings = {
password: 'your_password',
user: 'your_user',
hostdb: 'your.server.address',
couchdbhttp: 'http://your_server_address',
couchdbhttpport: '5984' // couchdb default port
}
@cfaulkingham
cfaulkingham / VC0706.cpp
Created August 16, 2011 11:35
Modification to the serial camera module
boolean VC0706::setColorCtrl(uint8_t showMode, uint8_t controlMode) {
uint8_t args[] = {0x02,controlMode,showMode};
return runCommand(VC0706_COLOR_CTRL, args, 3, 5);
}
#define VC0706_COLOR_CTRL 0x3C
// I also added the following under
//class VC0706 {
// public:
boolean setColorCtrl(uint8_t,uint8_t);