Skip to content

Instantly share code, notes, and snippets.

@DukeBaird
DukeBaird / node.cc
Created December 5, 2014 21:38
Copy & Swap
#include "node.h"
void Node::swap(Node &other) {
int tempnum = data;
data = other.data;
other.data = tempnum;
Node *tempnext = next;
next = other.next;
other.next = tempnext;
@DukeBaird
DukeBaird / graph.html
Last active August 29, 2015 14:05
D3 graph
<script src="d3.js"></script> //Not included in Gist
<script type="text/javascript" src="jquery.js"></script>
<script src="graph.js"></script>
<body>
<svg class='chart'></svg>
</body>
@DukeBaird
DukeBaird / kml.php
Created August 26, 2014 14:47
KML Maps
define('BASIC_AUTH', TRUE);
define('CMD_LINE_OK', TRUE);
require_once('KML.class.php'); //Should be online
$kml = new KML('File');
$document = new KML('Document');
$document->name = 'name';
$document->open = 1;
@DukeBaird
DukeBaird / phantomjs-example
Last active April 29, 2024 19:17
PhantomJS
var page = require('webpage').create();
var args = require('system').args;
page.onNavigationRequested = function(url, type, willNavigate, main) {
console.log('Trying to navigate to: ' + url);
console.log('Caused by: ' + type);
console.log('Will actually navigate: ' + willNavigate);
console.log('Sent from the page\'s main frame: ' + main);
}
@DukeBaird
DukeBaird / Waitfor
Last active January 6, 2016 19:13
Wait for
// From phantomjs
function waitFor(testFx, onReady, timeOutMillis) {
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 300000, // maxtimeout is 3m afaik
start = new Date().getTime(),
condition = false,
interval = setInterval(function() {
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
// If not time-out yet and condition not yet fulfilled
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code, reruns testFx to see if its good now