Skip to content

Instantly share code, notes, and snippets.

View natecavanaugh's full-sized avatar

Nate Cavanaugh natecavanaugh

View GitHub Profile
@natecavanaugh
natecavanaugh / add_shape_to_chart.js
Created November 1, 2012 16:27
add shape to chart
/*pc = A.Widget.getByNode($0);
g = pc.get("graph").get("graphic");
var w = g.get('width'), h = g.get('width');
var nw = w - 100, nh = h - 100;
var c = g.addShape({type: 'circle',
width: nw,
height: nh,
x: 100,
y: 100,
fill: {color: '#ffffff'},
@natecavanaugh
natecavanaugh / module_load_order.js
Created October 31, 2012 16:56
Show ordering of hierarchy and method invocation during instantiation
var first1 = function(c){
this.__NAME = this.constructor.NAME;
console.log('first1 constructor', this.__NAME);
first1.superclass.constructor.apply(this, arguments);
};
first1.NAME = 'first1';
A.extend(first1, A.Widget, {
initializer: function(){
@natecavanaugh
natecavanaugh / performance_timing.js
Created October 31, 2012 00:16
performance timing log
var pt = A.one('#manageContentDialog').get('contentWindow.performance.timing');
var inSec = function(v){return v /= 1000;};
console.log('Network latency: %d, Entire load: %d, page load time: %d', inSec(pt.responseEnd - pt.fetchStart), inSec(pt.loadEventEnd-pt.navigationStart), inSec(pt.loadEventEnd-pt.responseEnd));
@natecavanaugh
natecavanaugh / detect_js_version.js
Created September 28, 2012 00:53
detect_js_version
var ifr = document.createElement('iframe');
ifr.src = 'javascript:;';
ifr.style.display = 'none';
document.body.appendChild(ifr);
var js = [];
for (var i = 0; i < 11; i++) {
js.push('<script ' + (i !== 0 ? 'language="Javascript1.' + i + '"' : 'type="text/language"') + '">window.jsversion = 1.'+ i +';</script>');
}
ifr.contentWindow.document.write(js.join(''));
console.log(ifr.contentWindow.jsversion);
@natecavanaugh
natecavanaugh / alloy_treeview_perf_test.js
Created July 20, 2012 23:57
Alloy treeview performance test
var A = AUI();
var Lang = A.Lang;
var now = Lang.now;
var number_of_levels = 10;
var ts = now();
create_children = function(amount, level) {
amount = amount || 10;
if (level <= 3) {
@natecavanaugh
natecavanaugh / poll_for_brad.jsp
Created July 17, 2012 17:08
poll_for_brad.jsp
<aui:script use="aui-io-request">
var timer;
var request = A.io.request(
'/url'
{
dataType: 'json',
on: {
success: function(event) {
var response = this.get('responseData');
var responseStatus = response.status;
@natecavanaugh
natecavanaugh / git-pull-request.py
Created June 21, 2012 23:13
testing pr change
#!/usr/bin/env python
"""
Git command to automate many common tasks involving pull requests.
Usage:
gitpr [<options>] <command> [<args>]
Options:
@natecavanaugh
natecavanaugh / nav_tab_thing.html
Created June 6, 2012 18:16
navigation-tab-thing
<!DOCTYPE html>
<html>
<head>
<script src="../../build/aui/aui.js" type="text/javascript"></script>
<link rel="stylesheet" href="../../build/aui-skin-classic/css/aui-skin-classic-all-min.css" type="text/css" media="screen" />
<style type="text/css" media="screen">
body {
function checkFiles($filearr, $uploaddir, $requireimage=false, $filter=array())
{
$maxsize = ini_get("upload_max_filesize");
$final = array('errors' => array(),
'files' => array(),
'result' => array()
);
@natecavanaugh
natecavanaugh / cplinks.html
Created April 26, 2012 21:48
Control panel links