Skip to content

Instantly share code, notes, and snippets.

View cfaulkingham's full-sized avatar

Colin Faulkingham cfaulkingham

View GitHub Profile
@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.
# 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 / 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{
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() {
// Original xmlhttpRequest using the Greasemonkey object.
//
GM_xmlhttpRequest({
'method': 'GET',
'url': url,
'onload': function (xhr) {
parseGetLength(queueIdx, xhr.responseText);
}
});