Skip to content

Instantly share code, notes, and snippets.

View peterhughesdev's full-sized avatar

Peter Hughes peterhughesdev

View GitHub Profile
@peterhughesdev
peterhughesdev / authenticator.js
Created January 29, 2020 16:15
Diffusion Authenticator example
let session = await diffusion.connect({
host: <host>,
principal: <admin username>,
credentials: <admin password>
});
let authenticator = {
authenticate(principal, credentials, sessionProperties, proposedProperties, callback) {
console.log('Auth:', principal, proposedProperties);
@peterhughesdev
peterhughesdev / index.js
Created November 22, 2016 22:38
Basic usage of commander.js
var commander = require('commander');
commander.version('0.0.1')
.option('-h, --host <n>', 'The hostname', 'localhost')
.option('-p, --port <n>', 'The port', 8080)
.option('-t, --topic <n>', 'The topic', 'foo')
.parse(process.argv);
var host = commander.host
var port = commander.port
@peterhughesdev
peterhughesdev / pom.xml
Last active October 1, 2022 14:09
A sample POM for building a Javascript project with Maven
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.peterhughes.dev</groupId>
<artifactId>js-test-example</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
public class Foo {
public static void whee() { System.out.println("Oh god why"); }
public static void main(String[] args) {
Foo nothing = null;
nothing.whee();
((Foo)null).whee();
}
}
@peterhughesdev
peterhughesdev / index.html
Created February 1, 2013 10:46
Gauge proof-of-concept
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.progress-meter .background {
fill: #ccc;
}
.progress-meter .foreground {
fill: #000;
@peterhughesdev
peterhughesdev / LICENSE.txt
Created July 10, 2012 14:30 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@peterhughesdev
peterhughesdev / jquery.color.js
Created January 20, 2012 11:46
Minified version of jQuery UI color functionality
$.each("backgroundColor,borderBottomColor,borderLeftColor,borderRightColor,borderTopColor,borderColor,color,outlineColor".split(","),function(c,a){$.fx.step[a]=function(b){if(!b.colorInit)b.start=getColor(b.elem,a),b.end=getRGB(b.end),b.colorInit=!0;b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2], 10),255),0)+")"}}); function getRGB(c){var a;return c&&c.constructor==Array&&3==c.length?c:(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))?[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)]:(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))?[2.55*parseFloat(a[1]),2.55*parseFloat(a[2]),2.55*parseFloat(a[3])]:(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))?[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],1
@peterhughesdev
peterhughesdev / Class.js
Created January 11, 2012 13:48
Resig's Class.extend minified
var Class = function(){var d=!1,g=/xyz/.test(function(){})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(b){function c(){!d&&this.init&&this.init.apply(this,arguments)}var e=this.prototype;d=!0;var f=new this;d=!1;for(var a in b)f[a]="function"==typeof b[a]&&"function"==typeof e[a]&&g.test(b[a])?function(a,b){return function(){var c=this._super;this._super=e[a];var d=b.apply(this,arguments);this._super=c;return d}}(a,b[a]):b[a];c.prototype=f;c.prototype.constructor=c;c.extend=arguments.callee; return c};return Class}();