Skip to content

Instantly share code, notes, and snippets.

View msh9's full-sized avatar

Michael Hughes msh9

View GitHub Profile
@msh9
msh9 / index.html
Last active August 3, 2016 13:39
Handling WebSocket Errors
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>WebSocket Demostration</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@msh9
msh9 / test-add.js
Created February 20, 2016 21:18
Testing different counter addition strategies
'use strict';
var RUNS = 10;
var ITERATIONS = 10000000;
function Counter(initialValue) {
this.val = initialValue;
}
Counter.prototype.addWithOr = function addWithOr(incrVal) {
this.val += incrVal || 1;
@msh9
msh9 / concatTest.js
Created October 13, 2015 02:31
Testing performance of difference ways of appending to a new array.
'use strict';
var iterations = 1000000,
outerIterations = 100;
function runit() {
var ary
,result
,idx;
ary = createData();
console.log('Executing while loop with prefix incre in test condition');
@msh9
msh9 / loopTest.js
Last active May 5, 2017 04:10
Test different types of JavaScript looks for NodeJS v0.12.0
'use strict';
var iterations = 1000000,
outerIterations = 100;
function runit() {
var ary
,result
,idx;
ary = createData();
console.log('Executing while loop with prefix incre in test condition');
@msh9
msh9 / olingoWrapperService.js
Last active August 29, 2015 14:12
Olingo--AngularJS
'use strict';
myApp.factory('olingoWrapperService', ['localStorageService','$location', '$q', '$rootScope', function (localStorageService, $location, $q, $rootScope) {
var _recipeService = {};
var _oldOlingoODataClient = odatajs.oData.net.defaultHttpClient;
var _authSensitiveOlingoClient = {
request: function (request, success, error) {
request.headers = request.headers || {};
var authData = localStorageService.get('authorizationData');
@msh9
msh9 / CreateDB.sql
Last active August 29, 2015 14:10
Experimenting with SQL NULL vs. blank
USE [master]
GO
/****** Object: Database [Experiments] Script Date: 11/30/2014 4:39:05 PM ******/
CREATE DATABASE [Experiments]
GO
ALTER DATABASE [Experiments] SET COMPATIBILITY_LEVEL = 110
GO
ALTER DATABASE [Experiments] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Experiments] SET ANSI_NULLS OFF
@msh9
msh9 / ProcessDatesOnElements.js
Last active August 29, 2015 14:01
Processing dates
//N.B. Use Steven Levithan's date formatter for richer string output options
//http://blog.stevenlevithan.com/archives/date-time-format
if (window.addEventListener) // W3C standard
{
window.addEventListener('load', function() {
var timeElements = document.getElementsByClassName('make-time');
for (var i = 0; i < timeElements.length; i++) {
var dateStr = timeElements[i].getAttribute('data-time');
if (dateStr) {
@msh9
msh9 / CompleteTwoSelects.html
Last active August 29, 2015 14:01
Slightly more complex select box and knockoutjs
<!DOCTYPE HTML>
<head>
<title>A working shuttle</title>
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.0.0.js" type="text/javascript"></script>
<script type="text/javascript">
var vm = function() {
var self = this;
self.someFunction = function() {
alert('hello');
@msh9
msh9 / Example.html
Created May 18, 2014 16:08
Very simple usage of Ko and select element
<!DOCTYPE HTML>
<head>
<title>A Knockout select example</title>
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.0.0.js" type="text/javascript"></script>
<script type="text/javascript">
var vm = function() {
var self = this;
self.myList = ko.observableArray();
@msh9
msh9 / my.kv
Last active August 29, 2015 13:58
Rotating
<MyGame>:
FloatLayout:
size: self.parent.width, self.parent.height
MyWidget:
id: widget
pos_hint: {'x': 0, 'y': .5 }
<MyWidget>:
canvas.before:
PushMatrix